Path: news.mathworks.com!not-for-mail
From: "Michael McKay" <mike.mckay@pixelink.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: machine vision-Color Matching
Date: Wed, 20 Feb 2008 14:28:02 +0000 (UTC)
Organization: PixeLINK
Lines: 36
Message-ID: <fphddi$9b2$1@fred.mathworks.com>
References: <fpgn52$9ij$1@fred.mathworks.com> <fpgqt2$fn0$1@canopus.cc.umanitoba.ca>
Reply-To: "Michael McKay" <mike.mckay@pixelink.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1203517682 9570 172.30.248.37 (20 Feb 2008 14:28:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 20 Feb 2008 14:28:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1286771
Xref: news.mathworks.com comp.soft-sys.matlab:452647



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.