# Algorithm Development for the Non-Destructive Testing of Structural Damage
## 3 Damage Visualization
### Developed Image Processing Algorithms
#### 3.1.2.1 Segmentation of Steel Plate (SSP) Images  
The gradient magnitude was calculated on pre-processed SP images by computing the gradients in four directions of an image with the Prewitt filter. The edges of the crack were returned at those points where the gradient of the image was maximized. Therefore, the edges were obtained by using the Prewitt approximation to the derivative. Assuming the profile of the image as f(x), the detailed pseudocode of this algorithm is described as follows. **Pseudocode 1. ** The proposed FT-based algorithms for defect segmentation in microwave imaging. **Input:**_Phase and Magnitude_  
**Output:**_True Target Segmentation_  
1. Pre-processing of SP images as in Section 1. 2. Computation of the derivative of the input microwave image as f(x) to identify the direction of the maximum changes:  
\[\frac{\mathrm{d}y}{\mathrm{d}x}=\lim_{h\to 0}\left(\frac{\mathrm{f(x+h)-f(x-h)}}{h}\right)\]  
where h has the value of '1' as the smallest possible value that can occur in an image; therefore, the discrete version of the derivative expression is the form of:  
\[\mathrm{f(x+1)-f(x-1)}\]  
3. Consideration of the horizontal, vertical, and diagonal filters based on Prewitt approximation in four directions: These filters find horizontal, vertical, and diagonal edges in an image while smoothing the results. \[\mathrm{P_{x}=\left( \begin{array}{ccc}-1&0&1\\ -1&0&1\\ -1&0&1\end{array} \right)}\qquad\text{Vertical filter}\]  
\[\mathrm{P_{y}=P_{x}^{\prime}}\qquad\qquad\text{Horizontal filter}\]  
\[\mathrm{P_{d1}=\left( \begin{array}{ccc}0&1&1\\ -1&0&1\\ -1&-1&0\end{array} \right)}\qquad\text{Diagonal filter (Right to left)}\]  
\[\mathrm{P_{d2}=\left( \begin{array}{ccc}-1&-1&0\\ -1&0&1\\ 0&1&1\end{array} \right)}\qquad\text{Diagonal filter (Right to left)}\]  
4. Assuming that \(\mathrm{P_{x}}\), \(\mathrm{P_{y}}\), \(\mathrm{P_{d1}}\), and \(\mathrm{P_{d2}}\) as the grey values produced by applying the above filters to an image, the gradient magnitude is computed by:  
\[\mathrm{GM=\sqrt{P_{x}^{2}+P_{y}^{2}+P_{d1}^{2}+P_{d2}^{2}}}\]  
5. Computing the threshold value of the image by [PERSON]'s thresholding method. 6. Generating the binary image that contains edges by only applying the threshold value. 3.1.2.2. Segmentation of Composite Material (SCM) Images  
Three algorithms are proposed for this purpose;  
_Algorithm 1_: In the first algorithm, the 2D-FFT, which is one of the most fundamental tools in image analysis and an appropriate candidate for grey level images [37], is computed on CM images. It provides a more precise separation of the desired information than the 1D transform [38]. It can be mathematically formulated as:  
\[\mathrm{Y_{p+1,4+1}}=\sum_{j=0}^{m-1}\sum_{k=0}^{n-1}w_{m}^{jp}w_{n}^{kq}X_{j+1, k+1} \tag{15}\]  
\[w_{m}=e^{-2\pi i/m} \tag{16}\]  
\[w_{n}=e^{-2\pi i/n} \tag{17}\]  
where Y is a discrete Fourier transform, X is a matrix of m x n (2D-image), wm and wn denote complex roots of unity, and i indicates the imaginary unit. The obtained output is shifted to locate the zero-frequency component at the center of the output. The element-wise multiplication of the obtained FFT frequency components with a Wavelet transform is performed to suppress the effect of noise. This convolution was performed one, two, and three times, to investigate its optimization effects on the segmentation results [35]. This process is followed by taking the inverse transform and multi-thresholding to perform segmentation. Finally, the obtained binary image is eroded to remove small objects. This algorithm is summarized as Pseudocode 2. ```
Input: Phase and Magnitude Output: True Target Segmentation
1 Pre-processing of CM images as Section 1. 2 Computation of the 2D-FFT of the on the input microwave image as \"y\". 3 Element-wise multiplication of Wavelet transform and \"y\". for i: 1 to 3 // Separately perform one-, two-, and three-fold convolution xy [i] = x\"y // Convolution of x and y: (x*y): Integral of the product of the two matrices after one is reversed and shifted.