Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: machine vision-Color Matching
Date: Thu, 21 Feb 2008 11:00:17 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 97
Message-ID: <fpjlk1$3ho$1@fred.mathworks.com>
References: <fpgn52$9ij$1@fred.mathworks.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1203591617 3640 172.30.248.35 (21 Feb 2008 11:00:17 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 21 Feb 2008 11:00:17 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:452847


"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