Sie sind auf Seite 1von 25

GRAY CODE

GC  BC   BC  1

Logical operation XOR is Exclusive OR:


00=0 01=1
11=0 10=1

Examples
1) Value =127:
Binary code BC: 0111 1111

Gray code GC: 0111 1111


0011 1111
---------------
0100 0000

2) Value = 128
Binary code BC: 1000 0000

Gray code GC: 1000 0000


0100 0000
---------------
1100 0000
BINARY AND GRAY CODES (4 BITS):
Binary code Gray code
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
Binary and Gray code bit planes:
 Encode each bit plane with JBIG
 Typically, lossless JPEG is more efficient
than JBIG for images with more than 6 bits
Binary code Gray code

4
3

0
JPEG: Joint Photographic Experts Group

 JPEG Lossless mode


Predictive coding in lossless JPEG

ALTERNATIVE PREDICTORS:

Mode: Predictor: Mode: Predictor:


0 Null 4 N + W - NW
1 W 5 W + (N - NW)/2
2 N 6 N + (W - NW)/2
3 NW 7 (N + W)/2

NW N
W x
RESIDUAL CODING:
  x  x

DECODER:
x  x  

ENTROPY CODING:
 HUFFMAN CODING
 ARITHMETIC CODING (QM-CODER)
Huffman coding

Category Codeword Difference Codeword


0 00 0 -
1 010 -1, 1 0, 1
2 011 -3, -2, 2, 3 00, 01, 10, 11
3 100 -7,..-4, 4..7 000,...011,
100...111
4 101 -15,..-8, 8..15 0000,...0111,
1000...1111
5 110 -31,..-16, 16..31 :
6 1110 -63,..-32, 32..63 :
7 11110 -127,..-64, 64..127 :
8 111110 -255,..-128, :
128..255
Binary arithmetic coding

0
{0}
1
{1}
2
{ 2, 3 }
::
3
{ 4, . ,7 }

7 8
{ 63, ..,127 } { 128, ..,255 }
Lossless JPEG: example

Pixel sequence: 10, 12, 10, 7, 8, 8, 12.


Prediction mode: 1 (previous pixel value)
Static Huffman coding
Pixel: 10 12 10 7 8 8 12
 +10 +2 -2 -3 +1 0 +4
Category: 4 2 2 2 1 0 3
Bits: 101 1010 011 10 011 01 011 00 010 1 00 100 100
FELICS
Fast and Efficient Lossless
Image Compression System
P.Howard and J.Vitter

PREDICTION MODEL:

b
a x

L=min{a,b}, H=max{a,b}.

L = The smaller of the two neighbor pixel value


H = The larger of the two neighbor pixel value
ASSUMPTION OF DISTRIBUTION:

probability

below in above
range range range

L H intensity

CODING THE PIXEL VALUE:


IF P  [L, H] THEN
Output(0);
Encode =P-L by adjusted binary code;
ELSE IF P < L THEN
Output(1);
Output(0);
Encode =(L-1)-P by Golomb-Rice code;
ELSE
Output(1);
Output(1);
Encode =P-(H+1) by Golomb-Rice code;

CODE TABLE:
Pixel position: Codeword:
Below range 10 + Rice(L-P-1)
In range 0 + Adj.Binary(P-L)
Above range 11 + Rice(P-H-1)
ADJUSTED BINARY CODING:
 Let =H-L. There are +1 possible values in the
range.
 If +1 is a power of two, a binary code with
log2(+1) bits is used.
 Otherwise  log    1  are used for middle values and
2

 log    1  bits for the “outer values”.


2

 For example, if =4 there are five values (0, 1, 2, 3,


4) and their corresponding adjusted binary
codewords are (111, 10, 00, 01, 110).

RICE CODING:

 For determining the Rice coding parameter k, the


 is used as a context.
 For each context , a cumulative total bit rate is
maintained for each reasonable Rice parameter
value k, of the code length that would have
resulted if the parameter k were used to encode
all values encountered so far in the context.
 The parameter with the smallest cumulative code
length is used to encode the next value
encountered in the context.
 The allowed parameter values are k=0, 1, 2, and
3.
CALIC:
Context-based Adaptive Lossless
Image Codec

 CALIC [X.Wu,1995] is ranked top among


the schemes that were evaluated by the JPEG
committee prior to the development JPEG-
Lossless standard.
 … but rather elaborate scheme.
LOCO-I:
LOw-COmplexity
LOssless COmpression for Images
 Features
 Context modeling (365 contexts)
 Run-length coder: Run-lengths are coded with
Golomb-Rice method.
 Nonlinear predictor
 Golomb-Rice entropy coder: the parameter k
depends on the context, and is adapted to the
average absolute value of residuals.
Model structure of JPEG-LS

M o d e le r c o n te x t

im a g e p re d ic tio n p red . erro rs,


s a m p le s
- e rro rs C o n te x t
m o d e le r
s ta tis tic s

F ix e d p r e d ic te d
G ra d ie n ts v a lu e s
p re d ic to r

+
F lat A d ap tive
re g io n ? c o rre c tio n
m ode r e g u la r

im a g e r u n le n g th s ,
s a m p le s run
s ta tis tic s
im a g e R u n c o u n te r
s a m p le s
COMPONENTS OF THE MODEL:
1. Prediction
2. Determination of context.
3. Probability model for the prediction
errors.
PREDICTOR:
 min  a, b  if c  max(a, b)

x  max  a, b  if c  min(a, b)
ˆ
c b d  abc
 otherwise

e ax
Examples:
20 12
10 10
1) c=20 > max(10,12)  predictor =
min(10,12)=10

10 20
18 20
2) c=10 < max(18,20)  predictor =
max(18,20)=20

12 20
10 18
2) 10<12<20  predictor = 20+10-12=18
RESIDUAL CODING:
  x  x

DECODER:
x  x  
JPEG-LS context model
 The distributoin of prediction residuals in
continuous tone images can be approximated
by a Laplacian distribution, i.e. a two-sided
exponential decay centered at zero.

 In a one-pass scheme, the encoder cannot


tune an optimal Huffman table to each
possible distribution of prediction residuals.

 Adaptive construction of optimal tables is


ruled out by the complexity contsraints.

 Solution: For each context the encoder


adaotively chooses the best among a limited
set of Huffman codes, matched to
exponentially decaying distributions, based
on the past performance.
GRADIENT DETERMINATION:
g1 = d - b
g2 = b - c
g1 = c - a

CONTEXT QUANTIZATION:
gi  qi

{0}
{1,2}
{3,4,5,6}
{7,8,...,20}
{e20}

NUMBER OF DIFFERENT CONTEXTS: 365

C 
  2T  1 3

1
2

T=4, |C|=365: balance storage requirements


with high-order conditioning
JPEG-LS coding

VALUE MAPPING FROM [-127,127] TO [0, 255]:


M     2 , if   0
M     2   1, if   0

CODING OF RESIDUALS:
Golomb-Rice coding with parameter 2k

Coding of run-lengths:
Golomb-Rice coding with parameter 2k.
JPEG-LS: Part 2
 Difference from Part-1
1. No run mode
2. 4  5 reference points
3. Modified prediction for images with
sparse histograms
4. Binarization and its arithmetic coding

Part-1:
Context modeling  Prediction or Run mode
 Golomb Coding

Part-2:
Context modeling  Prediction Binarization
 Arithemtic Coding
Comparison of lossless methods

Source: http://www.hpl.hp.com/research/itc/csl/vcd/infotheory/loco.html

Das könnte Ihnen auch gefallen