**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 diagonal lines. Let us move the top-left-to-bottom-right diagonal line down and compute its magnitude and thickness. The MATLAB source of our programmatic investigation is in the last section of this post. The previous post on diagonal lines is here.

**Diagonal Line from Top Left to Bottom Right**

**Figure 1**shows a diagonal line from top left to bottom right moved diagonally down.

Figure 1. dig_tl_br_line_01c.jpg |

We add the path, read the image, and display it.

addpath C:\Users\Vladimir\research\images\

ImgDigTlBrLine_01c = imread('dig_tl_br_line_01c', 'jpg');

figure;

imshow(ImgDigTlBrLine_01c);

title('Dig TL-BR LINE 01c');

Now we compute the 2D FFT of the image in

%% ff2 magnitude

fftDigTlBrLine01c = fft2(double(ImgDigTlBrLine_01c));

fftDigTlBrLine01c = fftshift(fftDigTlBrLine01c);

fftDigTlBrLine01c = abs(fftDigTlBrLine01c);

fftDigTlBrLine01c = log(fftDigTlBrLine01c+1);

fftDigTlBrLine01c = mat2gray(fftDigTlBrLine01c);

The magnitude image is shown in

figure;

imshow(fftDigTlBrLine01c);

colormap(gray);

title('Dig TL-BR LINE 01c FFT2 Magnitude');

addpath C:\Users\Vladimir\research\images\

ImgDigTlBrLine_01c = imread('dig_tl_br_line_01c', 'jpg');

figure;

imshow(ImgDigTlBrLine_01c);

title('Dig TL-BR LINE 01c');

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

fftDigTlBrLine01c = fft2(double(ImgDigTlBrLine_01c));

fftDigTlBrLine01c = fftshift(fftDigTlBrLine01c);

fftDigTlBrLine01c = abs(fftDigTlBrLine01c);

fftDigTlBrLine01c = log(fftDigTlBrLine01c+1);

fftDigTlBrLine01c = mat2gray(fftDigTlBrLine01c);

The magnitude image is shown in

**Figure 2**. As can be seen in**Figure 2**, the FFT magnitude shows a diagonal line in the center orthogonal to the diagonal line in**Figure 1**. Note that there are other lines orthogonal to the diagonal line in**Figure 1**but less pronounced than the other lines. This indicates that there are other frequencies detected in the image.figure;

imshow(fftDigTlBrLine01c);

colormap(gray);

title('Dig TL-BR LINE 01c FFT2 Magnitude');

Figure 2. 2D FFT Magnitude of Figure 1 |

The phase component can be computed and displayed by the following MATLAB code.

**Figure 3**shows the 2D FFT phase graph of

**Figure 1**.

%%% fft2 phase

fftDigTlBrLine01c_PHASE = fft2(double(ImgDigTlBrLine_01c));

fftDigTlBrLine01c_PHASE = fftshift(fftDigTlBrLine01c_PHASE);

fftDigTlBrLine01c_PHASE = angle(fftDigTlBrLine01c_PHASE);

figure;

imshow(fftDigTlBrLine01c_PHASE, [-pi, pi]);

colormap(gray);

title('Dig TL-BR LINE 01c FFT2 Phase');

Figure 3. 2D FFT Phase of Figure 1 |