# Retinex Based Image Enhancement via General Dictionary Convolutional Sparse Coding
## 3 Proposed Method
### Proposed Retinex Model
#### 3.3.1 Reflectance Function Sub-Problem  
From line 3 of Algorithm 1, the reflectance sub-problem can be written as  
\[\min_{r,d,z}E_{1}(r,d,z)=\frac{1}{2}||r-\sum_{k=1}^{K}d_{k}*z_{k}||_{2}^{2}+ \beta\sum_{k=1}^{K}||z_{k}||_{1}+\frac{\eta}{2}||l^{k}-s-r||_{2}^{2} \tag{10}\]  
here, the formula for finding the dictionary \(d_{k}\) and coefficient map \(z_{k}\) through CSC Equation (7) is as follows.  
\[\arg\min_{d,z}\ E_{1-CSC}(d,z)=\frac{1}{2}||r^{\prime}-d*Z^{\prime}||_{2}^{2}+ \beta||Z^{\prime}||_{1}+\text{ind}_{C}(d) \tag{11}\]  
where, \(r^{\prime}=[{r^{1}}^{T}\ \ldots\ {r^{W}}^{T}]^{T}\). Equation (11) can be solved using the consensus alternate direction method of multipliers (ADMM) [21; 22]. \(Z^{\prime}\) and \(r^{\prime}\) can be expressed in a small N blocks matrix \(Z^{\prime}=[Z_{1}\ \ldots\ Z_{N}]\), \(r^{\prime}=[r_{1}\ \ldots\ r_{N}]\). Here, \(r_{i}\) represents the \(i\) th data block along with its respective filters \(Z_{i}\). The filter \(d\) sub-problem through ADMM is as follows [21].  
Algorithm 2's calculation follows CSC's ADMM method [21]; however, in particular, we propose a new method to solve the least-squares problem in line 3. The least-squares solution in line 3 is as follows.  
\[d_{i}^{m+1}=(Z_{i}^{\dagger}Z_{i}+\rho\mathbb{I})^{-1}(Z_{i}^{\dagger}r_{i}+ \rho(y^{m}-\lambda_{i}^{m})) \tag{12}\]where \(\dagger\) denotes the conjugate transpose, and \(\mathbb{I}\) denotes the identity matrix. Let \(Z_{i}=U^{i}\sum^{i}{V^{i}}^{T}=\sum_{p=1}^{h}\sigma_{p}^{i}u_{p}^{i}{{p_{p}^{i}} ^{T}}\). Then, we can solve the least-squares problem in line 3 through SVD. The diagonal entries \(\sigma_{p}^{i}\) of \(\sum^{i}\) are called the singular values of \(Z_{i}\). The columns of \(U^{i}\) are called left singular vectors. Moreover, the columns of \({V^{i}}^{T}\) are called right singular vectors. And \(h\) is the rank of \(Z_{i}\). Then, \(Z_{i}^{\dagger}Z_{i}\) can be calculated as \({V^{i}}{\sum^{i}}^{2}{V^{i}}^{T}\). We can use SVD to select only the important parts of large datasets and update the dictionary through it. Since we have limited memory (dictionary filter size and number), it is particularly important to construct a general dictionary for selecting and compressing only important information from large datasets.  
SVD is known to be the most robust and reliable method for solving the least-squares problem, but it has the disadvantage of complicated computation. Nevertheless, we use SVD to obtain the most common basis dictionary. It means that the dictionary constituting the reflectance can be constructed on a basis like SVD. Therefore, the best reflectance component \(r^{\prime}\) can be obtained from the dictionary and coefficient map in CSC.  
```
1:whileNot Converged do
2:for\(i=1\) to \(N\)do
3:\(d_{i}^{m+1}=\underset{d_{i}}{\arg\min}\frac{1}{2}||r_{i}-Z_{i}d_{i}||_{2}^{2 }+\frac{\rho}{2}||d_{i}-y^{m}+\lambda_{i}^{m}||_{2}^{2}\)
4:endfor
5:\(y^{m+1}=\underset{y}{\arg\min}\;\;\text{ind}_{C}(y)+\frac{N\rho}{2}||y-\frac{1 }{N}\sum_{i=1}^{N}d_{i}^{m+1}-\frac{1}{N}\sum_{i=1}^{N}\lambda_{i}^{m}||_{2}^{2}\)
6:for\(i=1\) to \(N\)do
7:\(\lambda_{i}^{m+1}=\lambda_{i}^{m}+d_{i}^{m+1}-y^{m+1}\)
8:endfor
9:endwhile
10:\(d=y^{m+1}\)
```  
**Algorithm 2**CSC Reflectance function ADMM for the Filters \(d\).