# Data-Driven Convolutional Model for Digital Color Image Demosaicing
## 3 Methods
### Image Model  
As in [19], we define a color image \(I\) as a mapping function from discrete coordinate \((x,y)\) to a three-dimensional RGB color vector. \[I(x,y)=\{C_{r}(x,y),C_{g}(x,y),C_{b}(x,y)\} \tag{2}\]  
We can also define a suitable projection in the RGB space as a positive combination of color components. This projection allows us to express the original input three-dimensional image as the sum of a scalar channel and a vector of residuals. Formally,  
\[I(x,y)=\{C_{r}(x,y),C_{g}(x,y),C_{b}(x,y)\}=\Phi(x,y)+\{\Psi_{i}(x,y)\},i\in\{R,G,B\} \tag{3}\]  
where \(\Phi(x,y)\) is a scalar (one-dimensional) image and \(\{\Psi_{i}(x,y)\}=\{C_{i}(x,y)-\Phi(x,y)\}\) is a three-dimensional vector of residuals. If we project the image on to the vector \([1/3,1/3,1/3]\), the scalar image is effectively the Luminance channel (i.e., the pixel-wise mean among the color channels) and the residual vector is the Chrominance channel. Similarly, we can define the Bayer image as the input image spatially subsampled by specific masking function for each color channel. Formally,  
\[I_{Bayer}(x,y)=\{C_{r}(x,y)m_{R}(x,y),C_{g}(x,y)m_{G}(x,y),C_{b}(x,y)m_{B}(x,y)\} \tag{4}\]  
where \(m_{R}\), \(m_{G}\), and \(m_{B}\) are three masking cosine functions defined for each possible Bayer configuration. For the Bayer RGGB configuration, \(m_{R}\), \(m_{G}\), and \(m_{B}\) are defined as follows:  
\[m_{R}(x,y) =\frac{1}{4}(1+cos(\pi x))(1+cos(\pi y)) \tag{5}\] \[m_{G}(x,y) =\frac{1}{2}(1-cos(\pi x)cos(\pi y))\] \[m_{B}(x,y) =\frac{1}{4}(1+cos(\pi x+\pi))(1+cos(\pi y+\pi))\]  
For Bayer images, it is relevant to analyze their Fourier Transform as it provides useful information that can drive the reconstruction process. Given the Bayer image representation in (4), its Fourier transform can be defined as the convolution in the frequency domain of the Fourier transform for each color channel \(\hat{C}_{i}(u,v)\) and the Fourier transform of the sampling functions \(\hat{m}_{i}(u,v)\) (6). The Fourier transform of the Bayer image can thus be expressed as:  
\[\hat{I}_{Bayer}(u,v)=\sum_{i}\hat{C}_{i}(u,v)*\hat{m}_{i}(u,v) \tag{6}\]  
Since the sampling functions are based on cosine functions, their Fourier transform are Dirac delta functions localized at different positions in the frequency spectrum. Thus, as the convolution with a Dirac delta functions is a translation of the original signal in the frequency spectrum \(\hat{C}_{i}(u,v)*\delta(u0,v0)=\hat{C}_{i}(u-u_{0},v-v0)\), the sampling functions localize the Chrominance and Luminance of the input image in the frequency spectrum. By expansion of Equation (6), the Fourier transform of the spatially subsampled input image can be expressed as:  
\[\hat{I}_{Bayer}(u,v) =\sum_{i\in\{R,G,B\}}p_{i}\hat{C}_{i}(u,v) \tag{7}\] \[+\sum_{(u,v)\in\{(-1,-1),(1,-1),(1,1),(-1,1)\}}\frac{1}{8}(\hat{ C}_{R}(u,v)-\hat{C}_{B}(u,v))\] \[+\sum_{(u,v)\in\{(0,-1),(1,0),(0,1),(-1,0)\}}\frac{1}{16}(\hat{C}_ {R}(u,v)-2\hat{C}_{G}(u,v)+\hat{C}_{B}(u,v))\]As observed in [19], the Bayer sampling applied to the input image creates aliasing in nine distinct regions of the spectrum (see Figure 6). Most of the Luminance energy is concentrated in the central region, whereas the Chrominance energy is located at the borders. In Figure 6, the Fourier transform of the Bayer image is presented. From the image, nine regions can be identified where most of the energy is concentrated, these correspond to each of the members in (7). From the Fourier representation of the Bayer image, four categories of visual artifacts generated in the reconstruction process can be explained (i.e., blurring, grid effect, false color, and watercolor). Blurring can be generated if the estimation of the Luminance spectrum is too narrow, hence all the high frequency components of the input signal are suppressed. The grid effect artifact is due to selection of a wider band that might include Chrominance components in the Luminance signal.