8000 GitHub - WangXuan95/ImCvt: A lightweight image converter which supports PNG, PNM, BMP, QOI, JPEG-LS, and H.265 intra-frame.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

WangXuan95/ImCvt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

language build build

ImCvt

ImCvt is a image format converter which supports several image formats. ImCvt is written in C (C99), contains the simplest, standalone implementation of the encoders/decoders of some image formats, the purpose is to help one understand these image compression formats and algorithms swiftly.

ImCvt supports:

format suffix supported color convert from (decode) convert to (encode) source code
PNM .pnm gray8 rgb24 ✅ fully support ✅ fully support 150 lines of C
PNG .png gray8 rgb24 ❎ unsupported ☑️ partially support 240 lines of C
BMP .bmp gray8 rgb24 ☑️ partially support ☑️ partially support 180 lines of C
QOI .qoi rgb24 ✅ fully support ✅ fully support 240 lines of C
JPEG-LS .jls gray8 rgb24 ❎ unsupported ☑️ partially support 480 lines of C
JPEG-LS ext .jlsx gray8 ☑️ support ☑️ support 760 lines of C
H.265 .h265 gray8 ❎ unsupported ☑️ partially support 1730 lines of C

Illustration of these image formats:

format Illustration
PNM PNM (Portable Any Map), PGM (Portable Gray Map), and PPM (Portable Pix Map) are simple uncompressed image formats which store raw pixels.
PNG PNG (Portable Network Graph) is the most popular lossless image compression format.
BMP BMP (Bitmap Image File) is a popular uncompressed image formats which store raw pixels.
QOI QOI (Quite OK Image) is a simple, fast lossless RGB image compression format. This project implements a simple QOI encoder/decoder in only 240 lines of C.
JPEG-LS JPEG-LS is a lossless/lossy image compression standard which can get better grayscale compression ratio compared to PNG and Lossless-WEBP. 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 specification of JPEG-LS is ITU-T T.87 . ImCvt implements a simple JPEG-LS encoder in only 480 lines of C. However, ImCvt do not support JPEG-LS decoder yet. Here are two ways to decompress a .jls file: (1) Use this website to view .jls image online (but the website may not work sometimes). (2) Use UBC's JPEG-LS encoder/decoder .
JPEG-LS extension This code is my implementation of JPEG-LS extension according to ITU-T T.870 specification for educational purpose. Note that the file header does NOT follow the specification!
H.265 H.265/HEVC is a video coding standard. This project implements a lightweight grayscale 8-bit H.265/HEVC intra-frame image compressor in only 1730 lines of C for educational purpose. Note that this code only offers H.265/HEVC compressor instead of decompressor. To decompress and view the compressed .h265 image file, you can use File Viewer Plus or Elecard HEVC Analyzer . For more knowledge about H.265, see H.265/HEVC 帧内编码详解:CU层次结构、预测、变换、量化、编码 .

More illustration about this H.265 image encoder:

  • Quality parameter can be 0~4, corresponds to Quantize Parameter (QP) = 4, 10, 16, 22, 28.
  • CTU : 32x32
  • CU : 32x32, 16x16, 8x8
  • TU : 32x32, 16x16, 8x8, 4x4
  • The maximum depth of CU splitting into TUs is 1 (each CU is treated as a TU, or divided into 4 small TUs, while the small TUs are not divided into smaller TUs).
  • part_mode: The 8x8 CU is treated as a PU (PART_2Nx2N), or divided into 4 PUs (PART_NxN)
  • Supports all 35 prediction modes
  • Simplified RDOQ (Rate Distortion Optimized Quantize)

 

 

Compile

compile in Windows (MinGW)

If you installed MinGW, run following compiling command in CMD:

gcc src\*.c -O3 -o ImCvt.exe

which will get executable file ImCvt.exe

compile in Windows (MSVC)

Also, you can use MSVC to compile. If you added MSVC (cl.exe) to your environment, run following compiling command in CMD:

cl src\*.c /Ox /FeImCvt.exe

