The LOCO-I Standard (ISO/IEC 14495-1)
Vicente González Ruiz
January 1, 2020
Contents
Intro
- LOCO-I [1] (LOw COmplexity, context-based, lossless Image compression
algorithm), also named JPEG-LS (Joint Photographic Expert Group -
LosslesS), is a lossless stil image codec based on context-based predictive
coding and Golomb Coding.
- Developed by HP, that only offers the executable code in:
http://www.hpl.hp.com/loco/locodown.htm
1 Encoder
- Initialization of the prediction contexts:
- Let
the actual context (there are
different spatial contexts).
- Let
the number of times that the context
has been found.
- Let
the accumulated prediction error for the context .
- Let
the sumatory of the absolute value of the prediction residues for the
context .
- Let
the the bias cancellation values for the context .
These values are added to the predictions to try that the predictions
residues have a zero average. If this is not satisfied, the compression
ratio in reduced severelly because the average of the real Lapace
probability distribution of the residues and the modeled probability
distribution does not match. For this reason,
is proportional to
that added to the predictions, cancel the bias.
- Determination of the prediction context
:
- Compute the local gradient:
- Quantize the gradients:
for
and
- Compute the residue :
- The initial prediction:
- Bias cancellation:
- Compute the prediction error:
where
is the number of bits/pixel. This produces a projection of the residues from the dynamic
range
to ,
where
is the size of the source alphabet.
- Shuffle the residues in order to get an exponiential (with negative
exponent) distribution of the probability of the residues:
After that, the residues are in the range
- Variable length encoding of
in the context :
- Output
a Rice code for
using the slope .
- Update the context :
- .
- .
- If , then:
(where )
- .
- .
- .
- .
- Update of :
- If ,
then:
- .
- If ,
then:
- If ,
then:
- Else:
- If ,
then:
- .
- If ,
then:
- If ,
then:
2 Decoder
- Idem to Step 1 of the encoder.
- Idem to Step 2 of the encoder.
- Decode .
- Compute the initial prediction such as in Step 3.a of the encoder.
- Add the bias to :
- Recover the original Laplace distribution for the residues:
- .
- Update
as in Step 5 of the encoder.
3 The RLE mode
LOCO-I uses a Rice encoder that can be very redundant if the probability
distributions are very narrow. To overcome this drawback, there is
a special encoding mode for this situation that is triggered when
.
The normal mode is re-started when if
or the
end of a line has been reached.
Let’s go to the lab!
References