Lossless JPEG

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 and JPEG-LS.

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.[1] 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).[2]

Lossless mode of operation

DPCM concept
Figure 1: DPCM encoder model
Lossless encode
Figure 2: Simplified block diagrams for lossless mode
Figure 3: Three neighboring samples around the sample to be predicted

Lossless JPEG[3] 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.[4] 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.

Selection-value Prediction
0 No prediction
1 A
2 B
3 C
4 A + B – C
5 A + (B – C)/2
6 B + (A – C)/2
7 (A + B)/2

Typically, compressions using lossless operation mode can achieve around 2:1 compression ratio for color images.[5] 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 14bpp values on typical embedded 32-bit processor and a little resulting gain in space.


JPEG-LS is a lossless/near-lossless compression standard for continuous-tone images.[6] Its official designation is ISO-14495-1/ITU-T.87.[7] 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.[8][9] 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,[10] 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. Compression for JPEG-LS is generally much faster than JPEG 2000 and much better than the original lossless JPEG standard.

LOCO-I algorithm

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


In the LOCO-I algorithm, primitive edge detection of horizontal or vertical edges is achieved by examining the neighboring pixels of the current pixel X as illustrated in Fig.3. The pixel labeled by B is used in the case of a vertical edge while the pixel located at A is used in the case of a horizontal edge. This simple predictor is called the Median Edge Detection (MED) predictor[11] or LOCO-I predictor. The pixel X is predicted by the LOCO-I predictor according to the following guesses:

The three simple predictors are selected according to the following conditions: (1) it tends to pick B in cases where a vertical edge exists left of the X, (2) A in cases of an horizontal edge above X, or (3) A + B – C if no edge is detected.

Context modeling

The JPEG-LS algorithm estimates the conditional expectations of the prediction errors using corresponding sample means within each context Ctx. The purpose of context modeling is that the higher order structures like texture patterns and local activity of the image can be exploited by context modeling of the prediction error. Contexts are determined by obtaining the differences of the neighboring samples which represents the local gradient:

The local gradient reflects the level of activities such as smoothness and edginess of the neighboring samples. Notice that these differences are closely related to the statistical behavior of prediction errors. Each one of the differences found in the above equation is then quantized into roughly equiprobable and connected regions. For JPEG-LS, the differences g1, g2, and g3 are quantized into 9 regions and the region are indexed from −4 to 4. The purpose of the quantization is to maximize the mutual information between the current sample value and its context such that the high-order dependencies can be captured. One can obtain the contexts based on the assumption that

After merging contexts of both positive and negative signs, the total number of contexts is contexts. A bias estimation could be obtained by dividing cumulative prediction errors within each context by a count of context occurrences. In LOCO-I algorithm, this procedure is modified and improved such that the number of subtractions and additions are reduced. The division-free bias computation procedure is demonstrated in [2]. Prediction refinement can then be done by applying these estimates in a feedback mechanism which eliminates prediction biases in different contexts.

Coding corrected prediction residuals

In the regular mode of JPEG-LS, the standard uses Golomb–Rice codes which are a way to encode non-negative run lengths. Its special case with the optimal encoding value 2k allows simpler encoding procedures.

Run length coding in uniform areas

Since Golomb–Rice codes are quite inefficient for encoding low entropy distributions because the coding rate is at least one bit per symbol, significant redundancy may be produced because the smooth regions in an image can be encoded at less than 1 bit per symbol. To avoid having excess code length over the entropy, one can use alphabet extension which codes blocks of symbols instead of coding individual symbols. This spreads out the excess coding length over many symbols. This is the “run” mode of JPEG-LS and it is executed once a flat or smooth context region characterized by zero gradients is detected. A run of west symbol “a” is expected and the end of run occurs when a new symbol occurs or the end of line is reached. The total run of length is encoded and the encoder would return to the “regular” mode.

JPEG 2000

JPEG 2000 includes a lossless mode based on a special integer wavelet filter (biorthogonal 3/5). JPEG 2000's lossless mode runs more slowly and has often worse compression ratios than JPEG-LS on artificial and compound images.[12][13] JPEG 2000 fares better than the UBC implementation of JPEG-LS on digital camera pictures.[14] JPEG 2000 is also scalable, progressive, and more widely implemented.


