How to remove the pattern from microscopy scanned image

25 vues (au cours des 30 derniers jours)
Peyman Obeidy
Peyman Obeidy le 12 Oct 2017
Commenté : Peyman Obeidy le 12 Oct 2017
To remove the pattern fro the image I am using an averaging filter (see the code below). It helps with removing the background but make it hard to recover the dark points in the image(attached in '.mat' file). Any suggestion will be highly appreciated.
% code
load('Image.mat');
meanFilter = fspecial('average', [4 4]);
ImIn_filterM = imfilter(ImIn, meanFilter);
imshow(ImIn_filterM,[])
newIm=ImIn./ImIn_filterM;
imshow(newIm,[])
b = imsharpen(newIm,'Radius',2,'Amount',1);
figure, imshow(b)
I tried FFT, what didn't remove the pattern. At the end of FFT is a filtered image. I divide the original image with the filtered image to remove the background. Is this correct to do?
fontSize=10;
% Display original grayscale image.
subplot(2, 2, 1);
grayImage=ImIn;
imshow(grayImage)
title('Original Gray Scale Image', 'FontSize', fontSize)
% Perform 2D FFTs
fftOriginal = fft2(double(grayImage));
shiftedFFT = fftshift(fftOriginal);
subplot(2, 2, 2);
imshow(real(shiftedFFT));
title('Real Part of Spectrum', 'FontSize', fontSize)
subplot(2, 2, 3);
imshow(imag(shiftedFFT));
title('Imaginary Part of Spectrum', 'FontSize', fontSize)
% Display magnitude and phase of 2D FFTs
subplot(2, 2, 4);
imshow(log(abs(shiftedFFT)),[]);
colormap gray
title('Log Magnitude of Spectrum', 'FontSize', fontSize)
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Now convolve with a 2D rect function.
figure;
rectWidth = 10;
rectHeight = 5;
kernel = ones(rectHeight, rectWidth) / (rectHeight * rectWidth);
% Display it
subplot(2, 2, 1);
k = padarray(kernel, [3, 3]); % Just for display.
imshow(k, []);
axis on;
title('Kernel', 'FontSize', fontSize)
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Convolve kernel (box filter) with the image
filteredImage = conv2(double(grayImage), kernel, 'same');
% Display filtered image.
subplot(2, 2, 2);
imshow(filteredImage,[]);
title('Filtered Image', 'FontSize', fontSize)
% Perform 2D FFT on the filtered image to see its spectrum.
% We expect to see a sinc multiplication effect.
% It should look like the original but with a sinc pattern overlaid on it.
fftFiltered = fft2(double(filteredImage));
shiftedFFT = fftshift(fftFiltered);
% Display magnitude of the 2D FFT of the filtered image.
subplot(2, 2, 3);
imshow(log(abs(shiftedFFT)),[]);
colormap gray
title('Log Magnitude of Spectrum - Note sinc multiplication', 'FontSize', fontSize)
NewIm=ImIn./filteredImage;
imshow(NewIm,[]);

Réponse acceptée

Image Analyst
Image Analyst le 12 Oct 2017
Well obviously sharpening the image won't remove the stripes - if anything it will just make it worse.
Look at the log magnitude of the spectrum. See those spikes? Just erase those and inverse transform. I'm attaching a similar example that you can adapt.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by