Find all colors in an image and compare?

J

Jmc

Hi
Need some advice on how to get all colors in an image.
I wish to have an input file, in my case it will be a scanned piece of
fabric.
I would like to first of all gen an array with all the colors
represented in the image.
and an percentage of how much the color exists.

Lets assume that the color of the fabric is blue, it will probably have
pixels that are not #0000FF since the diferent threads in the fabric
creates darker areas.
So when getting the colors I need to have a threshold, a percentage
that a color needs to differ to "become" a new bolor in the color
array.
So the problem is how do I get all unique colors from an imaga, (with a
threshold) bacically
#0000FF = blue #0000EE probably the same blue therefore not a new
color.
I guess that its the most light color tha should be assumed to be the
color, what do you think?

(Hope this makes sence).
best regards
/Jimmy
 
H

Hans Kesting

Hi
Need some advice on how to get all colors in an image.
I wish to have an input file, in my case it will be a scanned piece of
fabric.
I would like to first of all gen an array with all the colors
represented in the image.
and an percentage of how much the color exists.

Lets assume that the color of the fabric is blue, it will probably have
pixels that are not #0000FF since the diferent threads in the fabric
creates darker areas.
So when getting the colors I need to have a threshold, a percentage
that a color needs to differ to "become" a new bolor in the color
array.
So the problem is how do I get all unique colors from an imaga, (with a
threshold) bacically
#0000FF = blue #0000EE probably the same blue therefore not a new
color.
I guess that its the most light color tha should be assumed to be the
color, what do you think?

(Hope this makes sence).
best regards
/Jimmy

probably something along the lines of:
1) loop through all pixels of the image, reading color values
2) change the color value to some "normalized value" to group similar
colors (maybe: forget some least-significant bits of the R,G&B values)
3) mark those color values in some list: key = color value; value =
count (if it is not in the list, add with value 1; if it is, increase
the value)

Note: you can't just go through some sorted list to compare values and
see if they are "similar". Say you have numbers from 1 to 10. 1 is
almost equal to 2, so let's group them together. And 3 is almost 2, so
group together. And 4 is almost 3 and ... and 9 is almost 10. So is now
1 almost equal to 10??

Hans Kesting
 
J

Jmc

Thanks Hans
It souns like a resonable way to do things.
Having a bit trouble finding a good way to group the colors though.
If you have any suggestion im happy to listen ;)

/Jimmy
 
J

Jmc

Thanks I've acctually done that.
I discussed the problem with a friend at work, seems to be the best
solution to use hsl.
What I would like to do is to be able to reduce the numer of colors in
the picture first.
Photoshop can reduce the number och colors in an image by using
Perseptive palette (gif).
This seems to be what I want to do.
This way I'll only get the mos interesting colors in the picture and
resused to an amount that I can handle.
Any suggestions ono how I can reduce the number o colors in an image
using perseptive palette? (or somethimg simular?

/Jimmy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top