Skip to content

Epitech - Image Compressor in Haskell using K-Means algorithm

License

Notifications You must be signed in to change notification settings

skyf0l/ImageCompressor

Repository files navigation

ImageCompressor

ImageCompressor in Haskell based on K-Means algorithm

All automatic tests of Epitech are passed at 100%

Config

Via stack

$ stack build --copy-bins --local-bin-path ./

Via Makefile (with stack)

$ make

Usage

To compress image: ./compress.py image.[jpg/png/bmp] nbClusters convLimit

$ ./compress.py images/mona-lisa.jpg 10 0.2
Convert image in pixels...
 -> Convert image in pixels done in 0.241s
Compress pixels...
 -> Compress pixels done in 2.52s
Pixels image in image...
 -> Pixels image in image done in 0.563s

-> All done in 3.325s
Output file: images/compressed-mona-lisa.jpg

Example with image of 256 * 256 pixels

Original

mona-lisa

Compressed with 5 clusters and convergence limit at 1

~ 2.5s of compute

compressed-mona-lisa

Compressed with 10 clusters and convergence limit at 0.5

~ 2.8s of compute

compressed-mona-lisa

Compressed with 50 clusters and convergence limit at 0.01

~ 3s of compute

compressed-mona-lisa

Performance

Original 720p (1280 * 720 pixels)

  • Up ot 2Go of ram used for compression

minecraft

Compressed with 16 clusters and convergence limit at 0.5

~ 45s of compute

compressed-minecraft

Compressed with 64 clusters and convergence limit at 0.01

~ 60s of compute

compressed-minecraft

Compressed with 256 clusters and convergence limit at 0.001

~ 120s of compute

compressed-minecraft

Original 4K (3840 * 2160 pixels)

  • Up ot 13Go of ram used for compression

mustang

Compressed with 16 clusters and convergence limit at 0.5

~ 10m of compute

compressed-mustang

Compressed with 64 clusters and convergence limit at 0.01

~ 12m of compute

compressed-mustang

Compressed with 256 clusters and convergence limit at 0.001

~ 18m of compute

compressed-mustang

About

Epitech - Image Compressor in Haskell using K-Means algorithm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published