Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!k2g2000hse.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: machine vision-Color Matching
Date: Wed, 20 Feb 2008 09:05:41 -0800 (PST)
Organization: http://groups.google.com
Lines: 117
Message-ID: <6a07a3b8-802a-45f8-9737-0c849bf91a97@k2g2000hse.googlegroups.com>
References: <fpgn52$9ij$1@fred.mathworks.com>
NNTP-Posting-Host: 192.44.136.113
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1203527141 19366 127.0.0.1 (20 Feb 2008 17:05:41 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 20 Feb 2008 17:05:41 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: k2g2000hse.googlegroups.com; posting-host=192.44.136.113; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET 
X-HTTP-Via: 1.1 bdci2px (NetCache NetApp/6.0.5P2)
Xref: news.mathworks.com comp.soft-sys.matlab:452688


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/