<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>DREAM-CFA: joint learning of binary color filter array and demosaicing</title></titleStmt>
			<publicationStmt>
				<publisher>Journal of Electronic Imaging</publisher>
				<date>03/01/2025</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10667892</idno>
					<idno type="doi">10.1117/1.JEI.34.2.023063</idno>
					<title level='j'>Journal of Electronic Imaging</title>
<idno>1017-9909</idno>
<biblScope unit="volume">34</biblScope>
<biblScope unit="issue">02</biblScope>					

					<author>Cemre Omer Ayna</author><author>Bahadir Kursat Gunturk</author><author>Ali Cafer Gurbuz</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[Not Available]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">Introduction</head><p>Acquisition of a color image requires at least three color samples at each pixel; the colors often used in digital images are red (R), green (G), and blue (B) channels. Instead of three separate sensors to capture the color image completely, many digital imaging systems use a single monochromatic sensor covered with a color filter array (CFA). The CFA selectively allows only one of the colors to be measured at each pixel, creating a mosaic of different spectral bands depending on the pattern of the CFA. Estimating the missing color values at each pixel to reconstruct the full-color image is known as demosaicing.</p><p>Various CFA patterns have been employed in cameras. The Bayer filter 1 is one of the most commonly used CFA patterns. Several other hand-crafted CFAs are also present in specific camera models, such as Lukac filter, <ref type="bibr">2</ref> Fujifilm's X-Trans filter, <ref type="bibr">3</ref> and Compton's RGBW filter along with Kodak's RGBW filter variations. <ref type="bibr">4</ref> Example CFA patterns are illustrated in Fig. <ref type="figure">1</ref>.</p><p>One can ask what an optimal CFA pattern is for a specific task such as image reconstruction. Each of the existing patterns is hand-crafted with different considerations. For example, Bayer dedicates more pixels to the green band because of the higher sensitivity of the human eye to that band. However, such a pattern does not guarantee a better reconstruction performance, hence sub-optimal for demosaicing.</p><p>The current process with existing hand-crafted CFA patterns decouples the image acquisition and demosaicing processes. Over the years, many demosaicing techniques have been developed for fixed CFA patterns, such as Bayer, optimizing only the reconstruction process while keeping the acquisition model fixed. <ref type="bibr">5</ref> In addition to earlier interpolation-based techniques, recent deep learning (DL)-based demosaicing models <ref type="bibr">[6]</ref><ref type="bibr">[7]</ref><ref type="bibr">[8]</ref><ref type="bibr">[9]</ref><ref type="bibr">[10]</ref> learn to map the fixed CFA samples into the full-color image, fundamentally learning and optimizing the demosaicing process for a given fixed CFA pattern. Some studies also design a CFA for a given specific demosaicing technique. <ref type="bibr">11</ref> However, to design an optimal CFA pattern for the demosaicing process, both should be tuned jointly.</p><p>In this paper, we propose a joint DL architecture that simultaneously learns a CFA pattern and a demosaicing network by minimizing the reconstruction loss. The proposed joint framework comprises two modules; the head CFA module learns a constrained binary CFA, and the tail module reconstructs the color image from the filtered image mosaic. This joint learning approach enforces the learned binary CFA to be close to optimal for image demosaicing. The proposed method adapts hard thresholding as a band selection operation in the CFA learning module modified to be compatible with stochastic gradient descent. The CFAs learned with this method can be used in camera sensor arrays without impracticality concerns because selecting only one color channel is enforced for each pixel. Our results indicate that CFAs learned with this approach provide a higher reconstruction performance than the hand-crafted filters and the alternative learned binary filters.</p><p>With respect to the proposed joint deep reconstruction and efficient color filter array measurement learning concept, we name the proposed architecture DREAM-CFA. The main contributions of the proposed approach are as follows:</p><p>&#8226; This paper presents a method for joint color filtering and demosaicing that incorporates a novel binary CFA learning mechanism along with a new demosaicing architecture. <ref type="bibr">&#8226;</ref> The proposed CFA learning method is adaptable to different joint DL architectures, enabling it to learn optimal CFAs tailored for different objectives and tasks, such as reconstruction or classification. &#8226; In contrast to most existing methods, DREAM-CFA learns a binary CFA, assigning only one color channel to each pixel. This characteristic allows the learned CFA to be implemented in commercial digital cameras easily. &#8226; This study includes a comprehensive evaluation and analysis of various parameters, including filter size, color configuration, and training data size, and provides insights into the unique features of DREAM-CFA.</p><p>The rest of the paper follows this structure; Sec. 2 provides an overview of the available literature on the machine learning-based CFA design. Section 3 details the proposed CFA learning and demosaicing method, including the training and evaluation procedures. Section 4 outlines the dataset, training process, and evaluation metrics. Section 5 presents results and performance comparisons with existing approaches. Section 6 discusses the proposed approach and achieved results, addresses the study's shortcomings, and outlines the potential road map for future work. Finally, conclusions are drawn in Sec. 7.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">Background</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.1">Machine Learning in CFA Design</head><p>Utilizing machine learning to simultaneously solve the CFA learning and demosaicing tasks has recently appeared as a promising solution for optimal CFA design. One of the earlier works in the area is by Henz et al., <ref type="bibr">12</ref> where authors introduce an autoencoder architecture as a joint filteringdemosaicing pipeline. The encoder for learning CFA includes a 3D tensor with weights for available color channels (red, green, and blue) plus bias values. These weights linearly combine the available color intensities of the image as measurement at each pixel via matrix multiplication. This process is illustrated in Fig. <ref type="figure">2(a)</ref>. A convolutional neural network (CNN) is used as the demosaicing model in the joint architecture. The CFAs learned in the paper <ref type="bibr">12</ref> are similar to random measurement matrices in sparse reconstruction, which utilizes linear measurements. In the study proposed by Li et al., <ref type="bibr">11</ref> a sparsity-based CFA design algorithm represents CFAs as overcomplete dictionaries that sample an original image and find the set of dictionary values that minimize the mutual coherence. The CFA learning scheme in Ref. 11 corresponds to the one in Ref. 12 without the bias term. Although linear combination operation is differentiable and weights can be learned in a neural network architecture through backpropagation in both Refs. 11 and 12, the learned CFA results in a full measurement matrix that is practically unfeasible in actual digital camera hardware. However, in physical cameras, a single color filter is used to acquire each pixel data.</p><p>Similar to our goal of learning binary CFAs, the work by Chakrabarti <ref type="bibr">13</ref> uses soft thresholding by applying the softmax function with a temperature coefficient on a set of weights for each color channel per pixel to create a differentiable binary CFA learning network. The modeled measurement process in Ref. 13 is illustrated in Fig. <ref type="figure">2(b</ref>). The temperature coefficient is initialized as a small value. As training progresses, the value grows to converge the elements of the output vector to a binary value of 0 or 1. A recent study <ref type="bibr">14</ref> employs the same CFA learning scheme as in Ref. 13  but adopts a different demosacing architecture. Several regularization-enforced binary-coded aperture learning mechanisms are yet to be adapted to color filter selection. <ref type="bibr">15,</ref><ref type="bibr">16</ref> We have implemented both Henz's "linear filter" learning approach 12 and Chakrabarti's "weighted softmax" approach <ref type="bibr">13</ref> with the proposed learning scheme for comparisons.</p><p>Fig. <ref type="figure">2</ref> Visualization of the CFA learning methods used in this study for comparison. (a) Linear. <ref type="bibr">12</ref> (b) Weighted softmax. <ref type="bibr">13</ref> Figures show the RGBW configuration.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2">DL-Based Demosaicing</head><p>There is a plethora of demosaicing algorithms designed to work with different CFA filters. Although there is a huge literature on classical demosaicing approaches with interpolation, heuristics, or statistical models, <ref type="bibr">5</ref> here, we will focus on state-of-the-art DL-based demosaicing techniques. The demosaicing problem is an underdetermined reconstruction problem, <ref type="bibr">17</ref> and this fact is exploited heavily by the sparse representation-based demosaicing algorithms that employ dictionary search. <ref type="bibr">18,</ref><ref type="bibr">19</ref> For the same reason, the available DL-based demosaicing models share similarities with the DL-based image reconstruction and super-resolution models. We summarize three state-of-the-art DL-based demosaicing models here and compare the proposed model for evaluation with each of the existing demosaicing models. The reason for selecting these studies is that similar to our proposed framework, all selected models are used alongside a CFA learning algorithm in their respective studies.</p><p>The demosaicing model used in the study <ref type="bibr">12</ref> utilizes a CNN architecture. The input to the demosaic is a feature map of size N &#215; N &#215; &#240;2C &#254; 1&#222;, which N represents the size of the image patch and C is the number of submosaics interpolated with k-neighboring kernel. The rest of the demosaicing model is a fully convolutional network with 12 layers each employing 3 &#215; 3 kernels. The first six layers utilize 64 kernels, whereas the final six layers use 128 kernels. At the end of the network, the raw camera sensor data are concatenated with the output from the final convolutional layer. This combined tensor is then passed through one final convolutional layer to produce the reconstructed full-image patch.</p><p>The second demosaicing architecture is adapted from the weighted softmax model in the study. <ref type="bibr">13</ref> For a N &#215; N image patch, the model takes a 3N &#215; 3N &#215; 1 raw camera measurement as the input including the patch and its surroundings. The output is a reconstructed N &#215; N &#215; C full-color image. Surrounding patches are used to enhance reconstruction quality and reduce artifacts. This architecture has two parallel branches. The first branch, focused on extracting color information, includes a fully connected (FC) layer followed by reshaping. The second branch is an encoder with convolutional layers and an FC layer that captures spatial features independent of color.</p><p>The third demosaicing architecture is from Ref. 7, which processes raw camera data through two modules to reconstruct low-frequency color (chrominance) and high-frequency shapes (luminance). The luminance network, responsible for learning grayscale information such as edges and patterns, consists of a single hidden convolutional layer and an output layer, both using 3 &#215; 3 filters with 64 filters for the hidden layer and one for the output. The chrominance network is an autoencoder, and it produces a full-color patch. Because the original architecture was unspecified, we used three convolutional layers with 64, 128, and 256 filters (3 &#215; 3) and 2 &#215; 2 strides, followed by three deconvolutional layers to recover the shape. The outputs from both networks are summed to create the final reconstructed image.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">Proposed Method</head><p>The proposed DREAM-CFA architecture for learning a binary CFA along with a demosaicing model is an extension of the study presented in our previous paper. <ref type="bibr">20</ref> This section explains the details of the binary CFA learning algorithm, the architecture of the proposed demosaicing model, and the use of both modules in a joint framework.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1">Joint Binary CFA Learning and Demosaicing Architecture</head><p>The full proposed framework is a combination of the binary CFA learning module detailed in Sec. 3.2 and the demosaicing model based on image reconstruction networks described in Sec. 3.3. Figure <ref type="figure">3</ref> shows a visual representation of the framework in forward propagation.</p><p>During training, the model takes a 3N &#215; 3N &#215; C image patch x as input and returns a reconstruction of the image patch x as output. The first module of the model is the color filtering module, which acts as a simulated color filter and returns an output y corresponding to raw camera sensor observations. Then, y is passed into the demosaicing module for the reconstruction of the full-color image. The proxy image x&#240;0&#222; returned by the first convolution operation of the demosaicing module is refined by consecutive refinement submodules, which are detailed in Sec. 3.3. The complete architecture is learned jointly by minimizing a weighted mean square error (MSE) loss between reconstructed and input color images. The main consideration in this framework is guaranteeing differentiability in every step to make training by backpropagation possible. This is a critical problem specifically in the color filtering module as it will be detailed in the next section.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2">Binary CFA Learning Module with Hard Thresholding</head><p>The problem of adapting the binary selection operation in NN arises from the nondifferentiability of the thresholding function. A potential solution is the straight-through estimator (STE). STE is gradient estimation for functions without differentials in the interested parameter points. <ref type="bibr">21</ref> Assigning an STE to a non-differentiable function begins with observing the function's behavior in the concerned domain, then looking for a set of potential functions that behave similarly to the actual function and are differentiable in that domain. Using STE in this problem is inspired by Ref. 22. In the CFA learning task, the binary selection operation is redefined as a process of hard thresholding on the weights of the i'th pixel w i &#188; &#189;w i;R ; w i;G ; w i;B ; w i;W T , where the largest weight value &#949; &#188; max&#240;w i &#222; is selected as the threshold value. A normalization step follows, where the hard thresholding output is multiplied by 1&#8725; max&#240;w i &#222; to create a binary filter that selects the channel for the i'th pixel.</p><p>During backpropagation, using hard thresholding directly would carry the gradient only for weights above the threshold, preventing updates to unselected channels and limiting the learning of CFAs. To address this, we apply STE approximation using the identity function, for the identity function behaves such as hard thresholding in the forward pass. Taking the identity function's gradient as the gradient of hard thresholding allows gradient flow during backpropagation. This ensures the update of all color channel weights during training. The forward and backward operations are illustrated in Fig. <ref type="figure">4</ref>.</p><p>With the differentiable implementation of hard thresholding in place, we now consider the task of sampling an image block of size N &#215; N with C color channels. The goal of the learnable binary CFA module is to select one color channel per pixel, discarding the others, resulting in N &#215; N measurements. The CFA learning module begins by initializing weights of size N &#215; N &#215; C from a uniform random distribution in the range [0, 1]. For each pixel, the highest weight is selected as the threshold. The pixel weights then undergo thresholding followed by normalization to determine the chosen channel in the forward pass. Because backpropagation utilizes the gradient of the identity function, which is 1, as a result, the proposed CFA learning module is lightweight in both computational resources and time during both training and evaluation. The output of this module will be the input to the demosaicing module, which is detailed in the next subsection.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.3">Demosaicing Module</head><p>Demosaicing is an underdetermined reconstruction problem. There have been several DL-based architectures proposed to reconstruct the underlying signal from a smaller number of measurements than the signal dimension. <ref type="bibr">[23]</ref><ref type="bibr">[24]</ref><ref type="bibr">[25]</ref> Inspired by classical sparse reconstruction and existing DLbased reconstruction models, we introduce a multi-stage demosaicing model that first generates a proxy image and refines it through multiple convolutional submodules, each contributing to a cumulative loss function as illustrated in Fig. <ref type="figure">5</ref>. The demosaicing module receives the 3 N &#215; 3 N &#215; C-size output of the CFA learning module representing the sparse raw camera returns and generates a 3N &#215; 3N &#215; 3-size full-color RGB image. The central N &#215; N region contains the target reconstruction, with larger patches used to mitigate edge artifacts, as was also used in the study. <ref type="bibr">13</ref> The model begins by converting the raw camera data into a proxy image by applying a convolutional layer with 3 kernels of 9 &#215; 9 size with padding for equal-sized output and no bias. The proxy image is then pushed into three consecutive refinement submodules, each consisting of three convolutional layers followed by ReLU activation functions. In each refinement module, the first layer has 128 kernels of 7 &#215; 7 size, the second layer has 64 kernels of 5 &#215; 5 size, and the third layer has 3 kernels of 3 &#215; 3 size. All layers apply padding to preserve the image size and include l 2 regularization. Skip connections are introduced between the refinement blocks to facilitate gradient flow. The model's final layer is another convolutional layer with 3 kernels of 3 &#215; 3 size and a ReLU activation. The outputs from all refinement blocks along with the final layer contribute to the total loss function, which is defined as the sum of mean squared error (MSE) losses across all training patches and refinement block outputs. Unlike most DL approaches that use only the final output for computing the loss, the combined loss of the final layer and the refinement blocks enforces each refinement block to generate outputs closer to the label image, leading to a more accurate final reconstruction. The final loss function of the architecture can be defined in Eq. ( <ref type="formula">1</ref>) Ayna, Gunturk, and Gurbuz: DREAM-CFA: joint learning of binary color filter array. . . Journal of Electronic Imaging 023063-6 Mar&#8725;Apr 2025 &#8226; Vol. 34(2) E Q -T A R G E T ; t e m p : i n t r a l i n k -; e 0 0 1 ; 1 1 7 ; 4 7 1</p><p>where x i represents the i'th training sample and x&#240;n&#222; i is the output of the n'th refinement module and x&#240;4&#222;</p><p>i denoting the final reconstructed image as shown in Fig. <ref type="figure">5</ref>. In our evaluations, we tested the proposed demosaicing module alongside three existing DL-based demosaicing models described in Sec. 2.2, within the joint CFA learning and demosaicing framework by replacing only the demosaicing networks. In this way, we can compare the overall performance due to demosaicing networks while demonstrating that the joint framework is compatible with various demosaicing models. Furthermore, any future improvements in DL-based demosaicing models can be seamlessly integrated with the binary CFA learning module to enhance both CFA learning and reconstruction quality.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">Dataset and Training</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1">Dataset and Setup</head><p>The training dataset used in this study is created from the training and validation images of the BSDS500 dataset <ref type="bibr">26</ref> totaling 400 images. BSDS500 is a collection of 481 &#215; 321 px-sized RGB images originally published for segmentation benchmarks but is commonly used as training data in other computer vision tasks, including image demosaicing. The training image patches are 3N &#215; 3N non-overlapping blocks, yielding a total of 881,600 training patches for the case of N &#188; 8 patch size.</p><p>We used two different test image datasets. The first dataset is composed of 20 images selected from BSDS500's test images chosen based on their complexity in contour and texture. The second test dataset used in this study is the Kodak dataset, <ref type="bibr">27</ref> which is composed of 24 different images with 768 &#215; 512 sizes. Performance metrics of individual datasets were recorded and compared separately.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2">Training</head><p>Training and evaluation of all models were conducted with an Nvidia A6000 GPU. The programming language selected for the implementation of the source code is Python 3.10 with TensorFlow library and Keras module. The loss function used in all demosaicing models is the mean squared error (MSE) loss as defined in Eq. ( <ref type="formula">1</ref>). The adaptive movement estimation (ADAM) optimizer is used during backpropagation <ref type="bibr">28</ref> with decay rates (&#946; 1 and &#946; 2 ) and division constant (&#949;) values of ADAM optimizer were selected as 0.9, 0.999, and 10 -7 , respectively. The learning rate follows an exponential decay from 10 -4 to 10 -5 .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.3">Evaluation</head><p>The performance metrics used in the performance evaluation of the proposed approach are the peak signal-to-noise ratio (PSNR) and the Structural Similarity Index Metric (SSIM). These metrics are profound in the digital image processing literature for image reconstruction performance evaluations. PSNR is used to observe the distortion of the reconstruction compared with the original signal in terms of decibel units, and a higher PSNR value indicates a better reconstruction performance. PSNR can be computed as in Eq. ( <ref type="formula">2</ref>) where the mean squared error (MSE) is computed over the whole reconstructed image E Q -T A R G E T ; t e m p : i n t r a l i n k -; e 0 0 2 ; 1 1 4 ; 5 9 1 PSNR &#188; 10 log 10 &#240;255 2 &#8725;MSE&#222;:</p><p>(2)</p><p>SSIM is used to compare a reconstruction with its ground truth signal in terms of localized similarity. An SSIM score takes a value between 0 and 1, with higher values indicating a closer resemblance between the reconstruction and the original image. Calculation of SSIM involves the means and variances of the original (&#956; x , &#963; 2</p><p>x ) and the reconstructed (&#956; x, &#963; 2 x) images, along with the covariance of both (&#963; xx ). The division stabilizer constants c 1 and c 2 in the SSIM definition in Eq. ( <ref type="formula">3</ref>) are chosen as &#240;255 &#195; 0.01&#222; 2 and &#240;255 &#195; 0.03&#222; <ref type="bibr">2</ref> , respectively E Q -T A R G E T ; t e m p : i n t r a l i n k -; e 0 0 3 ; 1 1 4 ; 4 9 2</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">Results</head><p>In this study, we undertook a comprehensive examination of the proposed joint binary CFA and demosaicing model, DREAM-CFA, to evaluate and understand its performance compared with existing techniques. First, the performance of the proposed demosaicing network is compared with alternative approaches. The effect of CFA size on final reconstruction quality is assessed, and the performance of learned CFAs is benchmarked against popular hand-crafted fixed CFAs such as Bayer and Lukac, as well as existing alternative CFA learning studies. The convergence of the method, the evolution of learned CFAs during training, and the effect of training data size on the learned CFAs are analyzed. The findings of these analyses are detailed and discussed in this section, providing valuable insights crucial for the development of robust CFA learning and demosaicing models.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.1">Comparison of Demosaicing Models</head><p>In the first analysis, we compare the performance of the proposed demosaicing module in our joint framework against existing demosaicing models 7,12,13 outlined in Sec. 2.2. The color filtering module architecture is kept the same in all tested models, whereas the aforementioned demosaicing models are tested, resulting in eight different joint models trained and tested across RGB and RGBW configurations with the only change being in the demosaicer. The average PSNR and SSIM metrics for Kodak and BSDS500 test datasets are provided in Table <ref type="table">1</ref>, with separate results for RGB and RGBW configurations. The proposed demosaicing architecture achieves the highest PSNR and SSIM values for both RGB and RGBW cases. Specifically, it provides 2.23 dB and 1.81 dB higher PSNR in the RGB case, and 1.25 dB and 0.62 dB higher PSNR in the RGBW case compared with the second highest demosaicing model <ref type="bibr">12</ref> for Kodak and BSDS500 test datasets, respectively. For the SSIM metric, the proposed model and the model in the study <ref type="bibr">12</ref> perform better than the other two, with the proposed demosaicing model leading in most of the test cases.</p><p>Categorically, we observe that the models with feed-forward fully convolutional architectures (i.e., the proposed DREAM-CFA model and the model in Ref. 12) perform comparably better than models with parallel architectures separating the reconstruction of color and texture information such as works. <ref type="bibr">7,</ref><ref type="bibr">13</ref> Unlike the model, <ref type="bibr">12</ref> which uses hand-crafted kernels for an initial reconstruction, the proposed DREAM-CFA model employs a dedicated convolutional layer to learn to reconstruct a pseudo-image and incorporates skip connections and combined loss function from refinement modules to enhance the final reconstruction quality. Given the superior performance of the proposed demosaicing network, the rest of the evaluation scenarios will use the proposed demosaicing model in the joint architecture along with the CFA learning module.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2">Analysis on the CFA Size</head><p>In the second analysis, we investigate the effect of the CFA size on reconstruction performance. Four different CFA sizes (4 &#215; 4, 8 &#215; 8, 12 &#215; 12, and 16 &#215; 16) have been tested with the proposed joint model under both RGB and RGBW configurations. The achieved average PSNR and SSIM metrics across test datasets are presented in Table 2 for varying CFA sizes, in separate tables for RGB and RGBW. Our first observation from Table <ref type="table">2</ref> is that the highest PSNR and SSIM performance is achieved for 8 &#215; 8 size CFA in both RGB and RGBW color configurations. Using smaller or larger CFA sizes than 8 &#215; 8 negatively impacts the final reconstruction quality. In addition, higher PSNR and SSIM values are achieved for the RGBW case, indicating the inclusion of a luminance channel enhances the final performance.</p><p>Figure <ref type="figure">6</ref> illustrates the learned CFAs for each size for both RGB and RGBW configurations. Although learned filters do not exactly match any existing fixed CFA pattern, they seem to show some level of regularity in sampling a color channel. One observation is that the learned CFAs seem to prioritize the blue color over the others followed by red for RGB and luminance for RGBW. This is an interesting contrast with hand-crafted CFAs such as Bayer and Lukac where the green channel is prioritized with the assumption that the human eye is more sensitive to green channel information. Although the model's preference for blue and white channels is a result of the learning process over minimization of the defined loss function, the result might be related to the training dataset and understanding why DL models make these choices, dependencies on data are important for future research. It is also worth noting that the CFAs learned here are specific to the image reconstruction task. Using the same CFA learning module with a DNN model for a different objective may result in different color channel prioritization.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.3">Comparison of Learned CFAs with Hand-Crafted CFAs</head><p>To assess the performance of learned CFAs against commonly used fixed CFAs, we compare the reconstruction quality of CFAs learned by the DREAM-CFA model with fixed CFA patterns. All compared CFAs use the same proposed demosaicing network. For fixed CFAs, two RGB (Bayer and Lukac) and two RGBW (RGBW and CFZ) filters, shown in Fig. <ref type="figure">1</ref>, were selected. For each fixed CFA, training image patches are filtered with the respective filter beforehand and the demosaicing model is trained over the filtered training dataset separately for each CFA type. All cases are evaluated with 8 &#215; 8 CFA size. The achieved average PSNR and SSIM metrics over the two test datasets are provided in Table <ref type="table">3</ref>.</p><p>The results show that the learned CFA using the proposed model shows the highest reconstruction performance in both RGB and RGBW configurations for both test datasets compared with all fixed CFA patterns. Because the demosaicing network architecture is the same and is separately trained for each CFA, this analysis highlights that the jointly learning the CFA and the demosaicer as proposed in the DREAM-CFA model outperforms the hand-crafted CFAs in reconstruction quality. This underscores the advantage of joint learning of CFA and demosaicer in a single training pipeline exploiting the features of the training data for the enhanced reconstruction compared with a general work-for-all type fixed CFAs. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.4">Comparison with Alternative CFA Learning Methods</head><p>In this analysis, we compare the performance of the DREAM-CFA model with the state-of-theart DL-based joint CFA learning and demosaicing approaches <ref type="bibr">12,</ref><ref type="bibr">13</ref> summarized in Sec. 2.1. The  linear filter approach in the paper <ref type="bibr">12</ref> learns unconstrained linear weights for each pixel, unlike the DREAM-CFA or weighted softmax model, <ref type="bibr">13</ref> which constrain the solution space to binary weights or single-channel selection per pixel. Although learning unconstrained linear weights should theoretically offer better performance due to a broader optimization space, we compared all three approaches over the same training and test datasets. Each method was trained and tested as outlined in their respective studies. Table <ref type="table">4</ref> presents the PSNR and SSIM results for both constrained and unconstrained methods across all test configurations. The unconstrained linear CFA outperforms the constrained binary CFAs across all metrics in both RGB and RGBW configurations. The linear filter-based model <ref type="bibr">12</ref> was expected to outperform due to its larger optimization space, as it is not restricted to selecting a single color channel per pixel. If it is possible to practically construct a camera that can acquire measurements as different linear-weighted combinations of each color channel at each pixel, then the linear filter <ref type="bibr">12</ref> would be optimal. However, for most practical cameras, which are constrained to observe only one of the color channels for each pixel at a time, we can compare the performance of the proposed DREAM-CFA and weighted softmax <ref type="bibr">13</ref> as shown in the constrained column of Table <ref type="table">4</ref>. The results show that DREAM-CFA outperforms weighted softmax by 1.42 dB in RGB and 1.48 dB in RGBW cases, along with higher SSIM scores for both test datasets.</p><p>We illustrated one example image from Kodak dataset in Fig. <ref type="figure">7</ref> with reconstructions to visualize the performance of the DREAM-CFA compared to the alternatives. A zoomed section of the reconstruction with Bayer (b), Weighted SoftMax (c), and the proposed CFA (d) are provided in the figure. The patch from reconstruction with Bayer includes several blue hues in the image, while the patch reconstructed with Weighted SoftMax has serious artifacts in the blurred area. Meanwhile, the proposed DREAM-CFA manages to provide a clearer reconstruction.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.5">Analysis on the Learned CFA in Training</head><p>As we establish the high performance of the proposed DREAM-CFA model, in this analysis, we start looking into the behavior of the model during the training process. We observe the model's level of learning in training by comparing the performance metrics, reconstruction qualities, and learned filters at different epochs as the training progresses. For this, one sample of the proposed joint model was trained, and its weights were saved after epochs 1, 2, 4, 5, 10, 15, 20, and 50. These saved weights were used with the test dataset to evaluate the change in image reconstruction quality.    <ref type="table">5</ref> presents the mean and variance in PSNR and SSIM metrics over Kodak and BSDS500 test datasets. First of all, it can be observed that as the size of the training dataset increases, both the average PSNR and SSIM metrics improve. Because we were not able to train over 1 million image patches, important future work is to understand the required training image size for these models to converge. Another important observation is that the variance in the achieved performances decreases as models are trained over larger datasets. This shows that even though each training might end up with a different learned CFA and a demosaicing model, the achieved performances with these models become more consistent exhibiting lower variance with larger training datasets.</p><p>One example of learned CFA for each training dataset size is shown in Fig. <ref type="figure">11</ref>. It can be seen that the learned CFA over the largest training dataset shows more checker-like patterns, sampling  each color channel more uniformly. Because each independent training case might result in different CFAs, it is not proper to state that only one optimal CFA exists. Each of our independent training cases resulted in different CFAs and demosaicing models. However, our observation is that the variance on all learned CFAs as well as the achieved performance in terms of PSNR and SSIM metrics gets lower as training datasets are larger. Due to limited computational resources, we can train our models over a maximum of 1 million image patches. However, training the proposed architecture over much larger datasets would be informative on whether the observed trends in performance increases and lower variances continue for much larger dataset cases.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.7">Analysis on Loss Function</head><p>The loss function for the proposed architecture is formulated by summing the MSE loss of each reconstruction submodule. Alternative loss functions commonly used in image reconstruction problems include mean absolute error (MAE) and root mean squared error (RMSE). To evaluate the impact of different loss functions, we trained two additional DREAM-CFA models, replacing the MSE loss with MAE and RMSE, while keeping the training scheme unchanged. Table <ref type="table">6</ref> presents the PSNR and SSIM metrics for three different loss functions in RGB and RGBW cases. The results show that MSE and RMSE yield comparable values for both metrics, while MAE lags behind. However, examining the CFAs learned by the compared models in Fig. <ref type="figure">12</ref>, we can see that all three loss functions return patterns with roughly similar behavior  as discussed in Sec. 5.5. The reason for lower reconstruction performance with MAE might be explained by its larger gradients, which could hinder training in the later epochs. Nevertheless, the resulting model still performs as an effective filter/demosaicer and manages to learn a similar CFA pattern to the other two cases.</p><p>6 Discussion and Future Work</p><p>In this paper, we presented a joint architecture that learns a binary color filter array along with a demosaicing deep neural network. Our results show that the learned CFAs with the proposed architecture outperform traditional fixed CFAs such as Bayer or learned-CFA models such as weighted softmax. <ref type="bibr">13</ref> Because the proposed approach learns to select a single color channel at each pixel, learned CFAs are practical and physically implementable in digital cameras.</p><p>The results show that the proposed hard thresholding-based DREAM-CFA architecture can learn CFAs that outperform the weighted-softmax-based method <ref type="bibr">13</ref> that can also learn binary CFAs. We hypothesize two main reasons for enhanced performance due to the proposed color filtering module. The primary reason is that while weighted softmax still returns non-zero weight values that cause the discarded color channels to still contribute to the demosaicing during training (which is true, especially in earlier epochs), our architecture directly provides binary values, completely discarding the unused color channels. This enables the subsequent demosaicing module to train more effectively without any unwanted information. The second reason is the faster convergence due to the easier gradient calculation at the color filtering submodule.</p><p>One important aspect of CFA learning is the size of the learned CFA. The analysis in Sec. 5.2 revealed that an optimal CFA size of 8 &#215; 8 yields the best reconstruction performance, with larger sizes degrading the quality. Although this could mean larger and more complex CFA patterns might not be necessary for DL-based demosaicing because commonly used fixed CFA patterns are also smaller or similar sizes, it might also depend on data and training set size. Future work can confirm this result over larger training sets.</p><p>The size of the training dataset and its effect on the consistency of learned CFA and demosaicing performance is another important aspect we analyzed in the paper. The results in Sec. 5.5 show that larger training datasets improve both the average performance and the consistency of the reconstruction performance and learned CFAs, decreasing the variance both in the achieved PSNR values and the learned CFAs suggesting that training on even bigger datasets could yield more generalized CFAs and possibly enhanced reconstruction quality.</p><p>Another interesting observation was the bias toward the blue channel in the learned CFAs, contrasting with traditional filters that prioritize green. This might be due to effects such as Rayleigh scattering, <ref type="bibr">29</ref> which impacts the blue channel more strongly or it might be due to the training data and size, but further investigation is needed to analyze this observation. Additional future work could include an analysis of the effect of noise and cross-talk, and potential hardware implementation of the proposed deep neural network for computational analysis and a more practical implementation.</p><p>The task awareness of the learned CFA is another important feature in the proposed framework. In the current architecture, the learned CFA is jointly optimized for the task of the second module, which, in this study, is demosaicing. The flexibility of the proposed framework allows using a neural network designed for a different task as the second model. This enables the color filtering module to learn an optimal CFA for that particular task, opening the door for task-aware CFA learning in future applications.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7">Conclusion</head><p>This study presents a binary CFA learning module based on hard thresholding with a deep learning-based demosaicing network in a joint architecture. Although a measurement learning approach based on gradient adaptation is developed for binary CFA learning, a demosaicing architecture based on original DL-based image reconstruction models is jointly learned. The proposed model is trained and tested over Kodak and BSDS500 datasets. Because the proposed approach learns to select a single color channel at each pixel, the learned CFA is easily adaptable to modern commercial cameras. CFAs with a given color configuration learned using the</p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_0"><p>Journal of Electronic Imaging 023063-2 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_1"><p>Journal of Electronic Imaging 023063-3 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_2"><p>Journal of Electronic Imaging 023063-4 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_3"><p>Journal of Electronic Imaging 023063-5 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_4"><p>Journal of Electronic Imaging 023063-7 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_5"><p>Journal of Electronic Imaging 023063-8 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_6"><p>Journal of Electronic Imaging 023063-9 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_7"><p>Journal of Electronic Imaging 023063-10 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_8"><p>Journal of Electronic Imaging 023063-11 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_9"><p>Journal of Electronic Imaging 023063-12 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_10"><p>Journal of Electronic Imaging 023063-13 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_11"><p>Journal of Electronic Imaging 023063-14 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_12"><p>Journal of Electronic Imaging 023063-15 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_13"><p>Journal of Electronic Imaging 023063-16 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_14"><p>Journal of Electronic Imaging 023063-18 Mar&#8725;Apr 2025 &#8226; Vol. 34(2)</p></note>
		</body>
		</text>
</TEI>
