1

I have an image that has multi frequency noise, I used the code in this link : Find proper notch filter to remove pattern from image source image : orig_image But my final image noise has not been removed. As you know, I must remove the gradient in vertical direction. the frequency representation of image come in below: fft of image Have anyone idea for removal of this noise in matlab? I apply sobel filter and median filter but not improved. Note that my goal is remove of lines inside of object. Regards.

Community
  • 1
  • 1
opencv train
  • 29
  • 2
  • 13

2 Answers2

1

You have two kinds of noise: irregular horizontal lines and salt and pepper. Getting rid of the lines is easy as long as the object doesn't cover the whole horizontal range (which it doesn't in your example).

I just sample a small vertical stripe on the left to only get the stripes and then subtract them from the whole image. Removing the salt and pepper noise is simple with a median filter.

Result: enter image description here

Code:

% read the image
img = imread('https://i.stack.imgur.com/zBEFP.png');
img = double(img(:, :, 1)); % PNG is uint8 RGB

% take mean of columsn 100..200 and subtract from all columns
lines = mean(img(:, 100:200), 2);
img = img - repmat(lines, 1, size(img, 2));

% remove salt and pepper noise
img =medfilt2(img, [3,3], 'symmetric');

% display and save
imagesc(img); axis image; colormap(gray);
imwrite((img - min(img(:))) / (max(img(:)) - min(img(:))), 'car.png');
NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
0

here is code I once used for an assignment I once had to do. It was a much simpler example than the one you have. There were only a total of 4 components in the frequency domain causing noise, so simply setting those 4 components to zero manually (hfreq) solved my problem. I dont know how well this will work in your case, perhaps writing an algorithm to find the appropriate hfreqs that stand out will help. Here was the original image I used :

This is the code I used :

    %  filtering out the noisy image

clc
clear all
close all

image = imread('freqnoisy.png');

image = double(image);
image = image/(max(max(image)));

imshow(image) % show original image

Fimage = fft2(image); 

figure
imshow(((fftshift(abs(Fimage)))),[0 5000]) %shows all frequency peaks that stick out


hfreq = ones(256);

hfreq(193,193)=0;
hfreq(65,65) = 0;


hfreq(119,105) = 0;
hfreq(139,153)= 0;



% 
Fimage_filtered = fftshift(Fimage).*hfreq;



figure
imshow(abs(Fimage_filtered),[0 5000]) % show freq domain without undesired freq

filtered_im = ifft2(ifftshift(Fimage_filtered));
figure
imshow(filtered_im)

this is what your output will look like :

enter image description here

jerpint
  • 399
  • 2
  • 16
  • Tnx, in your case, noise is periodic witch means that have a special frequency, but mine frequency is wide range, and I don't know delete witch one. – opencv train May 25 '16 at 20:36