0

I have a noisy image that I am trying to clean using a lowpass filter (code below, modified from here). The image I get as a result is essentially identical to the one I gave as an input.

I'm not an expert, but my conclusion would be that the input image is so noisy that no patterns are found. Do you agree? Do you have any suggestion on how to interpret the result?

Result from the code:

enter image description here

Input image:

enter image description here

Code:

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');
Community
  • 1
  • 1
albus_c
  • 6,292
  • 14
  • 36
  • 77
  • 2
    Without digging into your image, it would appear that either your filter cutoff frequency or cutoff amplitude is not "catching" the high-frequency noise in your input. Try varying the cutoff frequency. – Carl Witthoft Jun 08 '15 at 11:26
  • Thanks Carl. I also had the same idea; I played with the 'roi' and 'threshold' values but I didn't manage to get a more meaningful result. – albus_c Jun 08 '15 at 11:39
  • What patterns are you specifically looking for? Circles? Any Object? .Looking at your input image, it is clear that one key problem with it is that it is too narrow, you might want to equalise it before you proceed to process to process it further. – KillaKem Jun 08 '15 at 18:29

1 Answers1

2

For filtering this kind of signal, you can try to use the median filter. It might be more appropriated than a means or Gaussian filter. The median filter is very effective on "salt and paper" noise when the mean just blur the noise.

As the signal seems very noisy, you need to try to find the good size of kernel for the filter. You can also try to increase the contrast of the image (after filtering) in order to see more the difference between the gray levels.

Olivier A
  • 842
  • 4
  • 8