低通滤波器不工作
Lowpass filter non working
我有一张嘈杂的图像,我正在尝试使用低通滤波器(下面的代码,从 here 修改而来)进行清理。结果我得到的图像与我作为输入提供的图像基本相同。
我不是专家,但我的结论是输入图像太嘈杂以至于找不到任何模式。你同意?您对如何解读结果有什么建议吗?
代码结果:
输入图像:
代码:
clear; close all;
frame = 20;
size_y = 512; % This is actually size_x
size_x = 256; % This is actually size_y
roi=5;thresh=100000;
AA = imread('image.png');
A = zeros(size_x, size_y);
A = AA(1:size_x, 1:size_y);
A(isnan(A)) = 0 ;
B = fftshift(fft2(A));
fabs = abs(B);
figure; imshow(B);
local_extr = ordfilt2(fabs, roi^2, ones(roi)); % find local maximum within 3*3 range
result = (fabs == local_extr) & (fabs > thresh);
[r, c] = find(result);
for i=1:length(r)
if (r(i)-128)^2+(c(i)-128)^2>thresh % periodic noise locates in the position outside the 20-pixel-radius circle
B(r(i)-2:r(i)+2,c(i)-2:c(i)+2)=0; % zero the frequency components
end
end
Inew=ifft2(fftshift(B));
figure;
subplot(2,1,1); imagesc(A), colormap(gray); title('Original image');
subplot(2,1,2);imagesc(real(Inew)),colormap(gray); title('Filtered image');
对于这种信号的过滤,可以尝试使用中值滤波器。它可能比均值或高斯滤波器更合适。当均值只是模糊噪声时,中值滤波器对 "salt and paper" 噪声非常有效。
由于信号似乎很嘈杂,您需要尝试为滤波器找到合适的内核大小。您还可以尝试增加图像的对比度(过滤后),以便看到更多灰度级之间的差异。
我有一张嘈杂的图像,我正在尝试使用低通滤波器(下面的代码,从 here 修改而来)进行清理。结果我得到的图像与我作为输入提供的图像基本相同。
我不是专家,但我的结论是输入图像太嘈杂以至于找不到任何模式。你同意?您对如何解读结果有什么建议吗?
代码结果:
输入图像:
代码:
clear; close all;
frame = 20;
size_y = 512; % This is actually size_x
size_x = 256; % This is actually size_y
roi=5;thresh=100000;
AA = imread('image.png');
A = zeros(size_x, size_y);
A = AA(1:size_x, 1:size_y);
A(isnan(A)) = 0 ;
B = fftshift(fft2(A));
fabs = abs(B);
figure; imshow(B);
local_extr = ordfilt2(fabs, roi^2, ones(roi)); % find local maximum within 3*3 range
result = (fabs == local_extr) & (fabs > thresh);
[r, c] = find(result);
for i=1:length(r)
if (r(i)-128)^2+(c(i)-128)^2>thresh % periodic noise locates in the position outside the 20-pixel-radius circle
B(r(i)-2:r(i)+2,c(i)-2:c(i)+2)=0; % zero the frequency components
end
end
Inew=ifft2(fftshift(B));
figure;
subplot(2,1,1); imagesc(A), colormap(gray); title('Original image');
subplot(2,1,2);imagesc(real(Inew)),colormap(gray); title('Filtered image');
对于这种信号的过滤,可以尝试使用中值滤波器。它可能比均值或高斯滤波器更合适。当均值只是模糊噪声时,中值滤波器对 "salt and paper" 噪声非常有效。
由于信号似乎很嘈杂,您需要尝试为滤波器找到合适的内核大小。您还可以尝试增加图像的对比度(过滤后),以便看到更多灰度级之间的差异。