Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
machine vision-Color Matching

Subject: machine vision-Color Matching

From: Vihang Patil

Date: 20 Feb, 2008 08:08:02

Message: 1 of 22

Hello All
I am in the process of developing machine vision system i
Matlab, primarily to detect color change, "basic colors
only and not shades".
This is what I have achieved so far, please let me know
after going through the details below if there is
something which probably missing the way I am developing
it.

Preliminary Details:
1. The object to be detected for color change comes in the
following 4 colors;Metallic BLOOD RED, Metallic BlACK,
Metallic SILVER, Metallic BLUE.
2. They are coming on the conveyor at a speed about 1.25
to 1.66 objects/min, ie roughly 600 - 800 in an 8 hour
shift.
3. Ligting condition is flouroscent tube

My steps for Reference Image:
1. I have placed a trigger on the conveyor such that,
whenever the object crosses it, the camera will take an
image
2. I crop the Region of Interest and Store the image
details of the part of my interest.
3. Convert the cropped image into indexed image for ex:
rgb2ind(img,1,'nodither'); so that I have a single uniform
colored image
4. Get the value of the color from the centroid of the
cropped image.
5. Store the details of the 4 colors in the mat file for
further testing process.

Testing Part:
1. I take the image and do the same analysis as discussed
in Step 1 to 4 of the above discussion.
2. Then do the color matching part.
My logic here as descibed by the example below

Suppose I have got these values for the colors from the
reference image

black = [18 22 25];
silver = [179 185 191];
red = [123 3 10];
blue = [75 96 237];

Now it is pretty obvious that due to the ambient lighting
condition and other factors, you will not get the same
color match or perfect match for the object in test
condition and I get a value which is say

color = [80 110 217];
My question is "How do we determine and tell that it is
blue"
or if I get
color = [194 208 211], "How do I determing that it is
Silver".

I hope I am able to explain or let you all visualize the
problem.

My logic tells me that I should do the following
1. testimgval = color(1) + color(2) + color(3) = (80 + 110
+217) = 407
2. Do the summation of all the stored colors by the same
way and do subtraction.
ex:
Blackval = black(1) + black(2) + black(3) = 65;
Similarly other color will be;
Redval = 126;
Silverval = 555;
Blueval = 408
3. Subtract testimageval from each of the colorval and the
minimum value which corresponds to that color is the color
detected.
i.e
 abs(407 - 65) = 342;
abs(407-126) = 281;
abs(407 -555) = 148
abs(407 - 408) = 1 = ----> least from all above so the
color must be Blue.

But I some how dont get the same satisfactory results by
my above calculation. i.e sometimes I get blue when the
object is actually silver, I get red if the object is
black and so on and so forth.
Am I missing something very imp in designing this machine
vision system?
 I know its not directly related to Matlab in any way, but
just looking for some imp comments from those, who feel
probably there is something which is still required there.
Thanks
Vihang
 

Subject: machine vision-Color Matching

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 20 Feb, 2008 09:12:02

Message: 2 of 22

In article <fpgn52$9ij$1@fred.mathworks.com>,
Vihang Patil <vihang_patil@yahoo.com> wrote:

>1. The object to be detected for color change comes in the
>following 4 colors;Metallic BLOOD RED, Metallic BlACK,
>Metallic SILVER, Metallic BLUE.

>Suppose I have got these values for the colors from the
>reference image

>Now it is pretty obvious that due to the ambient lighting
>condition and other factors, you will not get the same
>color match or perfect match for the object in test
>condition and I get a value which is say

>color = [80 110 217];
>My question is "How do we determine and tell that it is
>blue"

I suggest you experiment with rgb2hsv and examine the hue (H).
Red, silver, and blue should all be well seperated in hue;
to distinguish black you -might- need examine intensity
(black could be a "very dark" of any of the hues.)

Or you could try sum(abs(color - reference)) or
sum((color - reference).^2) for each of the reference colors
and find the minimum difference.
--
  "All is vanity." -- Ecclesiastes

Subject: machine vision-Color Matching

From: Michael McKay

Date: 20 Feb, 2008 14:28:02

Message: 3 of 22

I think Walter's suggestion to use hue is the key. The RGB
values can change significantly between similar hues and
light intensities. The hue value is largely invariant with
intensity but it will change with the illumination color
and "temperature". With the hue value you can select a
range of "blood reds" that meet your criteria.

To improve the robustness, you can use a trick from machine
vision and include a test area in each image. The test
area would be an known grey color that you can use to check
the white balance of the image prior to converting RGB
values to HSI. If you can place a grey area in the field
of view of the camera consistently, and then use this to
balance the RGB channels, the output should be more robust
to slight changes in the light temperature and intensity.
Use the RGB value of the grey area to determine three
multipliers (gains) to apply to each color channel.
Normalize the gains so that one of them is equal to 1 (one)
and apply them to the respective colors in the other ROIs.
Try to ensure that the grey area is really grey - no color
channel should be saturated or over say 240 for a 8-bit
image. In other words, keep the image data in the linear
region of the camera sensor. Alternatively, if you have
progromatic control of your camera, command the camera to
perform the white balance and recapture the image.

