ArticleslgStudy

computer science

Lossless JPEG

Lossless JPEG is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Lossless JPEG rather than just read about it. In short: Lossless JPEG is a 1993 addition to JPEG standard by the Joint Photographic Experts Group to enable lossless compression. However, the term may also be used to refer to all lossless compression schemes developed by the group, including JPEG 2000, JPEG LS, and JPEG XL.

Lossless JPEG — main illustration
Lossless JPEG — illustration

Key takeaways

  • Lossless JPEG belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Lossless JPEG to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Lossless JPEG from memory before moving on to harder problems.

Reference excerpt

Lossless JPEG is a 1993 addition to JPEG standard by the Joint Photographic Experts Group to enable lossless compression. However, the term may also be used to refer to all lossless compression schemes developed by the group, including JPEG 2000, JPEG LS, and JPEG XL. Lossless JPEG was developed as a late addition to JPEG in 1993, using a completely different technique from the lossy JPEG standard. It uses a predictive scheme based on the three nearest (causal) neighbors (upper, left, and upper-left), and entropy coding is used on the prediction error. The standard Independent JPEG Group libraries cannot encode or decode it, but Ken Murchison of Oceana Matrix Ltd. wrote a patch that extends the IJG library to handle lossless JPEG. Lossless JPEG has some popularity in medical imaging, and is used in DNG and some digital cameras to compress raw images, but otherwise was never widely adopted. Adobe's DNG SDK provides a software library for encoding and decoding lossless JPEG with up to 16 bits per sample. ISO/IEC Joint Photography Experts Group maintains a reference software implementation which can encode both base JPEG (ISO/IEC 10918-1 and 18477-1) and JPEG XT extensions (ISO/IEC 18477 Parts 2 and 6–9), as well as JPEG LS (ISO/IEC 14495).

Lossless mode of operation

Lossless JPEG is actually a mode of operation of JPEG. This mode exists because the discrete cosine transform (DCT) based form cannot guarantee that encoder input would exactly match decoder output. Unlike the lossy mode which is based on the DCT, the lossless coding process employs a simple predictive coding model called differential pulse-code modulation (DPCM). This is a model in which predictions of the sample values are estimated from the neighboring samples that are already coded in the image. Most predictors take the average of the samples immediately above and to the left of the target sample. DPCM encodes the differences between the predicted samples instead of encoding each sample independently. The differences from one sample to the next are usually close to zero. A typical DPCM encoder is displayed in Fig. 1. The block in the figure acts as a storage of the current sample which will later be a previous sample. The main steps of lossless operation mode are depicted in Fig. 2. In the process, the predictor combines up to three neighboring samples at A, B, and C shown in Fig. 3 in order to produce a prediction of the sample value at the position labeled by X. The three neighboring samples must be already encoded samples. Any one of the predictors shown in the table below can be used to estimate the sample located at X. Any one of the eight predictors listed in the table can be used. Note that selections 1, 2, and 3 are one-dimensional predictors and selections 4, 5, 6, and 7 are two-dimensional predictors. The first selection value in the table, zero, is only used for differential coding in the hierarchical mode of operation. Once all the samples are predicted, the differences between the samples can be obtained and entropy-coded in a lossless fashion using Huffman coding or arithmetic coding.

Typically, compressions using lossless operation mode can achieve around 2:1 compression ratio for color images. This mode is quite popular in the medical imaging field, and defined as an option in DNG standard, but otherwise it is not very widely used because of complexity of doing arithmetics on 10, 12, or 14 bpp values on typical embedded 32-bit processor and a little resulting gain in space.

JPEG LS

General description JPEG LS is a lossless or near-lossless compression standard for continuous-tone images. Its official designation is ISO-14495-1/ITU-T.87. It is a simple and efficient baseline algorithm which consists of two independent and distinct stages called modeling and encoding. JPEG LS was developed with the aim of providing a low-complexity lossless and near-lossless image compression standard that could offer better compression efficiency than lossless JPEG. It was developed because at the time, the Huffman coding-based JPEG lossless standard and other standards were limited in their compression performance. Total decorrelation cannot be achieved by first order entropy of the prediction residuals employed by these inferior standards. JPEG LS, on the other hand, can obtain good decorrelation. Part 1 of this standard was finalized in 1999. Part 2, released in 2003, introduced extensions such as arithmetic coding. The core of JPEG LS is based on the LOCO-I algorithm, that relies on prediction, residual modeling, and context-based coding of the residuals. Most of the low complexity of this technique comes from the assumption that prediction residuals follow a two-sided geometric distribution (also called a discrete Laplace distribution) and from the use of Golomb-like codes, which are known to be approximately optimal for geometric distributions. Besides lossless compression, JPEG LS also provides a lossy mode ("near-lossless") where the maximum absolute error can be controlled by the encoder.

Performance Compression for JPEG LS is generally much faster than JPEG 2000 and much better than the original lossless JPEG standard. Compression for JPEG LS is generally slightly worse than JPEG 2000, but this highly depends on the image content. Decompression for JPEG LS is generally much faster than JPEG 2000, but this depends on the exact software decoder implementations. This statement is valid for open-source implementations.

Application support IrfanView image viewer and editor has full read+write support for JPEG LS image codec (.jls file extension). XnView image viewer and editor claims the capability to read JPEG LS (.jls) files. However, XnViewMP v0.98.1 can not read JPEG LS files created by IrfanView v4.54. CharLS – an open-source JPEG LS codec. Thomas Richter's libjpeg – an open-source JPEG LS codec. UBC JPEG LS codec David Clunie's JPEG LS codec Hewlett-Packard JPEG-LS reference encoder v1.00 (direct link to zipfile)

LOCO-I algorithm Prior to encoding, there are two essential steps to be done in the modeling stage: decorrelation (prediction) and error modeling.

… excerpt ends here. Continue reading the full article.

Illustrations

Lossless JPEG: Figure 2: Simplified block diagrams for lossless mode
Figure 2: Simplified block diagrams for lossless mode
Lossless JPEG: Figure 3: Three[disputed – discuss] neighboring samples around the sample to be predicted
Figure 3: Three[disputed – discuss] neighboring samples around the sample to be predicted

Worked examples

Example 1 — a first encounter with Lossless JPEG

Start with the simplest possible case. Write down what Lossless JPEG claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Lossless JPEG before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Lossless JPEG ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Lossless JPEG

In research
Lossless JPEG appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Lossless JPEG in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Lossless JPEG is common in secondary-school and first-year university syllabi. It links to neighbouring topics Graphics file formats, Image compression, JPEG, so understanding it makes those chapters shorter.
In everyday life
Look for Lossless JPEG outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Lossless JPEG” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Lossless JPEG in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Lossless JPEG means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Lossless JPEG out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Lossless JPEG in simple terms?

Lossless JPEG is a 1993 addition to JPEG standard by the Joint Photographic Experts Group to enable lossless compression. However, the term may also be used to refer to all lossless compression schemes developed by the group, including JPEG 2000, JPEG LS, and JPEG XL.

Why does Lossless JPEG matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Lossless JPEG?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Lossless JPEG.

Tags

  • Graphics file formats
  • Image compression
  • JPEG
  • Lossless compression algorithms

Keep exploring