# One-Step Enhancer: Deblurring and Denoising of OCT Images
## 3 Proposed Method
### Loss Function  
The overall loss function includes five subfunctions: domain adversarial loss (\(\mathbf{L}_{adv}\)), cycle consistency loss (\(\mathbf{L}_{cycle}\)), reconstruction loss (\(\mathbf{L}_{recon}\)), noise patch loss (\(\mathbf{L}_{noise}\)) and KL divergence loss (\(\mathbf{L}_{KL}\)). Their interconnections with the processing framework is illustrated in Figure 3.  
**(1) Domain adversarial loss: \(\mathbf{L}_{adv}\) pushes the discriminators to pick the best encoders and generators to minimize the adversarial loss functions, which include content information loss \(\mathbf{L}_{adv}^{c}\), blur feature loss \(\mathbf{L}_{adv}^{b}\), noise feature loss \(\mathbf{L}_{adv}^{n}\), and blur-noise feature loss \(\mathbf{L}_{adv}^{bn}\). The domain adversarial loss is defined as:**  
\[\mathbf{L}_{adv}=\arg\!\min_{E,G}\max(\mathbf{L}_{adv}^{c}+\mathbf{L}_{adv}^{b}+\mathbf{L}_{ adv}^{n}+\mathbf{L}_{adv}^{bn}) \tag{11}\]  
where \(E\) stands for the encoder, \(G\) for the generator, and \(D\) for the discriminator. The four adversarial loss functions are defined below, where \(Z_{b}\) and \(Z_{n}\) are real blurred and noisy images, and \(\mathbb{E}\) is the expectation operator. \[\mathbf{L}_{adv}^{c}=\mathbb{E}[\log D^{c}(Y)]+\mathbb{E}[1-\log D^{c}(X_{c})] \tag{12}\]  
\[\mathbf{L}_{adv}^{b}=\mathbb{E}[\log D^{b}(Z_{b})]+\mathbb{E}[1-\log D^{b}(Y_{b})] \tag{13}\]  
\[\mathbf{L}_{adv}^{n}=\mathbb{E}[\log D^{n}(Z_{n})]+\mathbb{E}[1-\log D^{n}(Y_{n})] \tag{14}\]  
\[\mathbf{L}_{adv}^{bn}=\mathbb{E}[\log D^{bn}(X)]+\mathbb{E}[1-\log D^{bn}(Y^{bn})] \tag{15}\]  
**(2) Cycle consistency loss: inspired by CycleGAN [20], cycle consistency loss is introduced to guarantee that the enhanced image \(X_{c}\) represents a proper reconstruction  
Figure 3: Diagramillustrating the inputs and outputs of loss functions. The inputs include \(\mathbf{X}\): original images, \(\mathbf{Y}\): clean images, \(\mathbf{Z}\): real blurred/noisy images. of the raw sample image, and that \(Y^{lm}\) can be translated back to the original clean image domain. The cycle consistency loss further limits the space of the generated samples and preserves the content of original images. \[ \begin{split} L_{cycle}=&\mathbb{E}[||X-X_{ cycle}||_{1}]\\ &+\mathbb{E}[||X-X_{cycle2}||_{1}]+\mathbb{E}[||Y-Y_{cycle}||_{1}] \end{split}  \tag{16}\]  
where \(||.||_{1}\) represents the \(l_{1}\)-norm. **(3) Reconstruction loss**: the reconstruction loss is applied to facilitate \(X=X_{r}\) and \(Y=Y_{r}\). Consequently, \(G^{c}\) and \(G^{lm}\) can reconstruct the inputs to generate a clean counterpart of X and a blur-noise counterpart of Y.  
\[\mathbf{L}_{recon}=\mathbb{E}[||X-X_{r}||_{1}]+\mathbb{E}[||Y-Y_{r}||_{1}] \tag{17}\]  
**(4) Noise patch loss**: to overcome the obstacle of multiple types of noise, we leverage noise patches from the background of raw images and use a discriminator \(D^{pm}\) to distinguish between real noise and generated noise as follows:  
\[\mathbf{L}_{noise}^{X}=\mathbb{E}[\log D^{pm}(N)]+\mathbb{E}[\log D^{pm}(X-X_{b})] \tag{18}\]  
\[\mathbf{L}_{noise}^{Y}=\mathbb{E}[\log D^{pm}(N)]+\mathbb{E}[\log D^{pm}(Y-Y_{b})] \tag{19}\]  
According to Equations (18) and (19), the noise patch loss is given by:  
\[\mathbf{L}_{noise}=\underset{E,G}{\text{argmin}}\ \underset{D}{\text{max}}(\mathbf{L}_{ noise}^{X}+\mathbf{L}_{noise}^{Y}) \tag{20}\]  
**(5) KL divergence loss**: to guarantee that the blur encoder \(E^{b}(X)\) only encodes blur components, \(Y_{b}\) is generated from \(E^{c}(Y)\) and \(E^{b}(X)\) in Equation (5). This discourages \(E^{b}(X)\) from encoding content information from X. Furthermore, KL divergence loss is used to regularize the blur feature distribution \(F_{b}=E^{b}(X)\) to bring it closer to a normal distribution \(p(F)\sim N(0,1)\).