After you have balanced the RGB values, convert to HSI and
then compare the hue to the range of hues you are willing
to accept.

For fun, you could zero the intensity (the I in HSI) of
every pixel in the image that does not have the correct
hue, convert back to RGB and display the image. Only the
objects with the correct color should appear.

Good luck with your project.

Subject: machine vision-Color Matching

From: ImageAnalyst

Date: 20 Feb, 2008 17:05:41

Message: 4 of 22

On Feb 20, 3:08=A0am, "Vihang Patil" <vihang_pa...@yahoo.com> wrote:
> Hello All
> I am in the process of developing machine vision system i
> Matlab, primarily to detect color change, "basic colors
> only and not shades".
> This is what I have achieved so far, please let me know
> after going through the details below if there is
> something which probably missing the way I am developing
> it.
>
> Preliminary Details:
> 1. The object to be detected for color change comes in the
> following 4 colors;Metallic BLOOD RED, Metallic BlACK,
> Metallic SILVER, Metallic BLUE.
> 2. They are coming on the conveyor at a speed about 1.25
> to 1.66 objects/min, ie roughly 600 - 800 in an 8 hour
> shift.
> 3. Ligting condition is flouroscent tube
>
> My steps for Reference Image:
> 1. I have placed a trigger on the conveyor such that,
> whenever the object crosses it, the camera will take an
> image
> 2. I crop the Region of Interest and Store the image
> details of the part of my interest.
> 3. Convert the cropped image into indexed image for ex:
> rgb2ind(img,1,'nodither'); so that I have a single uniform
> colored image
> 4. Get the value of the color from the centroid of the
> cropped image.
> 5. Store the details of the 4 colors in the mat file for
> further testing process.
>
> Testing Part:
> 1. I take the image and do the same analysis as discussed
> in Step 1 to 4 of the above discussion.
> 2. Then do the color matching part.
> My logic here as descibed by the example below
>
> Suppose I have got these values for the colors from the
> reference image
>
> black =3D [18 22 25];
> silver =3D [179 185 191];
> red =3D [123 3 10];
> blue =3D [75 96 237];
>
> Now it is pretty obvious that due to the ambient lighting
> condition and other factors, you will not get the same
> color match or perfect match for the object in test
> condition and I get a =A0value which is say
>
> color =3D [80 110 217];
> My question is "How do we determine and tell that it is
> blue"
> or if I get
> color =3D [194 208 211], "How do I determing that it is
> Silver".
>
> I hope I am able to explain or let you all visualize the
> problem.
>
> My logic tells me that I should do the following
> 1. testimgval =3D color(1) + color(2) + color(3) =3D (80 + 110
> +217) =3D 407
> 2. Do the summation of all the stored colors by the same
> way and do subtraction.
> ex:
> Blackval =3D black(1) + black(2) + black(3) =3D 65;
> Similarly other color will be;
> Redval =3D 126;
> Silverval =3D 555;
> Blueval =3D 408
> 3. Subtract testimageval from each of the colorval and the
> minimum value which corresponds to that color is the color
> detected.
> i.e
> =A0abs(407 - 65) =3D 342;
> abs(407-126) =3D 281;
> abs(407 -555) =3D 148
> abs(407 - 408) =3D 1 =3D ----> least from all above so the
> color must be Blue.
>
> But I some how dont get the same satisfactory results by
> my above calculation. i.e sometimes I get blue when the
> object is actually silver, I get red if the object is
> black and so on and so forth.
> Am I missing something very imp in designing this machine
> vision system?
> =A0I know its not directly related to Matlab in any way, but
> just looking for some imp comments from those, who feel
> probably there is something which is still required there.
> Thanks
> Vihang

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
Vihang:
You need to convert your colors to another color space such as LAB or
HSV, etc. Then you can calculate Delta E which is the color
difference. One definition of delta E (there are several) is the
Euclidean distance in LAB space. You can then set a tolerance from
your reference colors. For example, say your object is the color with
the lowest Delta E, unless your Delta E is more than (say) 10 in which
case it's an unknown color.
Go to http://www.easyrgb.com/math.html for some convenient "book"
formulas that will probably work well in your situation.
Delta E is the most general color difference formula. It will work
better than those that only check lightness or hue, because it works
in three dimensions, not just a single dimension. Delta E is the
standard method for measuring color difference in the color industry
and you should learn how to use it.
Regards,
ImageAnalyst
P.S. Here's another nice web site that you might enjoy: http://www.efg2.com/

Subject: machine vision-Color Matching

From: Vihang Patil

Date: 21 Feb, 2008 10:01:06

Message: 5 of 22

Thank You
Walter, Michael and ImageAnalyst, for your valuable
suggestions. I will definately probe into each of the
above said options. Its so rewarding to have such good
friends around the globe.

Cheers!! to all
Vihang

Subject: machine vision-Color Matching

From: John D'Errico

Date: 21 Feb, 2008 11:00:17

Message: 6 of 22

