matlab高斯滤波跟中值滤波区别,matlab图像滤波处理代码讲解 均值滤波 中值滤波 高斯滤波...
該樓層疑似違規已被系統折疊?隱藏此樓查看此樓
(1)均值濾波
function imres = averageFilter(im,N) % imres為均值濾波后的矩陣,參數im為圖像的路徑,N為濾波模板
if 3==size(im,3) %判斷im是否為三維圖像,若是,則轉換為灰度圖像。
im = rgb2gray(im);
end
im = double(im);
h = ones(N,N)/N^2;
imres = imfilter(im, h, 'conv','replicate');
其中h = ones(N,N)/N^2; 是什么意思。
(2)中值濾波
function imres = medianFilter(im,N)
if 3==size(im,3)
im = rgb2gray(im);
end
im= double(im);
imres = im;
[row col] = size(im); %獲取圖像的行和列
wd = floor(N/2);%floor 向下取整(去掉小數點部分)
for x = wd+1:1:row-wd
for y = wd+1:1:col-wd
subim = im(x-wd:x+wd,y-wd:y+wd);
imres(x,y) = median(subim(:));
end
end
循環這部分我看不懂?
function imres = gaussianFilter(im,sigma) %sigma為標準差
if 3==size(im,3)
im = rgb2gray(im);
end
im = double(im);
GaussianDieOff=0.0001; %
pw = 1:30; %設定濾波器寬度
ssq = sigma^2;%計算方差
width = find(exp(-(pw.*pw)/(2*ssq))>GaussianDieOff,1,'last');
t = (-width:width);
gau = exp(-(t.*t)/(2*ssq))/(2*pi*ssq); % the gaussian 1D filter
gau = gau/sum(gau);
%smooth the image out
aSmooth=imfilter(im,gau,'conv','replicate');
imres=imfilter(aSmooth,gau','conv','replicate');
這個高斯濾波就更看不懂了
總結
以上是生活随笔為你收集整理的matlab高斯滤波跟中值滤波区别,matlab图像滤波处理代码讲解 均值滤波 中值滤波 高斯滤波...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab函数参数命令,matlab函
- 下一篇: php表白情话,向一个人表白 抖音最火9