# A New Defect Diagnosis Method for Wire Rope Based on CNN-Transformer and Transfer Learning
## 3 Methodology
### Image Establishment
#### 3.2.2 Image Processing  
First, data extension and segmentation steps were conducted. The purpose of the data extension step is to provide an adequate amount of data for feature image processing and a simple explanation of this step is the use of the detected defect extreme points as the axial center and the addition of certain data points at both sides. The feature image is established at a size of \(10\times 10\) and the data extension numbers located on the left and right sides are set to 49 and 50, respectively. Consequently, 1D defect signals can be obtained and the remaining data are segmented at the same lengths. Namely, there are 100 signal points in each sample, whether they are normal or defect data. Specifically, the length of the data should be adjusted according to the real application since it can affect the diagnosis resolution during an online diagnosis. Figure 4: Defect location based on isolation forest algorithm. Red dots are the detected abnormal signals that can be used to further locate the defect locations. Figure 5: Defect location following the use of the local extremum algorithm. Following the application of the local extremum algorithm, each defect can be located by these individual red dots. Second, 1D signals are recreated into 2D feature images through the matrix reconstruction method. Moreover, all the data presented in each sample should be max-min normalized and mapped to 0-255 using Equation (6). Where, \(X(i)\) is the \(i^{th}\) sample of the 1D signals and \(X(i)_{max}\) and \(X(i)_{min}\) are the maximum and minimum values of \(X(i)\). \[S(i)=\frac{X(i)_{\text{max}}-X(i)}{X(i)_{\text{max}}-X(i)_{\text{min}}}\times 255 \tag{6}\]  
Then, the matrix reconstruction method is employed to obtain the \(10\times 10\) matrix, and the element of the transformed matrix is used as the pixel of a gray image, a simple feature image (\(M\)) can be established using Equation (7):  
\[M=\tau\big{[}S(i)_{L\times 1}\big{]} \tag{7}\]  
where function \(\tau[\cdot]\) is an operation from 1D signals \(S(i)\), which contain \(L\) data points for the 2D matrix, and the process can be defined as Equation (8):  
\[\tau[S(i)]:[s(1),s(2),s(3),\cdots,s(L)]\rightarrow \begin{bmatrix}P_{11}&P_{12}& \cdots&P_{1n}\\ \vdots&\vdots&&\vdots\\ P_{m1}&P_{m2}&\cdots&P_{mn}\end{bmatrix}  \tag{8}\]  
Particularly, \(L\) should present a square root if the final image is transformed into a square matrix. Here, \(L=mn=k^{2}\), where \(k\) is the order of the right matrix and defined as 10 in this paper. During the process of matrix reconstruction, the relationship between each datum of \(S(i)\) and the matrix can be calculated by Equation (9), where \(m\) and \(n\) are the row and column indexes of the final matrix value, respectively. \[P_{mn}=s(k\times(m-1)+n) \tag{9}\]  
According to the algorithm presented in Table 1, the normal and defect feature images can be obtained and are presented in Figure 6. Obviously, image expression is more intuitive and distinguished when compared with the 1D original LMA signals. Moreover, those characteristics in different types of images are clear and distinguishable. As indicated by the red dotted line, it can be observed that the wire rope defect information changes into black-and-white cross stripes that are caused by the intense fluctuations in the defect LMA signals. Furthermore, cross stripes exist in all defect images; this is beneficial for the improvement of robustness and consistency outcomes achieved during the defect detection process. Unlike the defect images, normal images are characterized by random noise points instead of cross stripes because MFL signals can only be captured at defect locations.