"Vihang Patil" <vihang_patil@yahoo.com> wrote in message
<fpgn52$9ij$1@fred.mathworks.com>...
> Hello All
> I am in the process of developing machine vision system i
> Matlab, primarily to detect color change, "basic colors
> only and not shades".
> This is what I have achieved so far, please let me know
> after going through the details below if there is
> something which probably missing the way I am developing
> it.
>
> Preliminary Details:
> 1. The object to be detected for color change comes in the
> following 4 colors;Metallic BLOOD RED, Metallic BlACK,
> Metallic SILVER, Metallic BLUE.
> 2. They are coming on the conveyor at a speed about 1.25
> to 1.66 objects/min, ie roughly 600 - 800 in an 8 hour
> shift.
> 3. Ligting condition is flouroscent tube
>
> My steps for Reference Image:
> 1. I have placed a trigger on the conveyor such that,
> whenever the object crosses it, the camera will take an
> image
> 2. I crop the Region of Interest and Store the image
> details of the part of my interest.
> 3. Convert the cropped image into indexed image for ex:
> rgb2ind(img,1,'nodither'); so that I have a single uniform
> colored image
> 4. Get the value of the color from the centroid of the
> cropped image.
> 5. Store the details of the 4 colors in the mat file for
> further testing process.
>
> Testing Part:
> 1. I take the image and do the same analysis as discussed
> in Step 1 to 4 of the above discussion.
> 2. Then do the color matching part.
> My logic here as descibed by the example below
>
> Suppose I have got these values for the colors from the
> reference image
>
> black = [18 22 25];
> silver = [179 185 191];
> red = [123 3 10];
> blue = [75 96 237];

You don't really need to change color spaces.
Any color space still needs you to identify a
region of that space. For example, hue will be
a poor measure to identify black pixels.

Just throwing this at my fuzzycolor, I get...

black = [18 22 25];
silver = [179 185 191];
red = [123 3 10];
blue = [75 96 237];

[iscolor,cn] = fuzzycolor(blue/255,'all');cn{find(iscolor)}
ans =
blue

[iscolor,cn] = fuzzycolor(red/255,'all');cn{find(iscolor)}
ans =
red

[iscolor,cn] = fuzzycolor(black/255,'all');cn{find(iscolor)}
ans =
neutral

[iscolor,cn] = fuzzycolor(silver/255,'all');cn{find(iscolor)}
ans =
pastel


Although I note that your black was not really
dark enough to register as black. You could
change the definition of black to fix this. And
"silver" is not a color that I'd defined in the
database, so it comes out as a "pastel".

Try changing the blue pixel a bit.

[iscolor,cn] = fuzzycolor([60 100 220]/255,'all');cn{find(iscolor)}
ans =
blue

Still blue, no problems. Find fuzzycolor on
the file exchange.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
objectId=12326&objectType=FILE

HTH,
John

Subject: machine vision-Color Matching

From: Vihang Patil

Date: 27 Feb, 2008 16:30:26

Message: 7 of 22

"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <fpjlk1$3ho$1@fred.mathworks.com>...


> Try changing the blue pixel a bit.
>
> [iscolor,cn] = fuzzycolor([60 100 220]/255,'all');cn{find
(iscolor)}
> ans =
> blue
>
> Still blue, no problems. Find fuzzycolor on
> the file exchange.
>
>
http://www.mathworks.com/matlabcentral/fileexchange/loadFil
e.do?
> objectId=12326&objectType=FILE
>
> HTH,
> John

Hello John
I tried your fuzzycolor, its good, but I think it requires
a lot of tweaking too
for example
[iscolor,cn] = fuzzycolor([88 110 255]/255,'all');cn{find
(iscolor)}

I get no color whereas it is very much blue to me, which
you can see from the code below.

new = im2uint8(ones([128 128 3]));
new(:,:,1) = 88;
new(:,:,2) = 110;
new(:,:,3) = 255;
figure,imshow(new);

I think I will need to add this into the fuzzycolor's
database. I am still working on it. Probably you can
through more insight on it.

Vihang

Subject: machine vision-Color Matching

From: John D'Errico

Date: 27 Feb, 2008 17:56:03

Message: 8 of 22

"Vihang Patil" <vihang_patil@yahoo.com> wrote in message
<fq4372$hem$1@fred.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in
> message <fpjlk1$3ho$1@fred.mathworks.com>...
>
>
> > Try changing the blue pixel a bit.
> >
> > [iscolor,cn] = fuzzycolor([60 100 220]/255,'all');cn{find
> (iscolor)}
> > ans =
> > blue
> >
> > Still blue, no problems. Find fuzzycolor on
> > the file exchange.
> >
> >
> http://www.mathworks.com/matlabcentral/fileexchange/loadFil
> e.do?
> > objectId=12326&objectType=FILE
> >
> > HTH,
> > John
>
> Hello John
> I tried your fuzzycolor, its good, but I think it requires
> a lot of tweaking too
> for example
> [iscolor,cn] = fuzzycolor([88 110 255]/255,'all');cn{find
> (iscolor)}
>
> I get no color whereas it is very much blue to me, which
> you can see from the code below.
>
> new = im2uint8(ones([128 128 3]));
> new(:,:,1) = 88;
> new(:,:,2) = 110;
> new(:,:,3) = 255;
> figure,imshow(new);
>
> I think I will need to add this into the fuzzycolor's
> database. I am still working on it. Probably you can
> through more insight on it.
>
> Vihang