which will get executable file ImCvt.exe

compile in Linux (gcc)

gcc src/*.c -O3 -o ImCvt

which will get Linux binary file ImCvt

 

 

Usage

Run the program without any parameters to display usage:

> .\ImCvt.exe
|-----------------------------------------------------------------------|
| ImageConverter (v0.6)  by https://github.com/WangXuan95/              |
|-----------------------------------------------------------------------|
| Usage:                                                                |
|   ImCvt [-switches]  <in1> -o <out1>  [<in2> -o <out2>]  ...          |
|                                                                       |
|-----------------------------------------------------------------------|
| Where <in> and <out> can be:                                          |
|--------|---------------------------------|-------|--------|-----|-----|
|        |                                 | gray  | RGB    |     |     |
| suffix |          format name            | 8-bit | 24-bit | in  | out |
|--------|---------------------------------|-------|--------|-----|-----|
| .bmp   | Bitmap Image File (BMP)         | yes   | yes    | yes | yes |
| .pnm   | Portable Any Map (PNM)          | yes   | yes    | yes | yes |
| .pgm   | Portable Gray Map (PGM)         | yes   | no     | yes | yes |
| .ppm   | Portable Pix Map (PPM)          | no    | yes    | yes | yes |
| .qoi   | Quite OK Image (QOI)            | no    | yes    | yes | yes |
| .png   | Portable Network Graphics (PNG) | yes   | yes    | no  | yes |
| .jls   | JPEG-LS Image (JLS)             | yes   | yes    | no  | yes |
| .jlsx  | JPEG-LS extension (ITU-T T.870) | yes   | no     | yes | yes |
| .h265  | H.265/HEVC Image                | yes   | no     | no  | yes |
|--------|---------------------------------|-------|--------|-----|-----|
|                                                                       |
| switches:    -f         : force overwrite of output file              |
|              -<number>  : 1. PNG RGB palette quantize color count     |
|                           2. JPEG-LS near value                       |
|                           3. H.265 (qp-4)/6 value                     |
|-----------------------------------------------------------------------|

Example Usage

convert a PNM to a QOI:

ImCvt.exe image\P6.pnm -o image\P6.qoi

convert a QOI to a BMP:

ImCvt.exe image\P6.qoi -o image\P6.bmp

convert a BMP to a JPEG-LS, with near=1 (lossy):

ImCvt.exe image\P6.bmp -o image\P6.jls -1

convert a BMP to a H.265 image file, with (qp-4)/6=2 (lossy):

ImCvt.exe image\P6.bmp -o image\P6.h265

convert a BMP to a PNG:

ImCvt.exe image\P6.bmp -o image\P6.png

convert a BMP to a PNG by quantize to 16-color palette:

ImCvt.exe image\P6.bmp -o image\P6_16.png -16

convert a grayscale PNM to JPEG-LS extension with near=1 (lossy), and then convert it back to BMP:

ImCvt.exe image\P5.pnm  -o image\P5.jlsx -1
ImCvt.exe image\P5.jlsx -o image\P5.bmp

 

 

Related links

[1] Official website of QOI : https://qoiformat.org/

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

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

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

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

[6] uPNG: a simple PNG decoder: https://github.com/elanthis/upng

[7] FPGA-based Verilog QOI compressor/decompressor: https://github.com/WangXuan95/FPGA-QOI

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

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

[10] H.265/HEVC 帧内编码详解:CU层次结构、预测、变换、量化、编码:https://zhuanlan.zhihu.com/p/607679114

[11] The H.265/HEVC reference software HM: https://github.com/listenlink/HM

[12] NBLI: a fast, better lossless image format: https://github.com/WangXuan95/NBLI

[13] ITU-T T.870 : JPEG-LS extention specification : https://www.itu.int/rec/T-REC-T.870/en

[14] A comparison of many lossless image compression formats: https://github.com/WangXuan95/Image-Compression-Benchmark

Releases

No releases published

Packages

No packages published

Languages

0