# GAN-Based Map Generation Technique of Aerial Image Using Residual Blocks and Canny Edge Detector
## 3 Map Generation from Aerial Image
Although the Residual Block helps preserve the features of aerial photographs, this paper employs the Canny edge detector to ensure the edges in the real map photos are considered during training. The Canny edge detector identifies edges in images through the following process. First, a 5 \(\times\) 5 Gaussian filter is used for smoothing to remove noise. Then, a 3 \(\times\) 3 Sobel operator calculates the brightness gradient in the \(x\) and \(y\) directions. These gradients indicate the direction of the most significant brightness change and are perpendicular to the edges. Non-Maximum Suppression is then applied to retain only the maximum values, leaving precise edges. Finally, Hysteresis Thresholding is conducted. The thresholding uses two thresholds to distinguish strong edges from weak edges; strong edges that exceed the high threshold are considered definite edges. In contrast, weak edges between the low and high thresholds are only considered to be edges if they are connected to strong edges. The overall process of Canny edge detection remains unchanged; however, it can be observed that Non-Maximum Suppression has been streamlined through the utilization of convolution operations. The initial stage of the process involves applying a two-dimensional max pooling operation to each pixel in the magnitude matrix. This operation utilizes a 3 \(\times\) 3 kernel, a stride of 1, and a padding of 1, with the objective of identifying the maximum value present within each 3 \(\times\) 3 neighborhood. Subsequently, a Boolean mask is generated, wherein each element is set to True if it represents a local maximum within its 3 \(\times\) 3 neighborhood. Only the local maximum values are retained within the matrix through the utilization of this Boolean mask. Ultimately, the function returns the suppressed magnitude matrix. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Module** & **Block** & **Kernel Size** & **Stride** & **Padding** &
\begin{tabular}{c} **Output of Feature** \\ **Map** \\ \end{tabular} \\ \hline \multirow{4}{*}{Generator} & Down Block\({}^{\star}\) & 7 & 1 & Replication & (256, 256, 64) \\  & Down Block & 3 & 2 & Zero & (128, 128, 128) \\  & Down Block & 3 & 2 & Zero & (64, 64, 256) \\  & Residual Block (Repeat \(N\)) & 3 & 1 & Replication & (64, 64, 256) \\  & Up Block & 3 & 2 & Zero & (128, 128, 128) \\  & Up Block & 3 & 2 & Zero & (256, 256, 64) \\  & Up Block\({}^{\star}\) & 7 & 1 & Replication & (256, 256, 3) \\ \hline \multirow{3}{*}{Discriminator} & Convolution + Leaky ReLU & 1 & 1 & Valid & (256, 256, 64) \\  & Convolution + Leaky ReLU & 1 & 1 & Valid & (256, 256, 128) \\ \cline{1-1}  & Convolution + Sigmoid & 1 & 1 & Valid & (256, 256, 1) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Architectures of the network of generator and discriminator. The blocks marked with an asterisk (\({}^{\star}\)) have the same structure as the existing Down and Up blocks, but with minor differences in stride, kernel size, and padding. This paper uses the difference between \(C(G(a_{real})))\) and \(C(m_{real})\), computed by the Canny edge detector, as a loss function to minimize, aiming to generate accurate and high-quality map images. The optimal parameters for the two thresholds are determined through exploration in the paper. Unlike the traditional Non-Maximum Suppression process, this approach compares the original and convolution-processed images to retain only the parts of the original image with matching values. The loss function for training the proposed GAN network is defined as follows. First, the Adversarial Loss functions for the generator and discriminator are defined in Equations (1) and (2). The discriminator aims to classify \(m_{real}\) as real and \(G(a_{real}))\) as fake. Therefore, if all samples are correctly classified, Equation (1) evaluates to zero. However, Equation (2) works oppositely, where the generator aims to deceive the discriminator by classifying \(G(a_{real}))\) as real. It requires \(G(a_{real}))\) to be similar to \(m_{real}\) and generate realistic images.