{'fraction_non_alphanumeric': 0.0367467484523201, 'fraction_numerical': 0.010280002271823706, 'mean_word_length': 4.437924644842496, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Convex Optimization Based Bit Allocation for Light Field Compression under Weighting and Consistency Constraints

Compared with conventional image and video, light field images introduce the weight channel, as well as the visual consistency of rendered view, information that has to be taken into account when compressing the pseudo-temporal-sequence (PTS) created from light field images. In this paper, we propose a novel frame level bit allocation framework for PTS coding. A joint model that measures weighted distortion and visual consistency, combined with an iterative encoding system, yields the optimal bit allocation for each frame by solving a convex optimization problem. Experimental results show that the proposed framework is effective in producing desired distortion distribution based on weights, and achieves up to 24.7% BD-rate reduction comparing to the default rate control algorithm.


Introduction
The light field, introduced in [1] [2], describes the intensity of light rays passing through each point in space, at each possible direction, wavelength and time. Given a single time instance, the light field model can be simplified as a 4D function L(u, v, x, y), which can be considered as a collection of perspective images of the xy plane, observed from various positions on the uv plane [3].
Recent advancements in light field imaging, brought to light by the commercial products Lytro and Ratrix, call for efficient compression algorithms. [3] evaluated and compared several state-of-the-art light field image compression algorithms, most of them can be classified as lenslet image compression [4] [5] or perspective image compression [6] [7]. The latter approach arranges perspective images into a pseudotemporal-sequence (PTS), which is then coded with the HEVC [8] video encoder.
Rate control aims at delivering a video stream with the highest possible visual quality, while keeping the bitrate under constraints. As PTS coding uses a video encoder, a rate control mechanism is also required, with some important and unique challenges not addressed in a general video rate control algorithm design. Image captured by a light field camera (e.g. Lytro Illum) may contain a fourth weight channel in addition to the conventional RGB channels [9], indicating the confidence of each pixel, and affects the evaluation of coding distortion accordingly. Moreover, the visual consistency differs from the normal sense, as the PTS is not displayed in temporal order, rather, a render algorithm [10] [11] is used to reconstruct views from the PTS.
In this paper, we propose a novel frame level bit allocation framework for PTS coding that takes into account the weighting and consistency factors. The rate-distortion curves of each perspective frame are estimated to deduce the weighted distortion and consistency. They form a cost function to be minimized, when combined with a total bit cost constraint, define an optimization problem that can be systematically solved using convex programming, yielding optimal bit costs of each perspective frame.
The rest of the paper is organized as follows. Related work is presented in Section II. A quantitative model for weighted distortion and consistency is described in Section III. The convex optimization problem is formulated and solved in Section IV. Experimental results are given in Section V, and Section VI concludes the paper.

Related Work
Evaluations in [3] showed that perspective image compression is more efficient comparing to lenslet image compression. This coding approach relies on the arrangement of perspective images in the PTS. Spiral scan order [3] and raster scan order [6] were proposed, as well as a 2D hierarchical structure [12], which achieves higher efficiency with modifications to the HEVC codec.
Recent research [13] proposed using the Lagrange multiplier λ for bit allocation in HEVC. [14] proposed a rate control algorithm for its 2D hierarchical structure PTS coding based on an analysis of the R −λ model. It achieved significant bitrate savings but did not consider the impact of the weighting and consistency factors.
To some extent, rate control in light field image coding is similar to variable bitrate (VBR) coding, as we do not require the bitrate of the encoded PTS to be constant, but rather, aim to achieve the best video quality possible. Many VBR algorithms employ a two-pass procedure [15] [16], where encoding related statistics, especially the rate-distortion behavior of each frame, is collected during the first pass. These are then used in the second pass to perform the actual encoding. However, as the rate-distortion behavior of a frame relies on its reference frames, either an iterative framework [17], which assumes independence within each iteration and seeks convergence by re-encoding, or a model that features backward dependency [18] is required.
With frame level rate-distortion behavior, one can formulate an optimization problem which minimizes a cost function (e.g. distortion, discontinuity, and etc.) while satisfying given constraints, to yield an optimal solution for bit allocation. [19] proposed an iterative convex programming framework for VBR streaming rate control under multiple channel rate constraints. [20] proposed a convex optimization model with inter-frame dependency compatibility to solve the joint bit allocation problem in H.264 statistical multiplexing.
As its main novelty, this paper proposes an optimization target that measures weighted distortion and visual consistency of light field images. An iterative encoding system is then proposed, as well as a two-step strategy that converts the proposed target into a solvable convex optimization problem.

Weighting and Consistency Models Weighted Distortion
Each pixel in the light field image is associated with a 4-tuple coordinate (u, v, x, y), as well as its weight w(u, v, x, y) from the weight channel. The weight represents the confidence associated with the pixel, and therefore the relative loss of information due to coding distortion. Intuitively, distortion of a pixel with higher confidence leads to higher information loss, and vice versa.
A frame level rate control algorithm should therefore distinguish frames by their relative confidence levels. We propose to assign a weight w f to any perspective frame f with coordinate (u, v), which is the average pixel weight across f . A unified weight w f is obtained by rescaling w f into [0, 1] linearly where r and h are the width and height of f , respectively. The weighted distortion D f of f can thus be defined as a weighted Sum of Square Errors (SSE), allowing the unified weight to measure the relative information loss where D o f is the ordinary SSE,p and p are the decoded and original pixel, respectively. The rescaling of w tow makes the order of magnitude of the weight channel immaterial and thus allows us to compare different light field images fairly. In (3),w f is squared to match the squared errors in (2).
A sample distribution ofw f on the uv plane is shown in Fig. 1(a). It is a typical pattern with perspective frames in the center of the uv plane have higher weights, and weights of peripheral perspective frames reduce to zero.

Consistency
A virtual render of a light field is a synthesized view at an arbitrary position and direction. The visual consistency of a light field image refers to the quality consistency of virtual renders the observer is receiving when navigating freely in space. To be precise, since virtual renders of the light field can be obtained by resampling and interpolating nearest perspective frames [11], the quality of perspective frames needs to be a continuous function of the (u, v) coordinates, so that rendered views have smooth transitions when the observer follows a continuous path.
The uv plane with the 1 metric, forms a metric space where the distance between two perspective frames f at coordinate (u, v) and f at coordinate (u , v ) is measured as The visual consistency can then be measured by the distortion differences of perspective frame pairs with close distances: where the sum is taken over all perspective frame pairs (f, f ). We shall call C the discontinuity term. Frames with higher confidences shall make larger contribution as they are more "important", therefore the unified weightsw appear in (5). The δ function indicates the proximity of f to f , given by δ(f, f ) = max(0, 3 − d(f, f )). Fig. 1(b) shows the possible values of δ(f, f ). f is the gray frame in the center and f can be any white frame, the resulting δ is marked on f . It is worth noting that C and δ can be defined in other forms, as long as they can be used as a measure for consistency.

The Bit Allocation Problem Problem Formulation
The goal of our bit allocation framework is to achieve the minimum distortion considering the weight and consistency factors, and given the total bit budget. Using a Lagrange multipler λ to control the trade-off between weighted distortion and discontinuity, one can define the cost function to be minimized as The square root is taken over C to improve statistical stability, as norms behave better than quadratic forms [21] in convex programming. The total bit budget constraint is where R f is the bit cost of frame f and the sum is taken over all perspective frames, R is the total bit rate budget.
To relate T with R we need to establish the correspondence between D o f and R f . It is clear that D o f depends on not only R f , but also the reference frames of f . However, taking into account all dependencies will increase the complexity of the problem tremendously. In this paper we take the iterative approach as in [17] [19]. D o f is assumed to be a function of R f , and the resulting solution is used to re-encode the PTS in the next iteration, until the bit allocation converges.
The D o f − R f function will be denoted as D o f (R f ). For three perspective frames a,b,c in the light field image Black Fence [22] , their reference frames are fixed and we change the frame QPs to obtain the D o f − R f relationship shown in Fig. 2 as circles. The observation that D o f (R f ) resembles a monotonic and convex function enables us to solve the bit allocation problem with convex programming. Indeed, for each perspective frame f we approximate D o f (R f ) by the convex power function where α f > 0, β f < 0. The approximated functions for the three perspective frames are drawn as dash lines in Fig. 2. Table 1 shows the parameters α, β and the R 2 coefficients obtained through linear fitting. It is clear that (7) is a good approximation of the D o f (R f ) function. Once we have (6) and (7), our goal to minimize the cost function T can be written as an optimization problem

Solving the Optimization Problem
If we arrange the perspective frames in coding order (f 1 , f 2 , ..., f N ), and use r to denote the vector (R f 1 , ..., R f N ), (8) shows that r shall lie inside the N -simplex r 1 ≤ R, r 0. The N -simplex is a convex set, however the objective to be minimized in (8) is not convex with respect to r.
To make (8) tractable, we take advantage of the fact that the discontinuity term in (6) shall not dominate the weighted distortion term, as we prioritize a small overall distortion over absolute constant quality. Thus we can divide the task of solving (8) into two steps: 1. Solve (8) by omitting the discontinuity term in the objective to obtain an intermediate solution, 2. Approximate the discontinuity term in (8) by a convex function of r using the intermediate solution.
By omitting the discontinuity term, the objective becomes the sum of weighted f , which is indeed convex. Thus we can solve this optimization problem and obtain an intermediate solution r 0 = (r f 1 , ..., r f N ) that minimizes T . Once we have r 0 , we approximate the discontinuity term C in (6) by replacing D o f and D o f with their first order Taylor approximations: Based on our assumption that the weighted distortion should be the dominant term in (6), the optimal solution of (8) shall not differ from r 0 significantly, and use (9) as a good approximation of (7). Once we use (9) instead of (7) to compute the discontinuity term, the optimization problem can be re-written as where A is a sparse N 2 × N matrix and b is a N 2 × 1 vector, given by (5) and (9), each of whose rows corresponds to a pair of perspective frames. To be precise, row k corresponds to (f i , f j ) where i = k/N , j = k − N (k − 1)/N , and It is now clear that the objective in (10) is convex with respect to r, and a convex programming solver can be used to solve (10). In this paper we used the SDPT3 solver implemented in CVX [21], a package for specifying and solving convex programs.

Iterative Encoding
Based on the solution of (10), we propose an iterative encoding system that minimizes (6) by controlling the bit allocation during PTS encoding.
In the first iteration, we use the default rate control algorithm of HEVC to encode the sequence. The QPs of all encoded frames are recorded as (q 1 , ..., q N ). For frame f i , as soon as its QP q i is decided, we run a few trial compressions that estimate the bit cost R f i and distortion D o f i by using q as the frame QP, where q is set to every integer in [q i − K, q i + K]. These 2K + 1 points allow us to estimate the parameters α f i and β f i in (7). In this paper we set K = 2. The trial compressions do not affect the output as the frame QP is set to q i in the actual encoding.
Starting from the second iteration, the frame QPs (q 1 , ..., q N ) of the previous iteration are known, as well as the parameters α f , β f for all frames f . Therefore the solution of (10) gives the optimal bit allocation as (r 1 , ..., r N ). For frame f i , the same trial compressions as the first iteration are conducted, except that the frame QP for the actual encoding is chosen such that its estimated bit cost is close to r i . The chosen frame QPs and the estimated parameters α, β are passed to the next iteration, until encoding results converge. Similar to [19], it usually takes 3 to 4 iterations to reach convergence in our experiments.

Experimental Results
We selected five lightfield images (Bikes, Stone Pillars Outside, Black Fence, Fountain and Vincent 2 and Friends 1 ) from the EPFL light field image dataset [22] representing different scenarios. They were encoded with the default rate control algorithm and our proposed method, both implemented in HM 16.16, with four different target bitrates (500kbps, 1Mbps, 2Mbps, 4Mbps) under 30 fps. The "Low-Delay P" configuration was selected since random access is not necessary for decoding a light field image. The spiral scan order was chosen due to its simplicity, though our method is not specific to any arrangement.
The Bjontegaard-Delta rate [23] is used to compare the performance of our proposed method to the default rate control algorithm. However, as our goal is to minimize the cost function (6), it only makes sense to use (6) to define the MSE in a weighted PSNR metric: wPSNR = 20 log 10 255 where T is as defined in (6) and n is the number of pixels of the light field image. Two sets of experiments were carried out where λ in (6) was set to 5 and 0, respectively. The former demonstrates the performance of the overall framework, and the latter allows us to examine the improvement by considering the weighting factor alone. The value λ = 5 was determined heuristically, as it provides a satisfactory trade-off between distortion and consistency (see Fig. 3(b)). Table 2 shows the resulting bitrates, weighted PSNRs, and BD-rates obtained from the experiments. In the table, "TBR" stands for target bitrate, "BR" stands for actual bitrate, both are in Mbps. The weighting factor alone contributes an average 5.9% and up to 11.9% BD-rate reduction, while by jointly considering weighting and consistency, our proposed method achieves an average 19.5% and up to 24.7% BD-rate reduction. Fig. 3 is an example showing the distribution of perspective frame qualities, using the usual PSNR metric, obtained by encoding Stone Pillars Outside with the default algorithm (a) and our method where λ = 5 (b) and λ = 0 (c), respectively. (a) shows that the original HM encoder results in high discontinuity as frames with large PSNR differences are interlaced. The pattern in (b) shows smooth quality transition, with the exception of the central frame as it is the only I-frame. The PSNRs fall off from the center to the boundary, in a similar pattern as weights (see Fig. 1(a)), which proves the effectiveness of our joint model. The consistency factor is disabled in (c), but the weighting model is still effective and leads to a similar pattern as the weight distribution. Moreover, as discontinuity is out of concern, (c) results in higher overall discontinuity comparing to (b), but is able to achieve higher PSNRs in the central area.

Conclusions
In this paper, we proposed a novel bit allocation framework by modeling the weighted distortion and consistency for light field images. The optimal bit allocation is deduced using convex optimization, and a weighted PSNR metric is defined for measurement. Experimental results proves our framework's capability to allocate bits according to the weight distribution, and to produce encoded images with high consistency, where a maximum of 24.7% BD-rate reduction is achieved. Future work includes improving the rate-distortion model (7), accelerating the iterative process with a fast QP selection algorithm, as well as a CU level extension of the proposed framework.