Giter Site home page Giter Site logo

wangxuan95 / nbli Goto Github PK

View Code? Open in Web Editor NEW
61.0 2.0 11.0 3.64 MB

NBLI is a fast, better lossless image compression algorithm.

Home Page: https://gitee.com/WangXuan95/NBLI

License: GNU General Public License v3.0

C 1.05% C++ 98.95%
image-compression image-compressor image-encoder lossless-image-compression

nbli's Introduction

language build build

 

NBLI: New Bee Lossless Image Compression

NBLI (v0.4) is a fast, better lossless compression algorithm, which support RGB 24-bit and Gray 8-bit image. This repo provide:

  • fNBLI : The optimized NBLI, currently only provide executable file rather than source code.
  • NBLI : The prototype of NBLI, provide both executable file and source code.

Compared to the popular state-of-the-art lossless image formats, fNBLI is outstanding in both speed and compression ratio:

  • The compression ratio of fNBLI is between JPEG-XL(-6) and JPEG-XL(-8)
  • fNBLI compresses as same faster as JPEG-XL(-1)
  • fNBLI decompresses faster than PNG and JPEG-XL(-1)
Lossless Formats Compressed Size (vs. PNG) Compress Speed Decompress Speed
BMF (-s) -35.07% 1.3 MB/s 1.5 MB/s
Gralic -34.32% 4.2 MB/s 3.5 MB/s
NBLI (-ga) -30.37% 14.7 MB/s 17.0 MB/s
JPEG-XL (-e 8) -30.25% 0.6 MB/s 14.5 MB/s
fNBLI -29.79% 94.8 MB/s 149.1 MB/s
JPEG-XL (-e 6) -28.63% 2.4 MB/s 19.1 MB/s
JPEG-XL (-e 3) -26.53% 19.2 MB/s 27.9 MB/s
QLIC2 -23.31% 136.9 MB/s 135.7 MB/s
WEBP -5 -22.53% 3.7 MB/s 82.8 MB/s
JPEG-XL (-e 1) -13.49% 95.2 MB/s 71.0 MB/s
PNG (optimized) 0.00% 0.9 MB/s 153.7 MB/s
JPEG2000 +4.60% 12.8 MB/s 14.9 MB/s
PNG +5.13% 12.2 MB/s 121.5 MB/s
QOI +19.68% 214.7 MB/s 215.7 MB/s
Uncompressed +114.77%

The dataset of above comparison is the training image set of CLIC2021 competition, which includes 585 RGB 24-bit images, totaling 4GB (the downloaded zip file is about 2GB). All above compressor/decompressor are tested in single-threaded, See Lossless-Image-Compression-Benchmark for detail.

 

Compile NBLI.exe

Compile in Windows CMD

If you installed MinGW Compiler for Windows, you can run following command to compile NBLI, getting the executable file NBLI.exe

g++ src_NBLI\main.cpp src_NBLI\imageio\*.cpp src_NBLI\NBLI\NBLI.cpp -static-libgcc -static-libstdc++ -O3 -Wall -o NBLI.exe

Compile in Linux

Run following command to compile NBLI, getting the binary file NBLI

