# Color Structured Light Stripe Edge Detection Method Based on Generative Adversarial Networks
## 3 Proposed Method
### Network Architecture
#### 3.1.2 Horizontal Elastomeric Attention Residual Unet-Based GAN (HEAR-GAN)  
Accurately detecting the edges in the images of a deformed color stripe pattern is difficult because of the effects of the complex structure of the object surface, as mentioned above. To improve this, the proposed method consists of two stages: (1) segmenting lines with a width of 3 pixels from the original images; (2) detecting the centerlines in the resulting images. With the idea of solving the task of line segmentation in an image based on image-to-image translation, our network consists of two parts: the generator and discriminator (Figure 4).  
The generator is a CNN consisting of encoding and decoding paths arranged in a W-shaped model. Among these, most of the plain neural blocks are replaced by residual blocks. The size input and output images of the network are 128 \(\times\) 128 \(\times\) 3. In the entire network, the batch normalization (BN) and leaky ReLU (LK) activation functions are applied to all blocks except the input and output layers. Filters with a kernel size of 4 \(\times\) 4 are used. The amount of filters is doubled after each block, which starts with f\({}_{\text{d}}\) = 32 filters in encoding paths and is reduced by half in decoding paths. In encoding paths, max-pooling is used to reduce the sample size, while up sampling layers are employed in decoding paths. In addition, dropout is applied to the layers that have a large number of parameters in each path to reduce overfitting. Lastly, a convolutional layer with a kernel size of 1 \(\times\) 1 with the sigmoid (SI) activation function is used for the last layer of the network. It is worth noting that the skip connections used in traditional Unet networks are all improved with attention gates.  
Figure 3: Illustration of the attention gate in the proposed network.  
In the discriminator, the input data are the image pairs from two sets. The first set includes the input images themselves and their real label. Therefore, the data from this set are called the real pair data. Meanwhile, the second set includes the input images and the label generated from the generator. The data from this set are called fake pair data. Similar to the generator, we use convolutional layers with leaky ReLU and batch normalization in each layer to encode the input data into a feature vector. Lastly, the sigmoid activation function is applied to the feature vector to obtain the binary output {0: fake pairs, 1: real pairs}.  
Compared to those in previous studies, the proposed network has the following characteristics: (1) All plain neural blocks, except for convolutional layers at bridges, are replaced by residual blocks; (2) the batch normalization and leaky ReLU activation functions are applied to all blocks; (3) skip connections are improved with attention gates; (4) the generator is a W-shaped network whose number of convolution layers is much larger than in previous GAN-based networks; (5) applying dropout on layers with a large number of parameters and max-pooling on encoding paths can help the model avoid overfitting.