Coder Social home page Coder Social logo

jpeg-ls's Introduction

language build build

JPEG-LS encoder

A simple JPEG-LS baseline (ITU-T T.87) image compressor (encoder) in C language.

 

Background of JPEG-LS

JPEG-LS (JLS) is a lossless/lossy image compression standard which has the best lossless compression ratio compared to PNG, Lossless-JPEG2000, Lossless-WEBP, Lossless-HEIF, etc.

The standard specification of JPEG-LS is ITU-T T.87 [1], see https://www.itu.int/rec/T-REC-T.87/en

JPEG-LS uses the maximum difference between the pixels before and after compression (NEAR value) to control distortion, NEAR=0 is the lossless mode; NEAR>0 is the lossy mode, the larger the NEAR, the greater the distortion and the greater the compression ratio.

The file suffix name for JPEG-LS compressed image is .jls .

 

Development progress

  • gray 8 bit image lossless encode (near=0)
  • gray 8 bit image lossy encode (near-lossless, near≥1)
  • gray 9-16 bit image lossless encode (near=0)
  • gray 9-16 bit image lossy encode (near-lossless, near≥1)
  • RGB 24 bit image lossless encode (near=0)
  • RGB 24 bit image lossy encode (near-lossless, near≥1)
  • RGB 48 bit image lossless encode (near=0)
  • RGB 24 bit image lossy encode (near-lossless, near≥1)

 

Code list

The code is in pure-C. See src folder:

  • JLS.c : Implement a JLS encoder
  • JLS.h : Expose the JLS encoder function to users
  • JLSMain.c : A main program with main() function, which call the JLS encoder to achieve image file compression.

 

Compile

Compile in Windows (CMD)

If you installed MinGW Compiler for Windows, you can compile using the command line (CMD).

gcc src/*.c -o JLSencode.exe -O3 -Wall

We'll get the executable file JLSencoder.exe . Here I've compiled it for you, see JLSencoder.exe .

Compile in Linux

Run the command in the current directory:

gcc src/*.c -o JLSencode -O3 -Wall

We'll get the binary file JLSencoder .

 

Run image compression

This program can compress the following three types of image file to .jls compressed file.

There are some PGM and PPM files in testimage directory.

Run image compress in Windows (CMD)

Use the following command to compress a image file to a .jls file.

.\JLSencode.exe  <input-image-file>  <output-file(.jls)>  [near]

Where [near] is a optional parameter of range 0~9 :

  • 0 : lossless (default)
  • 1~9 : lossy. The larger the near value, the higher distortion and the lower compressed size.

For example, the following command to compress rgb1.ppm in testimage folder to rgb1.jls with near=1

.\JLSencode.exe  testimage\rgb1.ppm  rgb1.jls  1

Run image compress in Linux

Use the following command to compress a image file to a .jls file.

./JLSencode  <input-image-file>  <output-file(.jls)>  [near]

 

Appendix: How to decompress .jls file?

This repo do not have a JPEG-LS decompressor. There are several ways to decompress a .jls file:

  • The most convenient method: Try this website to view .jls image online (it may not work).
  • Use other JPEG-LS code or libraries such as UBC's JPEG-LS code [3] or CharLS [4].
  • Use python pillow library and pillow_jpls library, see [5].

 

Reference

[1] ITU-T T.87 : JPEG-LS baseline specification : https://www.itu.int/rec/T-REC-T.87/en

[2] PNM Image File Specification : https://netpbm.sourceforge.net/doc/pnm.html

[3] UBC's JPEG-LS baseline Public Domain Code : http://www.stat.columbia.edu/~jakulin/jpeg-ls/mirror.htm

[4] CharLS, a C++ JPEG-LS library implementation : https://github.com/team-charls/charls

[5] pillow-jpls library for Python - PyPI : https://pypi.org/project/pillow-jpls

[6] FPGA-based Verilog JPEG-LS encoder (basic version which support 8-bit gray lossless and lossy) : https://github.com/WangXuan95/FPGA-JPEG-LS-encoder

[7] FPGA-based Verilog JPEG-LS encoder (ultra high performance version which support 8-bit gray lossless) : https://github.com/WangXuan95/UH-JLS

jpeg-ls's People

Contributors

wangxuan95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.