How can I use histogram equalization to enhance the quality of a color image(flower.jpg)? Draw a flowchart & write a matlab program for this.

2 views (last 30 days)
How can I use histogram equalization to enhance the quality of a color image(flower.jpg) Picture attached? Draw a flowchart & write a matlab program for this.

Answers (1)

DGM
DGM on 31 Mar 2023
Define "enhance the quality". There's no reason to expect that leveling the histogram will generally improve the visual appearance of images. It usually does the opposite.
So let's see what happens.
inpict = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/78113/flower.jpg');
% just adjust contrast in RGB
inlevel = stretchlim(inpict);
inlevel = [min(inlevel(1,:)) max(inlevel(2,:))]; % or pick whatever levels
op1 = imadjust(inpict,inlevel);
% naive histogram equalization in RGB
op2 = inpict;
for c = 1:size(inpict,3)
op2(:,:,c) = histeq(op2(:,:,c));
end
% adaptive histogram equalization in RGB
op3 = inpict;
for c = 1:size(inpict,3)
% 0.005 clip limit is less aggressive than default
op3(:,:,c) = adapthisteq(op3(:,:,c),'cliplimit',0.005);
end
% naive histogram equalization in LAB
op4 = rgb2lab(inpict);
op4(:,:,1) = histeq(op4(:,:,1)/100)*100;
op4 = im2uint8(lab2rgb(op4));
% adaptive histogram equalization in LAB
op5 = rgb2lab(inpict);
op5(:,:,1) = adapthisteq(op5(:,:,1)/100,'cliplimit',0.005)*100;
op5 = im2uint8(lab2rgb(op5));
imshow([inpict op1; op2 op3; op4 op5])
Histogram equalization is a great way to make your images look blown-out and sickly. There may be technical purposes for leveling an image's histogram, but I don't think the results are what anyone would find visually appealing. Instead of using borderline useless words like "enhance", use words that describe specifically what you expect it to do.
As for the flowchart, this should get you started.

Community Treasure Hunt

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

Start Hunting!