Shade/color matching of the input image with reference shade chart
Show older comments
Dear Friends,
I have to segment different shades of colour from an image. There is name for each reference color. I have utlisied many suggested methods here like colorlab/edge detection etc. But they did not work as my color of interest is all white based and closer (in colour) to each other.
I am looking for a method to match the image with reference shade as in the figure below.
Please someone help me
Thanks in advance.

Answers (1)
Image Analyst
on 5 Jan 2014
2 votes
You need to calculate the color difference. See lengthy discussions I had with this poster who wanted to match grass to standard colored tiles. http://www.mathworks.com/matlabcentral/answers/contributors/3595115-elvin/questions
13 Comments
Image Analyst
on 5 Jan 2014
Yes it is. If you have simple RGB graphics, you can probably just calculate the Euclidean distance in RGB color space and whichever standard is closest, you assign it to that. Are your standard colors in an image? Do you have the RGB values for them? If not, and you have an image, you can measure them from the image. Then for each standard color, calculate the Euclidean rgb distance:
deltaR = rgbImage(:,:,1) - standardR;
deltaG = rgbImage(:,:,2) - standardG;
deltaB = rgbImage(:,:,3) - standardB;
colorDiffImage = sqrt(deltaR .^ 2 + deltaG .^ 2 + deltaB .^ 2);
Do that for every standard then find out which one each pixel is closest to. Let me see your code for that because there are efficient (min function) and inefficient (for loop) ways of doing that.
Did you see my File Exchange with color segmentation demos: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
Kumar
on 6 Jan 2014
Image Analyst
on 6 Jan 2014
Yes, if you put all the L into one array, all the b into another and all the b into another.
standardLs = [A1(1), B4(1), C4(1), D4(1)];
standardAs = [A1(2), B4(2), C4(2), D4(2)];
standardBs = [A1(3), B4(3), C4(3), D4(3)];
deltaLs = standardLs - testL;
deltaAs = standardAs - testA;
deltaBs = standardBs - testB;
deltaEs = sqrt(deltaLs .^ 2 + deltaAs .^ 2 + deltaBs .^ 2);
[closestDeltaE, index] = min(deltaEs);
Image Analyst
on 6 Jan 2014
Assign fontSize somewhere in the beginning
fontSize = 13; % or whatever...
Kumar
on 6 Jan 2014
Image Analyst
on 6 Jan 2014
Make sure everything is double before you use it.
l = double(labI(:,:,1));
same for a and b.
Image Analyst
on 6 Jan 2014
Edited: Image Analyst
on 6 Jan 2014
Since l is an entire image, you're going to have to subtract one LStandard value at a time:
deltaL = l - LStandard(1); % deltaL is also an image.
repeat for LStandard(2), LStandard(3), and LStandard(4).
Rifayet Ashraf
on 8 Feb 2018
Would you please tell me , how to run this full code? I cannot run because of error. Is there any specific initialization or any default settings? the m.file is here what I am trying to run.
Image Analyst
on 8 Feb 2018
You forgot to attach 'C:\Users\user\Desktop\FYP pic\Single teeth.JPG'
Categories
Find more on Images in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!