失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > matlab中陷波滤波器消除 matlab – 找到合适的陷波滤波器以从图像中移除图案

matlab中陷波滤波器消除 matlab – 找到合适的陷波滤波器以从图像中移除图案

时间:2018-11-21 20:04:27

相关推荐

matlab中陷波滤波器消除 matlab – 找到合适的陷波滤波器以从图像中移除图案

如果您查看图像的fft,您可以清楚地看到导致图像中图案的强频率.

您需要创建一个陷波滤波器,将这些高峰周围的区域归零.我尝试使用高斯陷波滤波器进行此操作,得到的频谱看起来像这样.

ifft图像(对比度增强)证明是

这是用于构建和应用过滤器的一些MATLAB代码

I = imread('YmW3f.png');

ft = fftshift(fft2(I));

[m,n] = size(ft);

% define some functions

norm_img = @(img) (img - min(img(:))) / (max(img(:)) - min(img(:)));

show_spec = @(img) imshow(norm_img(log(abs(img)-min(abs(img(:)))+1.0001)));

gNotch = @(v,mu,cov) 1-exp(-0.5*sum((bsxfun(@minus,v,mu).*(cov\bsxfun(@minus,v,mu)))));

% show spectrum before

figure();

show_spec(ft);

% by inspection

cx = 129;

cy = 129;

% distance of noise from center

wx1 = 149.5-129;

wx2 = 165.5-129;

wy = 157.5-129;

% create notch filter

filt = ones(m,n);

% use gaussian notch with standard deviation of 5

sigma = 5;

[y,x] = meshgrid(1:n, 1:m);

X = [y(:) x(:)].';

filt = filt .* reshape(gNotch(X,[cx+wx1;cy+wy],eye(2)*sigma^2),[m,n]);

filt = filt .* reshape(gNotch(X,[cx+wx2;cy+wy],eye(2)*sigma^2),[m,n]);

filt = filt .* reshape(gNotch(X,[cx-wx1;cy-wy],eye(2)*sigma^2),[m,n]);

filt = filt .* reshape(gNotch(X,[cx-wx2;cy-wy],eye(2)*sigma^2),[m,n]);

% apply filter

ft = ft .* filt;

% show spectrum after

figure();

show_spec(ft);

% compute inverse

ifft_ = ifft2(ifftshift( ft));

img_res = histeq(norm_img(ifft_));

figure();

imshow(img_res);

编辑:由于Todd Gillette指示的原因,为meshgrid交换了参数.

如果觉得《matlab中陷波滤波器消除 matlab – 找到合适的陷波滤波器以从图像中移除图案》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。