Wednesday, April 22, 2015

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


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 continue 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 vertical lines is here.

Vertical Line Shifted Left



Figure 1 shows a line shifted left in the image.
Figure 1. Vertical line shifted left (ver_line_01b.jpg)


We add the path, read the image, and display it. 
 
addpath C:\Users\Vladimir\research\images\
ImgVerLine_01b = imread('ver_line_01b', 'jpg');

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


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
fftVerLine01b = fft2(double(ImgVerLine_01b));
fftVerLine01b = fftshift(fftVerLine01b);
fftVerLine01b = abs(fftVerLine01b);
fftVerLine01b = log(fftVerLine01b+1);
fftVerLine01b = mat2gray(fftVerLine01b);


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(fftVerLine01b);
colormap(gray);
title('VER LINE 01b 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
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');

Figure 3. 2D FFT phase of Figure 1

The MATLAB source is at the end of this post. The next post on vertical lines is here.