mattn / go-sixel

DRCS/Sixel Encoder/Decoder
MIT License
152 stars 11 forks source link

Encoder improvement: smaller, faster and finer #3

Closed saitoha closed 8 years ago

saitoha commented 8 years ago

This patch introduces various improvements to Encode() method

Quarity improvement The patched version does median-cut quantization(by using github.com/soniakeys/quant/median) and floyd-steinberg error diffusion dithering.

former: snake

new: snake

Compression improvement The SIXEL file converted from above test image(snake.jpg) by patched version is reduced its size by 55.4%.

former:

$ curl -O https://raw.githubusercontent.com/saitoha/libsixel/master/images/snake.jp
$ ./gosr snake.jpg |wc -c
928336

new:

$ curl -O https://raw.githubusercontent.com/saitoha/libsixel/master/images/snake.jp
$ ./gosr snake.jpg |wc -c
414259

Performance improvement The patched version encodes above test image(snake.jpg) more 41.4% faster than current version.

former:

$ curl -O https://raw.githubusercontent.com/saitoha/libsixel/master/images/snake.jp
$ seq 1 10|while read i ;do time ./gosr snake.jpg > /dev/null; done 2>&1|awk '{sum+=$11;c++}END{print(sum/c)}'       
1.5232

new:

$ curl -O https://raw.githubusercontent.com/saitoha/libsixel/master/images/snake.jp
$ seq 1 10|while read i ;do time ./gosr snake.jpg > /dev/null; done 2>&1|awk '{sum+=$11;c++}END{print(sum/c)}'       
0.893
mattn commented 8 years ago

Wow!