Skip to content

Commit dc0d841

Browse files
Histogram Equalization
1 parent 14a0d51 commit dc0d841

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Histogram Equalization/histogram.bmp

3 MB
Binary file not shown.

Histogram Equalization/histogram.m

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
clear all
2+
clc
3+
a = imread('pout.tif');
4+
a = double(a);
5+
big = max(max(a));
6+
[row col] = size(a);
7+
C = row*col;
8+
h = zeros(1,300);
9+
z = zeros(1,300);
10+
for n=1:1:row
11+
for m=1:1:col
12+
if a(n,m) == 0
13+
a(n,m) = 1;
14+
end
15+
end
16+
end
17+
for n=1:1:row
18+
for m=1:1:col
19+
t = a(n,m);
20+
h(t) = h(t) + 1;
21+
end
22+
end
23+
pdf = h/C;
24+
cdf(1) = pdf(1);
25+
for x=2:1:big
26+
cdf(x) = pdf(x) + cdf(x-1);
27+
end
28+
new = round(cdf*big);
29+
new = new + 1;
30+
for p=1:1:row
31+
for q=1:1:col
32+
temp = a(p,q);
33+
b(p,q) = new(temp);
34+
t = b(p,q);
35+
z(t) = z(t)+1;
36+
end
37+
end
38+
b = b-1;
39+
subplot(2,2,1)
40+
imshow(uint8(a))
41+
subplot(2,2,2)
42+
bar(h)
43+
subplot(2,2,3)
44+
imshow(uint8(b))
45+
subplot(2,2,4)
46+
bar(z)

0 commit comments

Comments
 (0)