After working on this for a few days. This is the code I've written thus far:
if true % code
end% Clear the workspace
clcclear all;% Read the image 'Proj2.tif'
Proj2Image = 'Proj2.tif';img = imread(Proj2Image);% Stores the image as an array
img = img(:,:,1);% I then take the Fast Fourier Transform (FFT) of the Image
imgfft = fft2(img);% Next, I create a Butterworth Filter. A Low Pass Filter
% could probably also be performed, and work just as well.
% 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 the X and Y direction
A = ones(X,Y);XX = [204 182 191 196 214 219 228];YY = [273 275 267 282 264 279 271];% L is the max number of pixels in the image (i.e. 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;% Subtract the array of ones
A = 1 - A;% Next, I apply the filter by shifting the FFT of the image
% and multiplying it by the array of ones.
FilterImage = fftshift(imgfft).*A;% Here, I shift back and perform the Inverse FFT
FilterImage2 = ifft2(fftshift(FilterImage));% Next, I display FilterImage2 with the colormap defined as 'map'
imshow(abs(FilterImage2),map);% Then I resize and display the 'periodicpattern.tif' image
% And compare it to the 'Proj2.tif' image that I filtered,
% shifted, and performed the FFT and Inverse FFT on.
[img,map] = imread('periodicpattern.tif');figure('Name','Patterns/comparison');subplot(1,2,1), imshow(abs(FilterImage2),map);title('Patterns');subplot(1,2,2), imshow(img,map);title('Periodic Pattern of Image');
The problem I have with this code though is that when I run it, I get the following error message on Line 63: Undefined function or variable 'map'.
Do you have any other method I could use to fix this error, other than:
imshow(abs(FilterImage2),map);
I'm not quite too sure why it is doing this since Matlab ought to accept:
imshow(X,map)
which I don't think is all that much different. I tried replacing the abs(FilterImage2) by assigning it to a variable called I:
I = abs(FilterImage2);
But Matlab doesn't like this either.
Again, my input image is attached and all I am trying to do with it is get the mesh periodic cross-pattern out of it.
Best Answer