Skip to content

Commit 1a97055

Browse files
add Histogram Equalization files
1 parent f8da110 commit 1a97055

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Histogram Equalization/hw2_histeq.m

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
%mohadeseh ghafoori 9632133
2+
function [im_eq]=hw2_histeq(im)
3+
[m,n]=size(im);
4+
img=uint8(im);
5+
h=zeros(1,256);
6+
for i=1:m
7+
for j=1:n
8+
h(1,img(i,j)+1)=h(1,img(i,j)+1)+1;
9+
end
10+
end
11+
h_prob=h/(m*n); %matrix probability of image for each lighting level
12+
for j=1:256
13+
if (j==1) im_cdf(1,1)=h_prob(1,1);
14+
else im_cdf(1,j)=im_cdf(1,j-1)+h_prob(1,j);
15+
end
16+
end
17+
eq=255*im_cdf;
18+
for i=1:m
19+
for j=1:n
20+
im_eq(i,j)=eq(1,img(i,j)+1);
21+
end
22+
end
23+
im_eq=uint8(im_eq);
24+
imshow(im_eq)
25+
title('new equlized image');
26+
end

0 commit comments

Comments
 (0)