g++ src_NBLI/main.cpp  src_NBLI/imageio/*.cpp src_NBLI/NBLI/NBLI.cpp -static-libgcc -static-libstdc++ -O3 -Wall -o NBLI

 

Use fNBLI.exe

Run fNBLI.exe without any parameters to display its usage:

> .\fNBLI.exe
|----------------------------------------------------------------------------------|
| fNBLI : fast new-bee lossless image codec (single-threaded, v0.4, 202409)        |
| Copyright (C) 2024 Xuan Wang.                                                    |
|----------------------------------------------------------------------------------|
| this CPU: AVX2 supported                                                         |
|----------------------------------------------------------------------------------|
| Usage:                                                                           |
|   fNBLI [-switches]  <in1> [-o <out1>]  [<in2> [-o <out2]]  ...                  |
|                                                                                  |
| To compress:                                                                     |
|   <in>  can be .bmp, .png, .pgm, .ppm, .pnm, or .qoi (RGB-24bit or Gray-8bit)    |
|   <out> can be .fnbli. It will be generated if not specified.                    |
|                                                                                  |
| To decompress:                                                                   |
|   <in>  can be .fnbli                                                            |
|   <out> can be .bmp, .jls, .pgm, .ppm, .pnm, or .qoi                             |
|         It will be generated if not specified.                                   |
|                                                                                  |
| switches: -v : verbose                                                           |
|           -f : force overwrite of output file                                    |
|           -x : putting CRC32 when compressing                                    |
|----------------------------------------------------------------------------------|

Take the images I provided in the ./image/ folder as examples :

Compress a .pgm file (Gray image) to a .fnbli file :

fNBLI.exe -vf image\Gray.pgm -o Gray.fnbli

Compress a .ppm file (RGB image) to a .fnbli file :

fNBLI.exe -vf image\RGB.ppm -o RGB.fnbli

Compress a .png file to .fnbli file :

fNBLI.exe -vf image\RGB.png -o RGB.fnbli

Decompress the .fnbli file back to a .ppm file :

fNBLI.exe -vf RGB.fnbli -o RGB.ppm

Decompress the .fnbli file back to a .bmp file :

fNBLI.exe -vf RGB.fnbli -o RGB.bmp

 

Use NBLI.exe

Run NBLI.exe without any parameters to display its usage:

> .\NBLI.exe
|----------------------------------------------------------------------------------|
| NBLI : new-bee lossless image codec (single-threaded, v0.4, 202409)              |
| Copyright (C) 2024 Xuan Wang.                                                    |
|----------------------------------------------------------------------------------|
| Usage:                                                                           |
|   NBLI [-switches]  <in1> [-o <out1>]  [<in2> [-o <out2]]  ...                   |
|                                                                                  |
| To compress:                                                                     |
|   <in>  can be .bmp, .png, .pgm, .ppm, .pnm, or .qoi (RGB-24bit or Gray-8bit)    |
|   <out> can be .nbli. It will be generated if not specified.                     |
|                                                                                  |
| To decompress:                                                                   |
|   <in>  can be .nbli                                                             |
|   <out> can be .bmp, .jls, .pgm, .ppm, .pnm, or .qoi                             |
|         It will be generated if not specified.                                   |
|                                                                                  |
| switches: -v   : verbose                                                         |
|           -f   : force overwrite of output file                                  |
|           -x   : putting CRC32 when compressing                                  |
|           -0~7 : distortion level. 0=lossless (default), 1~7=lossy               |
|           -g   : use golomb arithmetic coding tree instead of ANS coding (slower)|
|           -a   : use advanced predictor (extremely slow)                         |
|----------------------------------------------------------------------------------|

Take the images I provided in the ./image/ folder as examples :

Compress a .png file to a .nbli file :

NBLI.exe -vf image\RGB.png -o RGB.nbli

Compress a .png file to a .nbli file, use Golomb coding tree (-g) and Advanced predictor (-a) to obtain higher compression ratio :

NBLI.exe -vfga image\RGB.png -o RGB.nbli

Compress a .png file to a .nbli file, set distortion level to 1 (lossy!!) :

NBLI.exe -vf1 image\RGB.png -o RGB.nbli

Decompress the .nbli file back to a .bmp file :

NBLI.exe -vf RGB.nbli -o RGB.bmp

nbli's People

Contributors

wangxuan95 avatar

Stargazers

冯浩轩 avatar Jonathan Brown avatar chuangming huang avatar wtj avatar  avatar  avatar Bruce Wayne avatar Zhenghao He avatar  avatar  avatar  avatar DaLaoYuan avatar  avatar bk liang avatar  avatar  avatar  avatar Longshan Du avatar Dengmiao Yu avatar Dom Chen avatar sangsang avatar DarkSky avatar  avatar wym avatar TabulaRasaKLD avatar  avatar leeyi avatar ChenHao avatar Timothy avatar openFPGA avatar  avatar Ling avatar Yuning Li avatar  avatar  avatar  avatar  avatar wzy avatar yh119 avatar 李東轩 avatar sczh01 avatar  avatar  avatar BigPig avatar  avatar  avatar cheukswiss avatar Darren Cheng avatar  avatar guowei avatar zhouxin avatar Redns avatar Yunkun Liao avatar End avatar king avatar Wendell avatar  avatar Qianjiaming avatar JinfengZhang avatar  avatar coolxv avatar

Watchers

 avatar  avatar

nbli's Issues

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.