## 3 Proposed Methods  
### Basic Principle and Theoretical Foundations  
The proposed method is based on the following observation:  
Given that a CNN such as CAE, applied to reconstruct the input image, is trainedonly on defect-free images, its reconstruction effectiveness in the defective region of an image will be inferior to that in the defect-free region.  
In other words, the corresponding gray level difference between the original and reconstructed images will be larger in the defective region than in the defect-free region. Figure 0(a) displays a defective surface image of fabric and Figure 0(b) is a reconstructed version through the proposed CNN. Figure 0(c) shows the residual map between the above two images and Figure 0(d) presents the plot of the residual map in 3D perspective. It can be seen from Figure 1 that the discriminative sensitivity in the image reconstruction process can be applied to locate defective regions, and the proposed method follows this principle exactly.  
In general, deep learning-based models employed for image reconstruction are based primarily on CAE. The proposed model uses a similar structure to input and output image data; however, it adopts a different training method, namely, adversarial learning, rather than the conventional method. More specifically, the proposed model is an extended version of DCGAN, which derives from GAN and addresses its training instability through some minor changes. So, to explain our method, it is important to introduce the theoretical foundation of DCGAN.  
The primary goal of DCGAN is to generate realistic images. It consists of two CNNs: generator (G) and discriminator (D). The generator maps a latent vector \(z\), which usually obeys a specified distribution, to a generated image \(x^{\prime}\); the discriminator maps \(x^{\prime}\) and the real image sample \(x\) to a scalar, which is considered as a score ranged [0, 1] to indicate how realistic the input image is. The training phase alternates between two process: (i) the discriminator attaches a high score to \(x\) and a low one to \(x^{\prime}\); (ii) the generator tries to generate a more realistic image \(x^{\prime}\) to 'fool' the discriminator, from which \(x^{\prime}\) will get a higher score. The two subnetworks compete with each other during each iteration until the Nash equilibrium of the cost function is reached. Then, in the test phase, the well-trained generator can be used to obtain a realistic image.  
The proposed model additionally includes a special feature-based LDA module. Its goal is to cooperate with the residual analysis to obtain a better detection result in the testing phase. As is well-known, the CNN has the ability of representation learning, from which the extracted hierarchical features are more generalized and robust to solve certain vision problems. The proposed method uses this kind of characteristic to locate defects in a region level. Specifically, there is one encoder before and the same encoder after the generator in the DCGAN respectively, which are used to extract the features of the input and reconstructed images; a region-level prediction can then be drawn from the similarity analysis between the two features.  
Figure 1: The different reconstruction effectiveness between defective and defect-free regions. (**a**) Original image; (**b**) Reconstructed image; (**c**) Residual image; (**d**) 3D heatmap of the residual image.