Yes, I may have missed some blues when I built
the database. As I recall, I did try to provide an
ability to add to or change the database.

A problem is that what I considered to be a blue,
on MY monitor, may not always coincide with
others opinion of a blue. There are several issues
of metamerism here to deal with. If your monitor
is set up with a higher or lower color temperature,
then blues might change. Or suppose one of us
is moderately color blind, perhaps protoanomalous
(red-green) or even tritananomalous (yellow-blue).
Even a minor amount of such an effect can influence
how you might see colors differently from me. Since
different people can have subtly different pigments
in their cones, they can see colors differently even
if not color blind at all.

These issues are why I called it fuzzy color. The
boundaries of a color name region will be both
irregular and fuzzy. In fact, some color name
regions may even overlap, i.e., colors near the
boundary of two color names like yellow/green,
might be arguably both yellow and green.

For your work, a simple solution is to build/modify
the database for your own eyes & monitor. Ask if
you have questions. I'd have to revisit the code,
but it was not hard to do using the buildfuzzyluts
function that I provided. The idea is it pops up
a series of color planes, then you encircle those
colors which satisfy your colorname with a
polygon in each plane.

John

Subject: machine vision-Color Matching

From: ImageAnalyst

Date: 28 Feb, 2008 04:32:44

Message: 9 of 22

On Feb 20, 3:08=A0am, "Vihang Patil" <vihang_pa...@yahoo.com> wrote:
> Hello All
> I am in the process of developing machine vision system i
> Matlab, primarily to detect color change, "basic colors
> only and not shades".
> This is what I have achieved so far, please let me know
> after going through the details below if there is
> something which probably missing the way I am developing
> it.
>
> Preliminary Details:
> 1. The object to be detected for color change comes in the
> following 4 colors;Metallic BLOOD RED, Metallic BlACK,
> Metallic SILVER, Metallic BLUE.
> 2. They are coming on the conveyor at a speed about 1.25
> to 1.66 objects/min, ie roughly 600 - 800 in an 8 hour
> shift.
> 3. Ligting condition is flouroscent tube
>
> My steps for Reference Image:
> 1. I have placed a trigger on the conveyor such that,
> whenever the object crosses it, the camera will take an
> image
> 2. I crop the Region of Interest and Store the image
> details of the part of my interest.
> 3. Convert the cropped image into indexed image for ex:
> rgb2ind(img,1,'nodither'); so that I have a single uniform
> colored image
> 4. Get the value of the color from the centroid of the
> cropped image.
> 5. Store the details of the 4 colors in the mat file for
> further testing process.
>
> Testing Part:
> 1. I take the image and do the same analysis as discussed
> in Step 1 to 4 of the above discussion.
> 2. Then do the color matching part.
> My logic here as descibed by the example below
>
> Suppose I have got these values for the colors from the
> reference image
>
> black =3D [18 22 25];
> silver =3D [179 185 191];
> red =3D [123 3 10];
> blue =3D [75 96 237];
>
> Now it is pretty obvious that due to the ambient lighting
> condition and other factors, you will not get the same
> color match or perfect match for the object in test
> condition and I get a =A0value which is say
>
> color =3D [80 110 217];
> My question is "How do we determine and tell that it is
> blue"
> or if I get
> color =3D [194 208 211], "How do I determing that it is
> Silver".
>
> I hope I am able to explain or let you all visualize the
> problem.
>
> My logic tells me that I should do the following
> 1. testimgval =3D color(1) + color(2) + color(3) =3D (80 + 110
> +217) =3D 407
> 2. Do the summation of all the stored colors by the same
> way and do subtraction.
> ex:
> Blackval =3D black(1) + black(2) + black(3) =3D 65;
> Similarly other color will be;
> Redval =3D 126;
> Silverval =3D 555;
> Blueval =3D 408
> 3. Subtract testimageval from each of the colorval and the
> minimum value which corresponds to that color is the color
> detected.
> i.e
> =A0abs(407 - 65) =3D 342;
> abs(407-126) =3D 281;
> abs(407 -555) =3D 148
> abs(407 - 408) =3D 1 =3D ----> least from all above so the
> color must be Blue.
>
> But I some how dont get the same satisfactory results by
> my above calculation. i.e sometimes I get blue when the
> object is actually silver, I get red if the object is
> black and so on and so forth.
> Am I missing something very imp in designing this machine
> vision system?
> =A0I know its not directly related to Matlab in any way, but
> just looking for some imp comments from those, who feel
> probably there is something which is still required there.
> Thanks
> Vihang

Vihang:
Here's an eye opening experience for you:
Download ImageJ and install it - it's freeware from the NIH.
http://rsb.info.nih.gov/ij/
Then go here
http://rsb.info.nih.gov/ij/plugins/color-inspector.html
and install the 3D Color Inspector/Color Histogram.
This amazing gamut visualization program lets you visualize the color
gamut in several different color spaces. You read in your color image
and it plots the gamut scatterplot in 3D and lets you interact with it
in several ways, such as reorienting the axes. It's really amazing
how much you can learn when you see what colors you actually have in
your image displayed graphically in a 3D scatterplot. Plus it lets
you pick several color classifiers such as Median Cut, and Wu's color
quantization. You can even specify the number of colors you wish to
classify your gamut into.

