# Content-Adaptive Light Field Contrast Enhancement Using Focal Stack and Hierarchical Network
## 3 Proposed Method
### FS Transforms into AIF  
For the LF camera decoding after the preliminary processing to acquire the raw FS, the FS includes 32 images with different depths. If each image is enhanced, the steps are identical and reduplicative. Therefore, we generate the full-focus image from the raw FS, enhance the contrast of the AIF image, and subsequently convert it into the FS using the DMAP and enhanced full-focus image, which can effectively extract the features of LF images and cover the most information with less work.  
A focus stack is a series of images focused on different planes. Therefore, the original image of the light field is refocused 32 times, and this series of refocused images is called the focus stack. The gradient of each pixel in the focus stack is calculated, and then the gradient image of each image is filtered by the mean value. Then, the sum of the squares of the gradient values of the three channels is calculated and the mean value is taken, and the square root is taken, which is the gradient value of the image. The maximum gradient of the pixel at the same position of the focus stack means that the pixel is the clearest at that  
Figure 3: Framework of the proposed content-adaptive light field FS contrast enhancement.  
depth; that is to say, the object at that depth surface is the clearest. The index value of the depth is recorded, from which the depth map can be synthesized.  
In most cases, DMAPs can be directly downloaded from many datasets and with the raw LF data, e.g., [41], although some LF images do not have DMAPs. To ensure the diversity of the application range of the proposed scheme, the DMAPs in this paper are extracted from the LF dataset instead of being directly downloaded from the Lytro camera. We adopt the method of [PERSON], [PERSON] et al. [42; 43], and use the FS to simultaneously render the AIF image and DMAP. The AIF image refers to the set of all the best in-focus pixels in the FS, i.e., the best in-focus pixel at every position is gathered. Suppose there are \(K\) refocused images in the FS, where the \(k\)-th refocused image is named \(I_{k\_org}(x,y)\), \(\alpha\) is defined as the relative depth, and its distance from the aperture plane is \(F^{\prime}=\alpha F\):  
\[I_{k\_org}(x,y)=I_{\alpha}(x,y) \tag{1}\]  
We use the difference focus measure to obtain the focus map \(F_{k\_d}\), which is the discrepancy between two focus maps, one from the FS \(I_{k\_org}\) and the other from the guided-filtered FS \(I_{k\_GF}\), designed to cancel out the discrepancy.  
\[F_{k\_d}=\left\|F_{k\_org}-F_{k\_GF}\right\| \tag{2}\]  
where \(F_{k\_org}=FM\Big{(}I_{k\_org}\Big{)}\), \(F_{k\_GF}=FM(I_{k\_GF})\). Here, \(I_{k\_GF}\) maintains the boundaries while smoothing the others through a guided filter \(G(.)\), and it is denoted as \(I_{k\_GF}=G\Big{(}I_{k\_org},I_{k\_org}\Big{)}\). \(FM(.)\) indicates a focus measure of choice; the ring difference filter is chosen due to its robustness, coming from incorporating local and non-local characteristics into the filtering window in this paper.  
For one pixel at position \((x,y)\), the best in-focus pixel value is elected from \(I_{1\_org}(x,y)\), \(I_{2\_org}(x,y)\), \(\ldots\), \(I_{K\_org}(x,y)\) by referring to the focus map \(F_{k}(x,y),k=1,\ldots,K\). In the selection of K refocused images of the image, at position \((x,y)\), we focus on the biggest pixels at the best focus pixel and image index, and use \(kmax(x,y)\), which is defined as  
\[kmax(x,y)=\underset{k,k=1,\ldots,K}{max}(F_{k}(x,y)) \tag{3}\]  
The AIF image can be formed by collecting the pixels at the best in-focus at all positions, as described by  
\[AIF(x,y)=I_{kmax(x,y)}(x,y) \tag{4}\]  
where \(I_{kmax(x,y)}(x,y)\) represents the best focus pixel at position \((x,y)\). The DMAP is the set of pixel indices at the maximum focus of all images in the FS, that is  
\[D\ (x,\ y)=kmax\ (x,\ y) \tag{5}\]