هموارسازی تصویر به منظور حذف نویز با متلب
کدهای پروژه
function [output] = myaveragefilter(I,r,c)
mask= ones(r,c);
mask= mask/ sum(mask(:));
%% step 2——————–
nr= floor(r/2);
nc= floor(c/2);
J1= padarray(I,[nr nc],’symmetric’);
%% step 3————————-
output= I;
[rows,cols]= size(J1);
for i=nr+1:rows-nr
for j=nc+1:cols-nc
temp= J1(i-nr:i+nr,j-nc:j+nc);
temp= mask.* temp;
J2(i-nr,j-nc)= sum(temp(:));
end
end
$$$$$$$$$$$$$$$$$$$$
function [output] = Avg2(I,r,c)
mask= ones(r,c);
mask= mask/ sum(mask(:));
%% step 2——————–
nr= floor(r/2);
nc= floor(c/2);
J1= padarray(I,[nr nc],’symmetric’);
%% step 3————————-
output= I;
[rows,cols]= size(J1);
for i=nr+1:rows-nr
for j=nc+1:cols-nc
temp= J1(i-nr:i+nr,j-nc:j+nc);
temp= mask.* temp;
J2(i-nr,j-nc)= sum(temp(:));
end
end
end
end
$$$$$$$$$$$$$$$$$$$$$$
clc;
clear;
close all;
%%——————-
I= imread(‘C:\Users\ACER\Desktop\hubbel.jpg’);
if size(I,3)>1
I= rgb2gray(I);
end
I= im2double(I);
figure
imshow(I)
%% step 1: apply averge filter on input image
r=9;
c=9;
J1 = myaveragefilter(I,r,c);
figure
imshowpair(I,J1,’montage’)
%% step 2: threshold image
thr= graythresh(J1);
BW= im2bw(J1,thr);
figure
imshowpair(I,BW,’montage’)
%% step 3: multiply bw image with original image
J2= I.*BW;
figure
imshowpair(I,J2,’montage’)
دیدگاهتان را بنویسید