471,319 Members | 3,224 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Find all colors in an image and compare?

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

Feb 13 '06 #1
4 3691
> 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
Feb 13 '06 #2
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

Feb 14 '06 #3
Try converting the RGB values to HSI values (Hue/Saturation/Intensity).
http://www.google.com/search?hl=en&q=rgb+hsi

Feb 14 '06 #4
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

Feb 14 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by RootShell | last post: by
2 posts views Thread by | | last post: by
7 posts views Thread by Laszlo Zsolt Nagy | last post: by
3 posts views Thread by Mr. x | last post: by
reply views Thread by mark | last post: by
15 posts views Thread by Thomas W | last post: by
8 posts views Thread by Larry Bates | last post: by
2 posts views Thread by Piotrekk | last post: by
1 post views Thread by Vegethalia | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.