## Wednesday, April 22, 2015

### 2D FFT: Effects of Location & Thickness of Vertical Lines on 2D FFT Magnitude & Phase: Part 01

Problem

This post continues our series of posts on a programmatic investigation of the effects of the location and thickness of horizontal, vertical, and diagonal lines on the magnitude and phase components of 2D FFT. In this post, we will start our investigation of vertical lines by modifying their location in the image without modifying their thickness. The MATLAB source of our programmatic investigation is in the last section of this post. The previous post on horizontal lines is here.

Centrally Positioned Vertical Line

Figure 1 shows a vertical line centrally positioned in the image.

 Figure 1. Centrally positioned vertical line (ver_line_01a.jpg)

figure;
imshow(ImgVerLine_01a);
title('VER LINE 01a');

Now we compute the 2D FFT of the image in Figure 1. The image is converted into a 2D double matrix. The fftshift command positions the 0,0 origin to the center of the image. We compute the absolute magnitude of each value in the 2D matrix and take the log of each value. 1 is added to each value before taking the log, because log(0) is not defined.

%%% ff2 magnitude
fftVerLine01a = fft2(double(ImgVerLine_01a));
fftVerLine01a = fftshift(fftVerLine01a);
fftVerLine01a = abs(fftVerLine01a);
fftVerLine01a = log(fftVerLine01a+1);
fftVerLine01a = mat2gray(fftVerLine01a);

The magnitude image is shown in Figure 2. As can be seen in Figure 2, the FFT magnitude shows a line orthogonal to the vertical line in Figure 1. Note that with horizontal lines the 2D FFT magnitude lines are vertical.

figure;
imshow(fftVerLine01a);
colormap(gray);
title('VER LINE 01a FFT2 Magnitude');
 Figure 2. 2D FFT magnitude of Figure 1
We compute the phase component and display it. The image is shown in Figure 3.

%%% fft2 phase
fftVerLine01a_PHASE = fft2(double(ImgVerLine_01a));
fftVerLine01a_PHASE = fftshift(fftVerLine01a_PHASE);
fftVerLine01a_PHASE = angle(fftVerLine01a_PHASE);

figure;
imshow(fftVerLine01a_PHASE, [-pi, pi]), colormap(gray);
title('VER LINE 01a FFT2 Phase');

 Figure 3. 2D FFT phase of Figure 1
The next post on vertical lines is here.

MATLAB Source

%%% ==================================================================
%%% Programmatic Investigation of the Effects of Location and Thickness
%%% of vertical lines on the magnitude and phase components of 2D FFT.
%%%
%%% ==================================================================

%%% ================== 2D FFT of VER LINE 01a ============================

figure;
imshow(ImgVerLine_01a);
title('VER LINE 01a');

%%% ff2 magnitude
fftVerLine01a = fft2(double(ImgVerLine_01a));
fftVerLine01a = fftshift(fftVerLine01a);
fftVerLine01a = abs(fftVerLine01a);
fftVerLine01a = log(fftVerLine01a+1);
fftVerLine01a = mat2gray(fftVerLine01a);

figure;
imshow(fftVerLine01a);
colormap(gray);
title('VER LINE 01a FFT2 Magnitude');

%%% fft2 phase
fftVerLine01a_PHASE = fft2(double(ImgVerLine_01a));
fftVerLine01a_PHASE = fftshift(fftVerLine01a_PHASE);
fftVerLine01a_PHASE = angle(fftVerLine01a_PHASE);

figure;
imshow(fftVerLine01a_PHASE, [-pi, pi]), colormap(gray);
title('VER LINE 01a FFT2 Phase');

%%% ================== 2D FFT of VER LINE 01b ============================

figure;
imshow(ImgVerLine_01b);
title('VER LINE 01b');

%%% ff2 magnitude
fftVerLine01b = fft2(double(ImgVerLine_01b));
fftVerLine01b = fftshift(fftVerLine01b);
fftVerLine01b = abs(fftVerLine01b);
fftVerLine01b = log(fftVerLine01b+1);
fftVerLine01b = mat2gray(fftVerLine01b);

figure;
imshow(fftVerLine01b);
colormap(gray);
title('VER LINE 01b FFT2 Magnitude');

%%% fft2 phase
fftVerLine01b_PHASE = fft2(double(ImgVerLine_01b));
fftVerLine01b_PHASE = fftshift(fftVerLine01b_PHASE);
fftVerLine01b_PHASE = angle(fftVerLine01b_PHASE);

