-
Notifications
You must be signed in to change notification settings - Fork 1
/
Matlab-Code
17 lines (17 loc) · 966 Bytes
/
Matlab-Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function output_image = median_filter_denoising(input_image)
output_image = zeros(size(input_image));
zp_input_image = padarray(input_image,[1 1]);
[row, col] = size(zp_input_image);
for i = 2:row-1
for j = 2:col-1
window3x3 = [...
zp_input_image(i-1,j-1),zp_input_image(i-1,j),zp_input_image(i-1,j+1),...
zp_input_image(i,j-1),zp_input_image(i,j),zp_input_image(i,j+1),...
zp_input_image(i+1,j-1),zp_input_image(i+1,j),zp_input_image(i+1,j+1),...
];
window3x3 = sort(window3x3);
output_image(i-1,j-1) = window3x3(5);
end
end
output_image = uint8(output_image);
end