You can still do the math in MATLAB, but once you've visualized the
gamut of your image(s), I know you'll be glad you did. It really
helps you to figure out how you need to carve up your gamut to do your
color classification.

Seriously, do this (it's free, painless, and easy), and then let me
know how you like it. You'll be glad you did. It's really cool!
Best wishes,
ImageAnalyst

Subject: machine vision-Color Matching

From: Vihang Patil

Date: 28 Feb, 2008 10:40:12

Message: 10 of 22

Thanks John and ImageAnalyst, will definately work on your
suggestions.
Its quite true what John said, about human perception of
color. I too had a similar experience once, when me and my
brother were lazing on the bed and I told him the celing
is looking pale yellow. While he was pretty sure that it
was pure white. We had a good long debate, where finally I
won "Since I am the elder one". That normally happens, I
guess the elders bullies the younger and make them accept
that they were wrong.
But Jokes apart I think I will need to do extensive study
on color recognition.
Thanks and Regards
Vihang

Subject: machine vision-Color Matching

From: John D'Errico

Date: 28 Feb, 2008 12:18:01

Message: 11 of 22

"Vihang Patil" <vihang_patil@yahoo.com> wrote in message
<fq632c$i7s$1@fred.mathworks.com>...
> Thanks John and ImageAnalyst, will definately work on your
> suggestions.
> Its quite true what John said, about human perception of
> color. I too had a similar experience once, when me and my
> brother were lazing on the bed and I told him the celing
> is looking pale yellow. While he was pretty sure that it
> was pure white. We had a good long debate, where finally I
> won "Since I am the elder one". That normally happens, I
> guess the elders bullies the younger and make them accept
> that they were wrong.
> But Jokes apart I think I will need to do extensive study
> on color recognition.
> Thanks and Regards
> Vihang

About 20 years ago I did some studies on color
blindness. This brought me in contact with a
color blind opthamologist, as well as a few other
people who were color blind.

The doctor had an interesting story to tell - he
never knew he was color blind until med school,
where he had a class where they showed the
Ishihara plates and he saw the wrong things!
The point is that many people who have this
characteristic don't actually know they have it,
or it takes them years to realize. A person might
also have various degrees of color anomaly.

http://mysite.du.edu/~jcalvert/optics/colvisn.htm

Finally, I was also reading recently that some
women even have 4 distinct types of cones in
their eyes. They see color in 4 dimensions. Do
a Google search for the word "quadchromatic"
or "tetrachromatic women".

John

Subject: machine vision-Color Matching

From: ImageAnalyst

Date: 29 Feb, 2008 04:30:56

Message: 12 of 22

On Feb 28, 7:18=A0am, "John D'Errico" <woodch...@rochester.rr.com>
wrote:
> "Vihang Patil" <vihang_pa...@yahoo.com> wrote in message
>
> <fq632c$i7...@fred.mathworks.com>...
>
> > Thanks John and ImageAnalyst, will definately work on your
> > suggestions.
> > Its quite true what John said, about human perception of
> > color. I too had a similar experience once, when me and my
> > brother were lazing on the bed and I told him the celing
> > is looking pale yellow. While he was pretty sure that it
> > was pure white. We had a good long debate, where finally I
> > won "Since I am the elder one". That normally happens, I
> > guess the elders bullies the younger and make them accept
> > that they were wrong.
> > But Jokes apart I think I will need to do extensive study
> > on color recognition.
> > Thanks and Regards
> > Vihang
>
> About 20 years ago I did some studies on color
> blindness. This brought me in contact with a
> color blind opthamologist, as well as a few other
> people who were color blind.
>
> The doctor had an interesting story to tell - he
> never knew he was color blind until med school,
> where he had a class where they showed the
> Ishihara plates and he saw the wrong things!
> The point is that many people who have this
> characteristic don't actually know they have it,
> or it takes them years to realize. A person might
> also have various degrees of color anomaly.
>
> http://mysite.du.edu/~jcalvert/optics/colvisn.htm
>
> Finally, I was also reading recently that some
> women even have 4 distinct types of cones in
> their eyes. They see color in 4 dimensions. Do
> a Google search for the word "quadchromatic"
> or "tetrachromatic women".
>
> John

Most birds and fish also have 4 cones so their color vision is more
accurate than humans. Makes sense when you think about it because
birds and fish are among the most brilliantly colored animals. Dogs
have two types of cones so can still see color (http://ask.yahoo.com/
20020902.html) contrary to what many people think. I've never heard
of people with 4 types of cones but I guess it could happen. Some guy
once wrote a book about an island in the Pacific where a good portion
of the people only had 1 type of cone and so they saw in monochrome.

Subject: machine vision-Color Matching

From: fburton@nyx.net (Francis Burton)

Date: 1 Mar, 2008 17:44:00

Message: 13 of 22

In article <e7d1eb41-4679-4640-a3b7-c341c2cdd5d5@e23g2000prf.googlegroups.com>,
ImageAnalyst <imageanalyst@mailinator.com> wrote:
>Most birds and fish also have 4 cones so their color vision is more
>accurate than humans. Makes sense when you think about it because
>birds and fish are among the most brilliantly colored animals. Dogs
>have two types of cones so can still see color (http://ask.yahoo.com/

Ah, that explains why dogs' coats are so drab. ;-)

>20020902.html) contrary to what many people think.

Some horsey people used to think that equines are totally colour
blind. In fact, they are also dichromats (two cone types) along
with a lot of other mammals.

> I've never heard
>of people with 4 types of cones but I guess it could happen. Some guy
>once wrote a book about an island in the Pacific where a good portion
>of the people only had 1 type of cone and so they saw in monochrome.

That would be Oliver Sacks:
http://www.oliversacks.com/island.htm

Francis

Subject: machine vision-Color Matching

From: ImageAnalyst

Date: 2 Mar, 2008 18:53:58

Message: 14 of 22

On Feb 27, 12:56=A0pm, "John D'Errico" <woodch...@rochester.rr.com>
wrote:
> "Vihang Patil" <vihang_pa...@yahoo.com> wrote in message
>
> <fq4372$he...@fred.mathworks.com>...
>
>
>
>
>
> > "John D'Errico" <woodch...@rochester.rr.com> wrote in
> > message <fpjlk1$3h...@fred.mathworks.com>...
>
> > > Try changing the blue pixel a bit.
>
> > > [iscolor,cn] =3D fuzzycolor([60 100 220]/255,'all');cn{find
> > (iscolor)}
> > > ans =3D
> > > blue
>
> > > Still blue, no problems. Find fuzzycolor on
> > > the file exchange.
>
> >http://www.mathworks.com/matlabcentral/fileexchange/loadFil
> > e.do?
> > > objectId=3D12326&objectType=3DFILE
>
> > > HTH,
> > > John
>
> > Hello John
> > I tried your fuzzycolor, its good, but I think it requires
> > a lot of tweaking too
> > for example
> > [iscolor,cn] =3D fuzzycolor([88 110 255]/255,'all');cn{find
> > (iscolor)}
>
> > I get no color whereas it is very much blue to me, which
> > you can see from the code below.
>
> > new =3D im2uint8(ones([128 128 3]));
> > new(:,:,1) =3D 88;
> > new(:,:,2) =3D 110;
> > new(:,:,3) =3D 255;
> > figure,imshow(new);
>
> > I think I will need to add this into the fuzzycolor's
> > database. I am still working on it. Probably you can
> > through more insight on it.
>
> > Vihang
>
> Yes, I may have missed some blues when I built
> the database. As I recall, I did try to provide an
> ability to add to or change the database.
>
> A problem is that what I considered to be a blue,
> on MY monitor, may not always coincide with
> others opinion of a blue. There are several issues
> of metamerism here to deal with. If your monitor
> is set up with a higher or lower color temperature,
> then blues might change. Or suppose one of us
> is moderately color blind, perhaps protoanomalous
> (red-green) or even tritananomalous (yellow-blue).
> Even a minor amount of such an effect can influence
> how you might see colors differently from me. Since
> different people can have subtly different pigments
> in their cones, they can see colors differently even
> if not color blind at all.
>
> These issues are why I called it fuzzy color. The
> boundaries of a color name region will be both
> irregular and fuzzy. In fact, some color name
> regions may even overlap, i.e., colors near the
> boundary of two color names like yellow/green,
> might be arguably both yellow and green.
>
> For your work, a simple solution is to build/modify
> the database for your own eyes & monitor. Ask if
> you have questions. I'd have to revisit the code,
> but it was not hard to do using the buildfuzzyluts
> function that I provided. The idea is it pops up
> a series of color planes, then you encircle those
> colors which satisfy your colorname with a
> polygon in each plane.
>
> John- Hide quoted text -
>
> - Show quoted text -

-----------------
For fun, have a look at these illusions:
http://www.psy.ritsumei.ac.jp/~akitaoka/color-e.html
particularly the one called "Green and blue spirals" It shows you
just how deceptive perceived colors can be.

Check out all the other links at his site too.
http://www.ritsumei.ac.jp/~akitaoka/index-e.html
Most of them are quite fun and colorful.
Regards,
ImageAnalyst

Subject: machine vision-Color Matching

From: Vihang Patil

Date: 3 Mar, 2008 09:45:03

Message: 15 of 22

ImageAnalyst <imageanalyst@mailinator.com> wrote in
> For fun, have a look at these illusions:
> http://www.psy.ritsumei.ac.jp/~akitaoka/color-e.html
> particularly the one called "Green and blue spirals" It
shows you
> just how deceptive perceived colors can be.
>
> Check out all the other links at his site too.
> http://www.ritsumei.ac.jp/~akitaoka/index-e.html
> Most of them are quite fun and colorful.
> Regards,
> ImageAnalyst

I intially did not believe my eyes when I looked at
the "Green and the Blue Spirals". But then I loaded the
image in Matlab and used impixelinfo over the image just
to check whether they are really the same, and I am so
amazed that I have stopped believing on this fact "Seeing
is Believing". I can keep looking at the image the whole
day but still, I am not able to tell that they are the
same color. Simply marvellous.

Meanwhile, I will be posting some of my work on Color
Matching shortly on FEX, so till then please keep watching
and/or updating this post with useful comments.
Vihang

Subject: machine vision-Color Matching

From: Ethan

Date: 3 Mar, 2008 15:31:08

Message: 16 of 22

You are trying to use one number to represent color when you need more.
You should read a little bit about color to understand the problem, but
basically your colors are going to vary in 3 dimensions, so you should check
color in 3 dimensions. If you have an issue with color tolerance, ie not all
blues are the same blue - they have some variation that is tolerable, then you
may need to go deeper into understanding color. Otherwise you can try
looking at the distance in 3D of a measured color from the standard color
(say in rgb) rather than the sum of the color coordinates. You can also
simplify things a little by using reducing the color to 2 dimensions by
normalizing (into an analog of chromaticity). That is, use r=R/(R+G+B),
g=G/(R+G+B) where R, G, and B are the digital values and r and g are
"chromaticities". Then you may be able to use 2D distances instead of 3D. But
if real color is important, you may need to use a real color space that is
associated with human color vision.

"Vihang Patil" <vihang_patil@yahoo.com> wrote in message
<fpgn52$9ij$1@fred.mathworks.com>...
> Hello All
> I am in the process of developing machine vision system i
> Matlab, primarily to detect color change, "basic colors
> only and not shades".
> This is what I have achieved so far, please let me know
> after going through the details below if there is
> something which probably missing the way I am developing
> it.
>
> Preliminary Details:
> 1. The object to be detected for color change comes in the
> following 4 colors;Metallic BLOOD RED, Metallic BlACK,
> Metallic SILVER, Metallic BLUE.
> 2. They are coming on the conveyor at a speed about 1.25
> to 1.66 objects/min, ie roughly 600 - 800 in an 8 hour
> shift.
> 3. Ligting condition is flouroscent tube
>
> My steps for Reference Image:
> 1. I have placed a trigger on the conveyor such that,
> whenever the object crosses it, the camera will take an
> image
> 2. I crop the Region of Interest and Store the image
> details of the part of my interest.
> 3. Convert the cropped image into indexed image for ex:
> rgb2ind(img,1,'nodither'); so that I have a single uniform
> colored image
> 4. Get the value of the color from the centroid of the
> cropped image.
> 5. Store the details of the 4 colors in the mat file for
> further testing process.
>
> Testing Part:
> 1. I take the image and do the same analysis as discussed
> in Step 1 to 4 of the above discussion.
> 2. Then do the color matching part.
> My logic here as descibed by the example below
>
> Suppose I have got these values for the colors from the
> reference image
>
> black = [18 22 25];
> silver = [179 185 191];
> red = [123 3 10];
> blue = [75 96 237];
>
> Now it is pretty obvious that due to the ambient lighting
> condition and other factors, you will not get the same
> color match or perfect match for the object in test
> condition and I get a value which is say
>
> color = [80 110 217];
> My question is "How do we determine and tell that it is
> blue"
> or if I get
> color = [194 208 211], "How do I determing that it is
> Silver".
>
> I hope I am able to explain or let you all visualize the
> problem.
>
> My logic tells me that I should do the following
> 1. testimgval = color(1) + color(2) + color(3) = (80 + 110
> +217) = 407
> 2. Do the summation of all the stored colors by the same
> way and do subtraction.
> ex:
> Blackval = black(1) + black(2) + black(3) = 65;
> Similarly other color will be;
> Redval = 126;
> Silverval = 555;
> Blueval = 408
> 3. Subtract testimageval from each of the colorval and the
> minimum value which corresponds to that color is the color
> detected.
> i.e
> abs(407 - 65) = 342;
> abs(407-126) = 281;
> abs(407 -555) = 148
> abs(407 - 408) = 1 = ----> least from all above so the
> color must be Blue.
>
> But I some how dont get the same satisfactory results by
> my above calculation. i.e sometimes I get blue when the
> object is actually silver, I get red if the object is
> black and so on and so forth.
> Am I missing something very imp in designing this machine
> vision system?
> I know its not directly related to Matlab in any way, but
> just looking for some imp comments from those, who feel
> probably there is something which is still required there.
> Thanks
> Vihang
>

Subject: machine vision-Color Matching

From: Vihang Patil

Date: 4 Mar, 2008 04:58:02

Message: 17 of 22

"Vihang Patil" <vihang_patil@yahoo.com> wrote in message
<fqghav$jic$1@fred.mathworks.com>...

 
> Meanwhile, I will be posting some of my work on Color
> Matching shortly on FEX, so till then please keep
watching
> and/or updating this post with useful comments.
> Vihang


Please see my humble contribution, for color matching
application on

http://www.mathworks.com/matlabcentral/fileexchange/loadFil
e.do?objectId=19020&objectType=FILE

or

http://tinyurl.com/2b2mld

Best Regards
Vihang

Subject: machine vision-Color Matching

From: Vihang Patil

Date: 4 Mar, 2008 05:04:48

Message: 18 of 22

"Ethan " <emontag.nospam@leuzeusa.com> wrote in message
<fqh5js$if5$1@fred.mathworks.com>...
> You are trying to use one number to represent color when
you need more.
> You should read a little bit about color to understand
the problem, but
> basically your colors are going to vary in 3 dimensions,
so you should check
> color in 3 dimensions. If you have an issue with color
tolerance, ie not all
> blues are the same blue - they have some variation that
is tolerable, then you
> may need to go deeper into understanding color.
Otherwise you can try
> looking at the distance in 3D of a measured color from
the standard color
> (say in rgb) rather than the sum of the color
coordinates. You can also
> simplify things a little by using reducing the color to
2 dimensions by
> normalizing (into an analog of chromaticity). That is,
use r=R/(R+G+B),
> g=G/(R+G+B) where R, G, and B are the digital values and
r and g are
> "chromaticities". Then you may be able to use 2D
distances instead of 3D. But
> if real color is important, you may need to use a real
color space that is
> associated with human color vision.
>
>
Hello Ethan
Could you please point out to some website/reference book
that would give insights on this 3D color space
representation and analysis. That would really be helpful
Vihang

Subject: machine vision-Color Matching

From: Vihang Patil

Date: 4 Mar, 2008 05:04:48

Message: 19 of 22

"Ethan " <emontag.nospam@leuzeusa.com> wrote in message
<fqh5js$if5$1@fred.mathworks.com>...
> You are trying to use one number to represent color when
you need more.
> You should read a little bit about color to understand
the problem, but
> basically your colors are going to vary in 3 dimensions,
so you should check
> color in 3 dimensions. If you have an issue with color
tolerance, ie not all
> blues are the same blue - they have some variation that
is tolerable, then you
> may need to go deeper into understanding color.
Otherwise you can try
> looking at the distance in 3D of a measured color from
the standard color
> (say in rgb) rather than the sum of the color
coordinates. You can also
> simplify things a little by using reducing the color to
2 dimensions by
> normalizing (into an analog of chromaticity). That is,
use r=R/(R+G+B),
> g=G/(R+G+B) where R, G, and B are the digital values and
r and g are
> "chromaticities". Then you may be able to use 2D
distances instead of 3D. But
> if real color is important, you may need to use a real
color space that is
> associated with human color vision.
>
>
Hello Ethan
Could you please point out to some website/reference book
that would give insights on this 3D color space
representation and analysis. That would really be helpful
Vihang

Subject: machine vision-Color Matching

From: Vihang Patil

Date: 4 Mar, 2008 05:04:57

Message: 20 of 22

"Ethan " <emontag.nospam@leuzeusa.com> wrote in message
<fqh5js$if5$1@fred.mathworks.com>...
> You are trying to use one number to represent color when
you need more.
> You should read a little bit about color to understand
the problem, but
> basically your colors are going to vary in 3 dimensions,
so you should check
> color in 3 dimensions. If you have an issue with color
tolerance, ie not all
> blues are the same blue - they have some variation that
is tolerable, then you
> may need to go deeper into understanding color.
Otherwise you can try
> looking at the distance in 3D of a measured color from
the standard color
> (say in rgb) rather than the sum of the color
coordinates. You can also
> simplify things a little by using reducing the color to
2 dimensions by
> normalizing (into an analog of chromaticity). That is,
use r=R/(R+G+B),
> g=G/(R+G+B) where R, G, and B are the digital values and
r and g are
> "chromaticities". Then you may be able to use 2D
distances instead of 3D. But
> if real color is important, you may need to use a real
color space that is
> associated with human color vision.
>
>
Hello Ethan
Could you please point out to some website/reference book
that would give insights on this 3D color space
representation and analysis. That would really be helpful
Vihang

Subject: machine vision-Color Matching

From: Vihang Patil

Date: 4 Mar, 2008 05:07:01

Message: 21 of 22

"Ethan " <emontag.nospam@leuzeusa.com> wrote in message
<fqh5js$if5$1@fred.mathworks.com>...
> You are trying to use one number to represent color when
you need more.
> You should read a little bit about color to understand
the problem, but
> basically your colors are going to vary in 3 dimensions,
so you should check
> color in 3 dimensions. If you have an issue with color
tolerance, ie not all
> blues are the same blue - they have some variation that
is tolerable, then you
> may need to go deeper into understanding color.
Otherwise you can try
> looking at the distance in 3D of a measured color from
the standard color
> (say in rgb) rather than the sum of the color
coordinates. You can also
> simplify things a little by using reducing the color to
2 dimensions by
> normalizing (into an analog of chromaticity). That is,
use r=R/(R+G+B),
> g=G/(R+G+B) where R, G, and B are the digital values and
r and g are
> "chromaticities". Then you may be able to use 2D
distances instead of 3D. But
> if real color is important, you may need to use a real
color space that is
> associated with human color vision.
>

Hello Ethan
Could you please point out to some website/reference book
that would give insights on this 3D color space
representation and analysis. That would really be helpful
Vihang

Subject: machine vision-Color Matching

From: Vihang Patil

Date: 5 Mar, 2008 05:15:20

Message: 22 of 22

Sorry for the multiple posts above.
Vihang

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us