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

Color matching and comparison

Asked by N.B. on 1 May 2013

Hey gang,

I am hoping that I can be placed onto the right thought process track. My end-goal is as follows:

  • Load an image into MatLab.
  • Find an average color value of the loaded image and save that value.
  • Compare that color value to a group of other color values, and find which color value matches the one from the image.

So basically, I am wondering if it is possible to find an average color value from an uploaded image? The images that I hope to upload are primarily of the same color (brown), but there will be different shades of brown in that image. I want to compare that image to a group of other images and find which one matches the loaded image best.

Thanks for your help!

0 Comments

N.B.

1 Answer

Answer by Image Analyst on 1 May 2013
Accepted answer

You can definitely do this. Check out my Delta E application in my File Exchange. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 The only difference is that after you draw a color in one image you want to apply it to other images instead of the same image.

You might also enjoy this web site: http://labs.tineye.com/multicolr/ Or this one: http://colorthesaurus.epfl.ch/

3 Comments

N.B. on 1 May 2013

Image Analyst, this is fantastic.

So, as I understand it, I would save that value of Delta E in the original image, and then check it with the Delta E in the other images that I want to compare it to?

Image Analyst on 1 May 2013

Glad you liked it. And those web sites were pretty cool too, huh?

But you don't exactly save the delta E in the original image. You would save the mean LAB value of the desired are of your input image - the area could be the whole image if you want. You would save that lab probably in a mat file if you wanted to save it. Then you'd read in an image and calculate the delta E for each pixel in that image. You don't need to save the delta E anywhere but in a variable in your comparison program. You could save it into a mat file also if you wanted, but you wouldn't save it in the original image file. So then you have a delta E image for this test image - basically row 2 column 3 of my demo above. Then you can threshold it to take deltaE less than some certain amount, like say 20, to find pixels close in color to your reference lab value that you want to match. That would give you a binary image (a mask) like in the lower left above. Then you can multiply the mask (or its inverse) to get the two images in the lower right.

Jurgen on 1 May 2013

You can do the same for RGB (or any other colorspace) instead of LAB.

Some choose CIEXYZ over LAB because XYZ primaries have a better correlation with light mixing. I.e. the xy chromacity better depicts how much of certain types of light should be mixed to get a color, whereas a*b* converts this to human 'perceptual amounts'.

Image Analyst

Contact us