MATLAB Answers


How can I do the histogram equalization?

Asked by Tomas
on 10 Nov 2012


I think that the histogram equalization on the 3 components of a color image has the effect of increasing the contrast in order to facilitate the detection of the region of interest that is darker than the other part of the image. How can I do this using matlab? thanks




No products are associated with this question.

2 Answers

Answer by Aneesh Balaji
on 14 Nov 2012

Hey For a color image split into 3 components and perform histeq on each of them and then recombine them.

  1 Comment

on 14 Nov 2012

I used these lines but i got this result

r1 = histeq(r);
v1 = histeq(v);
b1 = histeq(b);
img = cat(3,r1,v1,b1);

Answer by Image Analyst
on 14 Nov 2012

Using histeq() on individual color channels is not a good method. You will introduce color artifacts which may be severe. You're best off converting to hsv color space, then using histeq() or adapthisteq() on only the v channel, then recombine and transform back to rgb color space.


Looks like it should be right. Maybe it's some kind of uint8/double conflict. Can you post your image somewhere?

on 16 Nov 2012

I'm working on a large number of images. I just need to equalize the histogram to facilitate detection of the dark object. this is an example

Histogram equalization is not necessary for that purpose. In fact, it's rarely necessary for anything. And it looks like you'd do best with a texture filter, like entropyfilt() or stdfilt(), at least for the one image you posted.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
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

MATLAB Academy

New to MATLAB?

Learn MATLAB today!