Code change in histogram equalization
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hi,
Could anybody help me out. I was doing a histogram equalization code. I am getting both the graphs as same output graphs. Could you help me out in getting the right code. Could you let me know what is wrong in it or let me know if you could provide me a histogram equalization code which works.
clc;
close all;
clear all;
img=imread('C:\Users\Desktop\dipproj2\lena.bmp');
[p,q]=size(img)
k=1:0:256;
x= ones(1,256);
for k=1:0:256
for i=1:size(p,1)
for j=1:size(q,1)
k=value(256,i)
% if (img(i,j)==k)
% x(k+1)=x(k+1)+1;
x(k+1)=x(k+1)+1;
end
end
end
d=zeros(1,256);
d=x*(1/(p*q));
s=sum(k+1)
s(1)=d(1,1);
for i=2:256
s(i)=s(i-1)+d(1,i);
end
y=ones(1,256);
u=y*256
%sk=255*s;
z=floor(u);
final=img;
for k=0:256
for i=1:size(256,1)
for j=1:size(256,1)
if(img(i,j)==k)
final(i,j)=z(1,k+1)+1;
end
end
end
end
figure(1),
subplot(2,1,1),
title('histogram'),
imagesc(final),
colormap(gray);
subplot(2,1,2),
imhist(final);
figure(2),
subplot(2,1,1),
title('histogram1'),
imagesc(img),
colormap(gray);
subplot(2,1,2),
imhist(img);
Thanks and Regards,
Sandeep
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!