-
Notifications
You must be signed in to change notification settings - Fork 1
/
denoiseMDBUTMF.m
72 lines (61 loc) · 1.94 KB
/
denoiseMDBUTMF.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function [ output_image ] = denoiseMDBUTMF( input_image )
% MDBUTMF
% denoising algorithm
% implementation: Ashutosh Singla
%
% input_image: grayscale image
%
% ouput_image: grayscale image
% denoised image
[row col]=size(input_image);
for i=2:row-1
for j=2:col-1
array=zeros(1,9);
m=1;
sum=0;
for k=i-1:i+1
for l=j-1:j+1
array(1,m)=input_image(k,l);
sum=sum+array(1,m);
m=m+1;
end
end
avg=round(sum/9);
if((array(1,5)==255)||(array(1,5)==0))
count=0;
for z=1:9
if((array(1,z)==255)||(array(1,z)==0))
count=count+1;
end
end
index=9-count;
temp=zeros(1,index);
x=0;
if(count==9)
input_image(i,j)=avg;
else
for z=1:9
if((array(1,z)==255)||(array(1,z)==0))
array(1,z)=array(1,z);
else
x=x+1;
temp(1,x)=array(1,z);
end
end
temp=sort(temp);
med=round(index/2);
qw=mod(med,2);
if(qw==0)
value=temp(1,med);
value1=temp(1,med+1);
input_image(i,j)=round((value+value1)/2);
else
value=temp(1,med);
input_image(i,j)=value;
end
end
end
end
end
output_image = input_image;
end