Presentation is loading. Please wait.

Presentation is loading. Please wait.

DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF JOENSUU JOENSUU, FINLAND Image Compression Lecture 9 Optimal Scalar Quantization Alexander Kolesnikov.

Similar presentations


Presentation on theme: "DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF JOENSUU JOENSUU, FINLAND Image Compression Lecture 9 Optimal Scalar Quantization Alexander Kolesnikov."— Presentation transcript:

1 DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF JOENSUU JOENSUU, FINLAND Image Compression Lecture 9 Optimal Scalar Quantization Alexander Kolesnikov

2 Quantization error for discrete data X C2C2 C1C1 CMCM... Quantization error for the data X with M cells: Cell’s centroids:

3 Optimal scalar quantization: History J.D.Bruce [1963]: O(MN 2 ) DP X. Wu [1991]: O(MN 2 )  O(MN) DP+Monge X,Y,Z [2001]: O(N M )  O(N M-1 ) Exhaustive search in paper ”A fast algorithm for multilevel thresholding” Some researchers still believe that complexity of the optimal algorithm is exponential, … and some researchers are still re-inventing the optimal DP algorithm of O(MN 2 ) complexity.

4 Problem formulation Let X={x 1, x 2, …, x N } be a finite ordered set of real numbers ( intensity values ). Let P={p 1, p 2, …, p N } be the correspondent set of a probabilities for the values X (histogram). Let {r 0,r 1,r 2, …,r M+1 } be an ordered set of integers such that defines a partition of the set X into M parts: r 0 = 0 < r 1 <... < r j < r j+1 <... < r M = N. x 1 x 2 xNxN p1p1 p2p2

5 Sequence partition problem Quantization error for one (part) cell: Cell’s centroid y j : Partition indices: r 0 = 0 < r 1 <... < r j <... < r M =N. We introduced r 0 = 0 for x 0 = . The total quantization error:

6 Scheme of partition into cells Quantization error for the cell #2 (j=2): Data: x 0 =  < x 1 <... < x j <... < x N Partition indices: r 0 = 0 < r 1 <... < r j <... < r M =N. Cells:... ]( ] ( #1 #2 #3 (x 0 =  ) x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x N (r 0 =0) r 1 =4 r 2 =10 r M =N=15 N=15, the number of cells M=3

7 Optimization task For a given data X, probabilities P and number of cells M find such a partition {r o,r 1, r 2, …, r M } that the total quantization error is minimal: where and

8 Cost function D M (0,N] Let us introduce cost function D m (0,n] that is minimum quantization error for quantization of data sub-set X n ={x 1, x 2, …, x n } with m cells: Then D M (0,N] gives us solution of the problem in question.

9 Dynamic programming approach In other words: Let’s rewrite the cost function:

10 Reccurent equations Initialization: Recursion:

11 Calculation of quantization error for a cell Complexity of the quantization error calculation is O(N) Can we calculate it faster?

12 Calculation of quantization error for a cell

13 where cumulants S 0 (n), S 1 (n), S 2 (n) are defined as follows: Complexity of quantization error calculation for one cell is O(1).

14 DP search in the state space  M N1 0 b n m j State space  C(n,m) C(j,m-1) C(N,M) Start state e 2 (j,n ) C(n,m) = min {C(m, m-1) + e 2 (m, n], C(m+1,m-1) + e 2 (m+1,n],... C(j,m-1) + e 2 (j, n]* ),... C(n-1, m-1) + e 2 (n, n]} m-1 * A(n,m)=j opt

15 Scheme of the DP algorithm // Initialization FOR n = 1 TO N DO C(n,1)= e 2 (j,n] // Minimum search FOR m = 2 TO M DO FOR n = m TO N DO d min   FOR j= m-1 TO n-1 DO c  C(j, m  1) + e 2 (j,n] IF(c < c min ) c min  c; j min  j ENDIF ENDFOR C(n, m)  d min A(n, m)  j min ENDFOR Complexity: O(MN 2 ) C(n,m)=D m (0,n]

16 Backtrack in the state space  M N1 0 b n m j State space  A(N,M) Start state m-1 S(M+1)= N FOR m = M+1 TO 2 DO S(m  1) = A(S(m), m)) E 2  C(N,M) S(M+1)= N FOR m = M+1 TO 2 DO S(m  1) = A(S(m), m)) E 2  C(N,M) N=22, M=8: S={22,18,14,12,9,6,4,3,1} (x 0,x 3 ], (x 3,x 4 ], (x 4,x 6 ], (x 6,x 9 ], (x 9,x 12 ], (x 12,x 14 ], (x 14,x 18 ], (x 18,x 22 ]

17 Optimal scalar quantization DP algorithm a) Time complexity: O(MN 2 ) b) Space complexity: O(MN) Error balance property: e 2 (r j-1,r j ]  Const Optimal scalar quantizer as weighted k -link shortest path in directed acyclic graph (DAG) Wu [1991] reduced time complexity of optimal DP algorithm to O(MN) using Monge property of quantization error with L 2 metrics. Space complexity: O(N 2 ).

18 Can we do it faster? Wu [1991] reduced time complexity of optimal DP algorithm to O(MN) using Monge property (monotonicity property) of quantization error with L 2 metrics. Space complexity: O(N 2 ).

19 Example 1: M=3 Input image Uniform Optimal

20 Example 1: M=3 Uniform Optimal

21 Example 2: M=5 Optimal Uniform

22 Example: M=5 Uniform Optimal

23 Example: M=12 Centroid dencity is higher when probability dencity is also higher... Centroid dencity is higher when probability dencity is also higher...

24 Summary 1) Optimal scalar quantization


Download ppt "DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF JOENSUU JOENSUU, FINLAND Image Compression Lecture 9 Optimal Scalar Quantization Alexander Kolesnikov."

Similar presentations


Ads by Google