• No results found

3.2 Algorithms for contour compression

3.2.2 Encoding contour edges

In publication [P3], we introduce a different strategy for compressing the contours, where we choose to represent the contour using contour edges (called in [P3] crack-edges). The contour edges (crack-edges) are stored using two binary matrices, each of size nr× nc: one matrix to store the vertical contour edges, denoted V ; and one matrix to store the horizontal contour edges, denoted H. Using these two matrices we are able to achieve a much simpler connection between the image grid and the contour edge grid. In each location of the vertical binary matrix a vertical edge is stored, that is set as follows: if the pixel positions (x, y − 1) and (x, y), in the initial image Z, are belonging to two different regions, i.e. if Z(x, y − 1) 6= Z(x, y), then the vertical edge is set as active by V (x, y) = 1, else it is set as inactive by V (x, y) = 0. Similarly, in each location of the horizontal binary matrix a horizontal edge is stored, where H(x, y) = 1 if Z(x − 1, y) 6= Z(x, y) and H(x, y) = 0 otherwise. Figure 3.6 shows an example of the way active contour edges are set in the two binary matrices.

Figure 3.6: The representation of contour edges using two binary matrices. Black lines are marking the inactive contour edges. A cyan line is marking the active vertical edge, V (x, y) = 1, between Z(x, y) and Z(x, y − 1). A blue line is marking the active horizontal edge, H(x, y) = 1, between Z(x, y) and Z(x − 1, y).

The image contour is transmitted to the decoder by encoding the two binary matrices H and V. Although the information regarding the crack-edges is divided into two matrices, the coding of each vertical and horizontal edge is done using both binary matrices. Template Context Tree Model (TCTM) is the statistical model used to encode the representation, where two different templates are introduced.

The template shown in Figure 3.7.(a) is used to encode a vertical edge, where the previous two lines in the two binary matrices are used to create the template context using 10 horizontal edges from H and 7 vertical edges from V . Let us denote Tv the context tree obtained using this template. The template shown in Figure 3.7.(b) is used to encode a horizontal edge. Similarly, the previous two lines in the two binary matrices are used to create the template context using 7 horizontal edges from H and 10 vertical edges from V . Let us denote Th the context tree obtained using this template. Note that in both cases the length of the context is 17. The order, in which the edges are collected in the template context, was fixed after testing different orders for a set of five different depth-map images. Each image has an optimal order selection that could be found by a greedy method. We choose not to search for it because its method is increasing the algorithm’s complexity and the obtained decrease in bitrate is very small.

The two binary matrices, V and H, are scanned row-wise by first traversing the row x from H, and then traversing row x from V . The symbols distributions, at each node in each context tree Tv and Th, are collected in the first pass. The two context trees are then pruned, and the optimal context trees Tv and Th are obtained. In the second pass, the contour edges saved in the two binary matrices are encoded using the two optimal trees [51, 70]. To lower the complexity of the algorithm and to decrease the runtime, in [P3], we developed two versions for the contour compression algorithm. We summarized the High Complexity (HiCo) ver-sion (described above) in an algorithm denoted Algorithm C (Alg. C), presented in Algorithm 3.2. In the second version of the algorithm, called Fast, the com-plexity is decreased by using only one pass to encode each binary matrix. Hence,

(a) (b)

Figure 3.7: The context template used to encode: (a) a vertical edge; (b) a horizontal edge. The cyan lines are marking the position of the vertical edges added in the templates. The blue lines are marking the positions of the horizontal edges added in the templates. The numbers in the circles are denoting the contour edges order in the template. Both images represent the image Z, with the contour edges marked as in Figure 3.6.

in Fast the balanced trees Tv and Thare used to encode the contour edges, and the context template length (and tree depth), is decreased from 17 to 15.

The regions in the image must be separated by a continuous contour; otherwise we cannot distinguish two neighbor regions, which give the contour edge the pro-priety that each of its ends is connected with at least one other contour edge end.

Exceptions appear only for the contour edges at the image boundary. This propri-ety is used in [P3] to improve the compression by finding deterministic cases where the contour edge can be predicted from its neighboring edges. Unfortunately, only for the vertical edges we found deterministic cases. In Figure 3.7.(a), if all the con-tour edges in the positions 1, 2, and 3 are inactive, then the unknown vertical edge marked with the red line is also inactive. A simple explanation is that, because all the contour edges in the three positions are inactive, all four pixels, between which these contour edges are set, are in the same region, and hence the last unknown edge out of the four is always inactive. If only one contour edge is active and has any position 1, 2, or 3, then the unknown vertical edge, marked with the red line in Figure 3.7.(a), is always active. The propriety described above is used here, since the unknown vertical edge has at the upper end a connection with one active contour edge, it must be active so that the contour can be continuous.

The non-stationarity propriety of the context distributions was used in publi-cation [P3], where during the count collection, we try to down-weigh some counts in each context by halving the values of the symbols distribution. Note that the context that has all the contour edges inactive is the only context that has a

sta-Algorithm 3.2: sta-Algorithm C, contour compression stage in CERV

The algorithm represents the image contour using contour edges, and encodes two binary matrices, V and H, using Template Context Tree Model (TCTM).

(0) Initialize the context trees Tvand Thup to the maximum tree depth of 17.

(1) Do one pass through the binary matrices V and H and collect: the counts in the context tree Tvusing the context template in Figure 3.7.(a), and the counts in the context tree Thusing the context template in Figure 3.7.(b).

(2) Prune the balanced trees, Tv and Th, using dynamic programming, and encode the structure of the new optimal context trees, Tv and Th, using a Breadth-First Search (BFS) procedure.

(3) Do one pass through the binary matrices V and H. If the current contour edge is not in a deterministic case, then encode the contour edges using Tv and Th (already available at the decoder); else set the corresponding deterministic contour edge.

tionary distribution. The concept is described in more details in Appendix A.2.

For the image Art (full size, left view) of size 1390×1110 the CERV algorithm obtains a result of 0.2065 bpp, i.e. a compression ratio of 38.7420 (see Section 5).

The contours are compressed using Algorithm 3.2 in 0.1918 bpp, i.e. 92.87% of the final bitrate. The optimal context trees Tv and Th have together a total of 1857 branches that are encoded using 227 bytes or 0.0013 bpp, i.e. 0.61% out of the contours bitrate.