How to implement this plateau limit histogram equalization algorithm
9 views (last 30 days)
Show older comments
Hi,
i would like to implement and simple alghoritm. i compare my result's histogram with original result's histogram and there is always a huge difference.
![Adsız.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/257128/Ads%C4%B1z.png)
i reviewed my code again and again. but i couldn't see what is the problem. can you take a look to my code, please?
![step1.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/257129/step1.png)
histogram_of_image = imhist(input_image);
modified_histogram = zeros(1,256);
modified_histogram(1:256) = (log(histogram_of_image(1:256)+(a))).^(beta);
![step2.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/257130/step2.png)
these_elements_are_not_zero = modified_histogram~= 0;
sum2 = sum(modified_histogram(these_elements_are_not_zero));
cnt2 = size(these_elements_are_not_zero,2);
tcl = sum2/cnt2;
clipped_histogram = zeros(1,256);
for i=1:256
if((modified_histogram(i)) >= tcl)
clipped_histogram(i) = tcl;
else
clipped_histogram(i) = (modified_histogram(i));
end
end
![step3.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/257131/step3.png)
PDa = zeros(1,256);
PDa = clipped_histogram / (sum(clipped_histogram));
CDa = zeros(1,256); %create CDa in formula
CDa(1) = PDa(1) ;
for i=2:256
CDa(i) = PDa(i) + CDa(i-1);
end
value_after_enhancement = zeros(1,256);
value_after_enhancement = (255 * CDa);
b=uint8(0);
output_image=zeros(width,height);
output_image = value_after_enhancement(input_image+1);
figure;imshow(uint8(output_image));
original_result=imread('testsonuc.bmp');
original_result=double(rgb2gray(original_result));
image_of_dif= zeros(width,height);
figure;imshow(uint8(original_result));
2 Comments
Answers (0)
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!