Search code examples
matlabnoise

How to remove multifrequency noise from image using filter in matlab?


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.


Solution

  • 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.sstatic.net/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');