JPEG XT includes a lossless integer-to-integer DCT transform mode based on wavelet compression from JPEG 2000.


  1. ^ Murchison, Ken (April 4, 1999). "Lossless JPEG support for libjpeg". Newsgroupcomp.protocols.dicom. Usenet: 372618DE.969A19D9@oceana.com. Retrieved December 12, 2017. A number of people have been interested in my patch which adds lossless JPEG support (per the original spec -- not JPEG-LS) to libjpeg v6b. I have decided to make this patch available via my ftp site (ftp://ftp.oceana.com/pub/ljpeg-6b.tar.gz).
  2. ^ "JPEG - JPEG XT". jpeg.org.
  3. ^ Pennebaker, W. B. & Mitchell, J. L. (1993). JPEG Still Image Data Compression Standard. New York: Van Nostrand Reinhold. ISBN 978-0-442-01272-4.
  4. ^ ITU-T. ISO DIS 10918-1 Digital compression and coding of continuous-tone still images (JPEG). Recommendation T.81.
  5. ^ Wallace, C. K. (1991). "The JPEG still picture compression standard". Communications of the ACM. 34 (4): 31–44. CiteSeerX doi:10.1109/30.125072.
  6. ^ "HP Labs LOCO-I/JPEG-LS Home Page". Hewlett-Packard Development Company. May 13, 2005. Retrieved 24 October 2011.
  7. ^ "T.87 : Information technology – Lossless and near-lossless compression of continuous-tone still images – Baseline". International Telecommunication Union. Retrieved 24 October 2011.
  8. ^ M. J. Weinberger, G. Seroussi, and G. Sapiro, “LOCO-I: A low complexity, context-based, lossless image compression algorithm,” in Proc. 1996 Data Compression Conference, Snowbird, UT, Mar. 1996, pp. 140–149.
  9. ^ M. Weinberger, G. Seroussi, and G. Sapiro, “The LOCO-I lossless image compression algorithm: Principles and standardization into JPEG-LS,” IEEE Trans. Image Processing, vol. 9, no. 8, pp. 1309–1324, Aug. 2000, originally as Hewlett-Packard Laboratories Technical Report No. HPL-98-193R1, November 1998, revised October 1999. Available from [1].
  10. ^ http://www.hpl.hp.com/loco/HPL-98-193R1.pdf LOCO-I algorithm
  11. ^ Memon, Nasir D.; Wu, Xiaolin; Sippy, V. & Miller, G. (1997). "Interband coding extension of the new lossless JPEG standard". Proc. SPIE Int. Soc. Opt. Eng. 3024 (47): 47–58. Bibcode:1997SPIE.3024...47M. doi:10.1117/12.263270.
  12. ^ "Archived copy" (PDF). Archived from the original (PDF) on 2006-07-02. Retrieved 2006-06-17.CS1 maint: Archived copy as title (link)
  13. ^ "Archived copy". Archived from the original on 2007-02-22. Retrieved 2007-02-07.CS1 maint: Archived copy as title (link)
  14. ^ "Lossless Photo Compression Benchmark". www.imagecompression.info.

External links

CodedColor PhotoStudio Pro

CodedColor is a bitmap graphics editor and image organizer for computers running the Microsoft Windows operating system, and is published by 1STEIN.

CodedColor contains different tools for image editing and viewing. Additionally, it has other features such as web album export, annotations, database and keyword searching, contact sheets, screen shows, batch conversion, photo finishing, red eye correction, screen capture and TWAIN import.

Comparison of image viewers

This article presents a comparison of image viewers and image organizers which can be used for image viewing.


Digital Imaging and Communications in Medicine (DICOM) is the standard for the communication and management of medical imaging information and related data. DICOM is most commonly used for storing and transmitting medical images enabling the integration of medical imaging devices such as scanners, servers, workstations, printers, network hardware, and picture archiving and communication systems (PACS) from multiple manufacturers. It has been widely adopted by hospitals, and is making inroads into smaller applications like dentists' and doctors' offices.

DICOM files can be exchanged between two entities that are capable of receiving image and patient data in DICOM format. The different devices come with DICOM Conformance Statements which clearly state which DICOM classes they support, and the standard includes a file format definition and a network communications protocol that uses TCP/IP to communicate between systems.

The National Electrical Manufacturers Association (NEMA) holds the copyright to the published standard which was developed by the DICOM Standards Committee, whose members are also partly members of NEMA. It is also known as NEMA standard PS3, and as ISO standard 12052:2017 "Health informatics -- Digital imaging and communication in medicine (DICOM) including workflow and data management".


FELICS, which stands for Fast Efficient & Lossless Image Compression System, is a lossless image compression algorithm

that performs 5-times faster than the original lossless JPEG codec and achieves a similar compression ratio.


FFmpeg is a free software project consisting of a vast software suite of libraries and programs for handling video, audio, and other multimedia files and streams. At its core is the FFmpeg program itself, designed for command-line-based processing of video and audio files, and widely used for format transcoding, basic editing (trimming and concatenation), video scaling, video post-production effects, and standards compliance (SMPTE, ITU). FFmpeg includes libavcodec, an audio/video codec library used by many commercial and free software products, libavformat (Lavf), an audio/video container mux and demux library, and the core ffmpeg command line program for transcoding multimedia files. FFmpeg is published under the GNU Lesser General Public License 2.1+ or GNU General Public License 2+ (depending on which options are enabled).The name of the project is inspired by the MPEG video standards group, together with "FF" for "fast forward". The logo uses a zigzag pattern that shows how MPEG video codecs handle entropy encoding.FFmpeg is part of the workflow of hundreds of other software projects, and its libraries are a core part of software media players such as VLC, and has been included in core processing for YouTube and the iTunes inventory of files. Codecs for the encoding and/or decoding of most of all known audio and video file formats is included, making it highly useful for the transcoding of common and uncommon media files into a single common format.

FastStone Image Viewer

FastStone Image Viewer is an image viewer and organizer for Microsoft Windows, provided free of charge for personal and educational use, as of version 7.0.

The program also includes basic image editing tools.

Free Lossless Image Format

Free Lossless Image Format (FLIF) is a lossless image format (current version FLIF16 specification) claiming to outperform PNG, lossless WebP, lossless BPG and lossless JPEG 2000 in terms of compression ratio on a variety of inputs.FLIF supports a form of progressive interlacing (a generalization of the Adam7 algorithm) with which any partial download of an image file can be used as a lossy encoding of the entire image.

Helicon Photo Safe

Helicon Photo Safe is a proprietary freeware and commercial digital image organization and protection tool produced by Helicon Soft Ltd. It is designed to be an image viewer and organizer which works together with the editing program Helicon Filter, as well as an image encryption tool. It is intended to be integrated into the future Helicon Filter 5.


Huffyuv (or HuffYUV) is a lossless video codec created by Ben Rudiak-Gould which is meant to replace uncompressed YCbCr as a video capture format. The codec can also compress in the RGB color space.

"Lossless" means that the output from the decompressor is bit-for-bit identical with the original input to the compressor. Lossless only occurs when the compression color space matches the input and output color space. When the color spaces do not match, a low loss compression is performed.

Huffyuv's algorithm is similar to that of lossless JPEG, in that it predicts each sample and then Huffman-encodes the error.

JLS (disambiguation)

JLS are an English boy band.

JLS may also refer to:

Jodio Loco Sucio, a band in Zaragoza, Spain

JLS (album), an album by Jodio Loco Sucio

.jls, an extension for Lossless JPEG files

Jane Lathrop Stanford Middle School, a middle school in Palo Alto, California

Jarcho-Levin Syndrome

Journal of Libertarian Studies, a scholarly journal published by the Ludwig von Mises Institute and Lew Rockwell

The Java Language Specification, the specification for the programming language Java.

JPEG 2000

JPEG 2000 (JP2) is an image compression standard and coding system. It was created by the Joint Photographic Experts Group committee in 2000 with the intention of superseding their original discrete cosine transform-based JPEG standard (created in 1992) with a newly designed, wavelet-based method. The standardized filename extension is .jp2 for ISO/IEC 15444-1 conforming files and .jpx for the extended part-2 specifications, published as ISO/IEC 15444-2. The registered MIME types are defined in RFC 3745. For ISO/IEC 15444-1 it is image/jp2.

JPEG 2000 code streams are regions of interest that offer several mechanisms to support spatial random access or region of interest access at varying degrees of granularity. It is possible to store different parts of the same picture using different quality.


JPEG XR (JPEG extended range) is a still-image compression standard and file format for continuous tone photographic images, based on technology originally developed and patented by Microsoft under the name HD Photo (formerly Windows Media Photo). It supports both lossy and lossless compression, and is the preferred image format for Ecma-388 Open XML Paper Specification documents.

Support for the format is available in Adobe Flash Player 11.0, Adobe AIR 3.0, Sumatra PDF 2.1, Windows Imaging Component, .NET Framework 3.0, Windows Vista, Windows 7, Windows 8, Internet Explorer 9, Internet Explorer 10, Internet Explorer 11, Pale Moon 27.2. As of August 2014, there were still no cameras that shoot photos in the JPEG XR (.JXR) format.


libjpeg is a free library with functions for handling the JPEG image data format. It implements a JPEG codec (encoding and decoding) alongside various utilities for handling JPEG data.

It is written in C and distributed as free software together with its source code under the terms of a custom permissive (BSD-like) free software license, which demands attribution.

The original variant is maintained and published by the Independent JPEG Group (IJG). Meanwhile, there are several forks with additional features.

JPEG JFIF images are widely used on the Web. The amount of compression can be adjusted to achieve the desired trade-off between file size and visual quality.

Lossy compression

In information technology, lossy compression or irreversible compression is the class of data encoding methods that uses inexact approximations and partial data discarding to represent the content. These techniques are used to reduce data size for storing, handling, and transmitting content. The different versions of the photo of the cat to the right show how higher degrees of approximation create coarser images as more details are removed. This is opposed to lossless data compression (reversible data compression) which does not degrade the data. The amount of data reduction possible using lossy compression is much higher than through lossless techniques.

Well-designed lossy compression technology often reduces file sizes significantly before degradation is noticed by the end-user. Even when noticeable by the user, further data reduction may be desirable (e.g., for real-time communication, to reduce transmission times, or to reduce storage needs).

Lossy compression is most commonly used to compress multimedia data (audio, video, and images), especially in applications such as streaming media and internet telephony. By contrast, lossless compression is typically required for text and data files, such as bank records and text articles. It can be advantageous to make a master lossless file which can then be used to produce additional copies from. This allows one to avoid basing new compressed copies off of a lossy source file, which would yield additional artifacts and further unnecessary information loss.


MicroDicom is a free DICOM viewer for Windows.

MicroDicom is application for primary processing and preservation of medical images in DICOM format. It is possible to open DICOM images produced by medical equipment (MRI, PET, CT, ...). It is also possible to open other image formats - BMP, GIF, JPEG, PNG, TIFF, ....

It is equipped with most common tools for manipulation of DICOM images and it has an intuitive user interface.

It is free to use and easily accessible to most. It has also been used by the U.S. Department of Veterans' Affairs to get medical data on their state of health.

Portable Network Graphics

Portable Network Graphics (PNG, pronounced PEE-en-JEE or PING) is a raster-graphics file-format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange Format (GIF).

PNG supports palette-based images (with palettes of 24-bit RGB or 32-bit RGBA colors), grayscale images (with or without alpha channel for transparency), and full-color non-palette-based RGB/RGBA images (with or without alpha channel). The PNG working group designed the format for transferring images on the Internet, not for professional-quality print graphics, and therefore it does not support non-RGB color spaces such as CMYK. A PNG file contains a single image in an extensible structure of "chunks", encoding the basic pixels and other information such as textual comments and integrity checks documented in RFC 2083.PNG files nearly always use the file extension PNG or png and are assigned MIME media type image/png.

PNG was published as informational RFC 2083 in March 1997 and as an ISO/IEC standard in 2004.

Raw image format

A camera raw image file contains minimally processed data from the image sensor of either a digital camera, or motion picture film scanner, or other image scanner. Raw files are named so because they are not yet processed and therefore are not ready to be printed or edited with a bitmap graphics editor. Normally, the image is processed by a raw converter in a wide-gamut internal color space where precise adjustments can be made before conversion to a "positive" file format such as TIFF or JPEG for storage, printing, or further manipulation. This often encodes the image in a device-dependent color space. There are dozens, if not hundreds, of raw formats in use by different models of digital equipment (like cameras or film scanners).


Tag Image File Format/Electronic Photography (TIFF/EP) is a digital image file format standard – ISO 12234-2, titled "Electronic still-picture imaging – Removable memory – Part 2: TIFF/EP image data format". This is different from the Tagged Image File Format, which is a standard administered by Adobe currently called "TIFF, Revision 6.0 Final – June 3, 1992".

The TIFF/EP standard is based on a subset of the Adobe TIFF standard, and a subset of the JEITA Exif standard, with some differences and extensions.

One of the uses of TIFF/EP is as a raw image format. A characteristic of most digital cameras (but excluding those using the Foveon X3 sensor or similar, hence especially Sigma cameras) is that they use a color filter array (CFA). Software processing a raw image format for such a camera needs information about the configuration of the color filter array, so that the raw image can identify separate data from the individual sites of the sensor. Ideally this information is held within the raw image file itself, and TIFF/EP uses the tags that begin "CFA", CFARepeatPatternDim and CFAPattern, which are only relevant for raw images.

This standard has not been adopted by most camera manufacturers – Exif/DCF is the current industry standard file organisation system which uses the Exchangeable image file format. However, TIFF/EP provided a basis for the raw image formats of a number of cameras. One example is Nikon's NEF raw file format, which uses the tag TIFF/EPStandardID (with value Adobe's DNG (Digital Negative) raw file format was based on TIFF/EP, and the DNG specification states "DNG... is compatible with the TIFF-EP standard". Several cameras use DNG as their raw file format, so in that limited sense they use TIFF/EP too.


WinZip is a trialware file archiver and compressor for Windows, macOS, iOS and Android developed by WinZip Computing (formerly Nico Mak Computing). It can create archives in Zip file format, and unpack some other archive file formats.


This page is based on a Wikipedia article written by authors (here).
Text is available under the CC BY-SA 3.0 license; additional terms may apply.
Images, videos and audio are available under their respective licenses.