473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 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 3923
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: RootShell | last post by:
Hello How can i use the GD Library to only show the White (or the hex value of white) pixels of a image? Imagine i have a 8 color picture in PNG format. This is to use on a color puzzle...
2
by: | | last post by:
hi, is it a php bug or i do smth wrong? From site http://www.allegro.pl/show_user_auctions.php?uid=45432 I`m taking images (those thumbs) and its name at right.
7
by: Laszlo Zsolt Nagy | last post by:
Hello, How can I determine the number of colors used in an image? I tried to search on Google but I could figure out. I read the PIL handbook but I do not see how to do it. Can anyone help? ...
3
by: Mr. x | last post by:
Hello, I would like that my image's background color will be transparent. What I have is only paintbrush. My image is *.jpg format (I have tried to save it as *.gif format, and I got less...
0
by: mark | last post by:
Somebody can explain me why if I put a color with SetPixel the color showed is of another value? For example: I've to draw a grayscale image. The color RGB(90,90,90) become RGB(40,45,60). In the...
15
by: Thomas W | last post by:
How can I use python to find images that looks quite similar? Thought I'd scale the images down to 32x32 and convert it to use a standard palette of 256 colors then compare the result pixel for...
8
by: Larry Bates | last post by:
I have a project that I wanted to solicit some advice on from this group. I have millions of pages of scanned documents with each page in and individual .JPG file. When the documents were scanned...
2
by: Piotrekk | last post by:
Hi I have a problem. I open bitmap file, load it to memory decrease color palette by proceeding Euclidean distance. As a result i have image reduced to - for example 18 colors. Once i save it -...
1
by: Vegethalia | last post by:
Dear all, I'm sure that im doing something wrong, but I can't imagine what! My problem is the following: I create an image using imagecreatetruecolor, and, after some painting, I push the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.