File Exchange

image thumbnail

Color segmentation by Delta E color difference

version (356 KB) by Image Analyst
User draws region and this finds pixels in the image with a similar color, using Delta E.


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 (2021). Color segmentation by Delta E color difference (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (33)

ahmadreza hormozi

very good .
thank you

Holmes Queen

Image Analyst

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.

Image Analyst

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?

Diah Junaidi

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

Nathalie Roos

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

Muhammad Umar

amina hadjari



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.

zohaib nawaz

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


Hello, may I ask how can I segment every color object in separate picture, I mean for example on the next picture to segment only red object (red colored off course), on the next blue object and so on. Thank you in advance for the help :)

uvan siya

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

Image Analyst

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.

Karthik MSwamy

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

Anselm Griffin

Well commented/explained.

Image Analyst

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


Marium Malik

Have messaged you the error

Image Analyst

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.

arman Yaraee

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

Image Analyst

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!