# Diffusion-Denoising Process with Gated U-Net for High-Quality Document Binarization
## 3 Method
### Document Diffusion-Denoising Network
#### 3.3.2 Diffusion-Denoising Process  
We use a diffusion-denoising process to create high-quality, clean, binarized document images. Initially, within the diffusion process, Gaussian noise is injected into the image's latent vector over multiple time steps to form a complete Gaussian noise vector. Subsequently, in the denoising process, the model undergoes training to progressively eliminate Gaussian noise from the complete Gaussian noise vector, ultimately producing a clean, binarized document image. Therefore, during the document binarization inference, the result is exclusively generated through the trained denoising process, as shown in Figure 5.  
Figure 4: Exemplary images of a latent vector compressed through an autoencoder and image vector in the pixel space, showing the change in the vector in each space according to the time step.  
Figure 5: Illustration of the architecture of the denoising process. Our denoising network consists of a gated U-Net, which is a fully gated convolution. The denoising process at a specific time step passes through a gated U-Net by concatenating the latent vector of the degraded document with the noise vector of the previous time step.  
The iterative diffusion-denoising process of the proposed model depends on the diffusion model [21,33] and proceeds according to Equations (1) and (2) in the latent space to enhance the computational cost and feature control ability, as described in Section 3.3.1. The diffusion process of the network generates the noise vector \(z_{t}\) by gradually adding the Gaussian noise \(\epsilon\) to the latent vector \(z=E(x)\) generated by the encoder. Then, in the denoising process, \(z_{0}\) is restored by gradually removing noise from the noise vector \(z_{t}\) through the gated U-Net architecture, which is known as the denoising network. To achieve this, the training process involves computing the difference in the distribution of the outputs from each process at the same time step. The gated U-Net architecture and its corresponding processes are illustrated in Figure 5.  
However, in the case of the unconditional diffusion-denoising process, it is trained using data that solely comprise binarized document images. As a result, it can generate a document image following a distribution similar to that of a binarized document image; however, it cannot restore a degraded document image to a clean, binarized state. For document binarization, the model must generate not only a binarized document image but also a clean, binarized document image when presented with a degraded document image. Hence, as illustrated in Figure 3, we configure the conditional diffusion-denoising process by adding degraded document images as a condition. The loss function for training the denoising network \(\epsilon_{\theta}\) with the condition added is as follows:  
\[L_{LDM}=\mathbb{E}_{E(x),\epsilon,\epsilon}\Big{[}\|\epsilon-\epsilon_{\theta }(z_{t},t,E(c))\|_{2}^{2}\Big{]} \tag{4}\]  
In the document binarization process, during the denoising step, the latent vector \(E(c)\) of the degraded document image \(c\) generated by the encoder is concatenated channel-wise as a condition. Additionally, we implement skip connections to mitigate information loss. When sampling a cleaned, binarized document image, the latent vector of the degraded document image is combined with a random noise vector. This noise is progressively removed through an iteratively trained denoising network, corresponding to the number of time steps.