File Exchange

image thumbnail

Color segmentation by Delta E color difference

version (356 KB) by Image Analyst


Updated 19 Apr 2011

View License

Demo to perform very, very simple color detection in LAB color space. The RGB image is converted to LAB color space and then the user draws some freehand-drawn irregularly shaped region to identify a color. The Delta E (the color difference in LAB color space) is then calculated for every pixel in the image between that pixel's color and the average LAB color of the drawn region. The user can then specify a number that says how close to that color would they like to be. The software will then find all pixels within that specified Delta E of the color of the drawn region.

Cite As

Image Analyst (2020). Color segmentation by Delta E color difference (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (31)

Diah, there is no 'getWorkArea' in my code. If you have some problem with how you modified the code for your own image, then post your question and modified m-file to the Answers forum.

Lina, I just didn't want to clutter up the code and make it more complicated for handling all kinds of situations. I figure the user can make the obvious modifications in the case the image is uint16.

rahul ahire

Lina Eckel

I have a question, hope you can help me. You check in your code if it is an uint8 image and later, if it was true, for indexed images you convert it back to uint8. Why are you not doing this for uint16 too?

i got an error in 'getWorkArea' while executing 'my own image'....somebody help me please :(

What are the labels of the y and x axis? what does the numbers stand for?

The rest of it is very clear and good, thank you!

Chloe Hind

Thank you for the code. Is there a version in which I could segment colour from a video please?

anggi nego



Thank you very much...after 3 days, I manage to solve my problem after looking at this code..although I need to point out row by row, it is helped me a lot. Thank you.

admire your work.
I just wanted to know where can I study in detail this method? Specially the automatic calculating of tolerance method?
Any help in this case would be highly appreciated

Manu BN

Fari Nami


Very good and simple software! But how can I extract the segmented data?


great work bro... Thanks for sharing this code.. Is it possible to do in the HSV colorspace?


I am a research student. I would like to use your methodology (Color segmentation by Delta E color difference) for shade matching.
I just want to find where the reference shades (from a standard color chart)are located in the chosen image? Is it possible?
Plz help me



uvan siya

Image Analyst >> Please send me the base paper for this "Color segmentation by Delta E color difference" . my mail is

ajit, if there is a brightness change, there is a color change. If you want to detect a hue, regardless of it's brightness, then you can use my HSV color segmentation demo and just threshold on the hue value. However skin is a boomerang-shaped gamut and can't be gotten by any simple carving up of the gamut in any 3D color space, no matter which one you pick. You'd need to carve out the boomerang shape, not just a hue sector or a delta-E ball shape.

ajit sarode

works very accurate if said to choose any color however if there is brightness change for same color in rest of the picture than selected, then it does not detect(skin color with different brightness),can u please help?

Well commented/explained.

Works quite well. Well commented.
Can you add the reference to the paper or the math/theory behind this work?

Well commented/explained.

Marium: I don't recall getting anything from you.


Have messaged you the error

arman: How did you run it? What was the exact error message? I just downloaded it and ran it, and it was fine. Click my name above and then click the "Contact Author" link to send me this information.

It doesn't work. Whenever I draw a region it gives error of too many output arguments!!

You can use it for indexed images if you convert the indexed image into an RGB image with ind2rgb().


can i use it for index image???

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: Convert between RGB and Color Names