Need help for Extracting periodic pattern that is vaguely visible in image using Matlab

8 vues (au cours des 30 derniers jours)
I need some help extracting the cross-mesh periodic pattern of the _ i.tiff _ image that I've attached. In short, I need the o.tiff as my output image by applying operations on the input image. Below is the code which I tried but I am not even close to output. Let me summarize the process which I tried to implement:
Read the image
Apply FFT
Apply Butterworth filter
Apply IFFT
Please help me what changes I have to make in my code to get my desired output (i.e. o.tiff)
Input image:
Desired Output image:
[img,map] = imread('i.tif');
figure
imshow(img,map);
title('Original Image');
% Store the original image as an array.
img = img(:,:,1);
% Perform the Fast Fourier Transform (FFT) on the Image
imgfft = fft2(img);
% Next, I create a Butterworth Low-Pass Filter.
% Note: c is a constant
% X is the size of the dimension of array X
% Y is the size of the dimension of array Y
c = 2;
X = size(imgfft, 1);
Y = size(imgfft, 2);
% A returns an array of ones in X and Y.
A = ones(X,Y);
% 7 unique pixels are used in each array.
XX = [204 182 191 196 214 219 228];
YY = [273 275 267 282 264 279 271];
% L = Max Number of Pixels = 255
L = 255;
for i=1:length(L)
for x = 1:X
for y = 1:Y
%Compute the distance between the points.
Lxy = sqrt((x-XX(i))^2 + (y-YY(i))^2);
A(x,y) = A(x,y) + 1/(1+(Lxy/L(i)^2))^(2*c);
end
end;
end;
% Next, I apply the Butterworth filter by shifting
% the FFT of the image, and multiplying it by A.
FilterImage = fftshift(imgfft).*A;
figure
imshow(abs(FilterImage),[]);
title('Image After Shifting by FFT and Multiplying By A');
% Here, I shift back and perform the Inverse FFT
FilterImage2 = ifft2(fftshift(FilterImage));
figure
imshow(abs(FilterImage2),[]);
title('Shifting Back and Performing Inverse FFT');
% Then I resize and display the 'periodicpattern.tif' image
% And compare it to the output Image named 'FilterImage2'.
[img1,map1] = imread('o.tif');
figure('Name','Periodic Pattern Comparison');
subplot(1,2,1), imshow(abs(FilterImage2),[]);
title('Periodic Pattern of Image');
subplot(1,2,2), imshow(img1,map1);
title('periodicpattern.tif(expected)');

Réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by