figure;
imshow(fftVerLine01b_PHASE, [-pi, pi]), colormap(gray);
title('VER LINE 01b FFT2 Phase');

%%% ================== 2D FFT of VER LINE 01c ============================

figure;
imshow(ImgVerLine_01c);
title('VER LINE 01c');

%%% ff2 magnitude
fftVerLine01c = fft2(double(ImgVerLine_01c));
fftVerLine01c = fftshift(fftVerLine01c);
fftVerLine01c = abs(fftVerLine01c);
fftVerLine01c = log(fftVerLine01c+1);
fftVerLine01c = mat2gray(fftVerLine01c);

figure;
imshow(fftVerLine01c), colormap(gray);
title('VER LINE 01c FFT2 Magnitude');

%%% fft2 phase
fftVerLine01c_PHASE = fft2(double(ImgVerLine_01c));
fftVerLine01c_PHASE = fftshift(fftVerLine01c_PHASE);
fftVerLine01c_PHASE = angle(fftVerLine01c_PHASE);

figure;
imshow(fftVerLine01c_PHASE, [-pi, pi]), colormap(gray);
title('VER LINE 01c FFT2 Phase');

%%% ================== 2D FFT of VER LINE 01d ============================

figure;
imshow(ImgVerLine_01d);
title('VER LINE 01d');

%%% ff2 magnitude
fftVerLine01d = fft2(double(ImgVerLine_01d));
fftVerLine01d = fftshift(fftVerLine01d);
fftVerLine01d = abs(fftVerLine01d);
fftVerLine01d = log(fftVerLine01d+1);
fftVerLine01d = mat2gray(fftVerLine01d);

figure;
imshow(fftVerLine01d), colormap(gray);
title('VER LINE 01d FFT2 Magnitude');

%%% fft2 phase
fftVerLine01d_PHASE = fft2(double(ImgVerLine_01d));
fftVerLine01d_PHASE = fftshift(fftVerLine01c_PHASE);
fftVerLine01d_PHASE = angle(fftVerLine01d_PHASE);

figure;
imshow(fftVerLine01d_PHASE, [-pi, pi]), colormap(gray);
title('VER LINE 01d FFT2 Phase');

%%% ================== 2D FFT of VER LINE 01e ============================

figure;
imshow(ImgVerLine_01e);
title('VER LINE 01e');

%%% ff2 magnitude
fftVerLine01e = fft2(double(ImgVerLine_01e));
fftVerLine01e = fftshift(fftVerLine01e);
fftVerLine01e = abs(fftVerLine01e);
fftVerLine01e = log(fftVerLine01e+1);
fftVerLine01e = mat2gray(fftVerLine01e);

figure;
imshow(fftVerLine01e), colormap(gray);
title('VER LINE 01e FFT2 Magnitude');

%%% fft2 phase

fftVerLine01e_PHASE = fft2(double(ImgVerLine_01e));
fftVerLine01e_PHASE = fftshift(fftVerLine01e_PHASE);
fftVerLine01e_PHASE = angle(fftVerLine01e_PHASE);

figure;
imshow(fftVerLine01e_PHASE, [-pi, pi]), colormap(gray);
title('VER LINE 01e FFT2 Phase');

%%% ================== 2D FFT of VER LINE 01f ============================

figure;
imshow(ImgVerLine_01f);
title('VER LINE 01f');

%%% ff2 magnitude
fftVerLine01f = fft2(double(ImgVerLine_01f));
fftVerLine01f = fftshift(fftVerLine01f);
fftVerLine01f = abs(fftVerLine01f);
fftVerLine01f = log(fftVerLine01f+1);
fftVerLine01f = mat2gray(fftVerLine01f);

figure;
imshow(fftVerLine01f), colormap(gray);
title('VER LINE 01f FFT2 Magnitude');

%%% fft2 phase
fftVerLine01f_PHASE = fft2(double(ImgVerLine_01f));
fftVerLine01f_PHASE = fftshift(fftVerLine01f_PHASE);
fftVerLine01f_PHASE = angle(fftVerLine01f_PHASE);

figure, imshow(fftVerLine01f_PHASE, [-pi, pi]), colormap(gray);
title('VER LINE 01f FFT2 Phase');

%%% ======================================================================