Skip to content

seungkilee-cs/K-Means-Image-Compression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K-Means-Image-Compression

My implementation of Image Compression by K Means Clustering, in various languages

How To Use

First, clone this repository. Then, navigate to src/cpp/.

Prebuild

# clean previous build is there are any
rm -rf build
# confiugure and build
cmake -S . -B build
cmake --build build --config Release

Build

./build/kmeans_imgc {YOUR_TEST_IMAGE_PATH}.png {K_CLUSETERS: [2,256]} out {JPEG_QUALTIY: [0,100]}

Will create the poc compression for the image.

Results

Of course, none other than the first lady of the internet

Original (474kb/PNG) Compressed Image w/ 16 Clusters (82kb/JPEG)
PNG JPEG

Prototyping

I've been avoiding Rust for a while, partly due to a "just write in C" mentality and partly because of my general aversion to evangelists. However, my first experience with Rust through WebAssembly was surprisingly positive and measurably faster than native JavaScript. After that Rust conversion therapy, I want to properly learn it as a viable tool. The best way to learn something new is to solve a problem you already understand, letting you focus on implementation rather than figuring out the problem itself.

Building a client-side image compressor. The problem with "free" online converters is that your data ends up on someone else's server where they can do whatever they want with it. TypeScript with Vite is my preferred tool for this kind of web application, and I want to test how well these algorithms perform in the browser.

Next Agenda

  • Modularize the C++ code. There was too much Stack Overflow involved and proper refactoring would help.
  • Add compression performance comparisons.
  • Build TypeScript frontend for real-time comparison between original and compressed images.
  • Create client-side image compression app for uploading and compressing images.
  • Add parameter sliders in the TypeScript client to see compression results in real time.
  • Support additional compression algorithms with dropdown selection for users to test different approaches.
  • Display metadata for both original and compressed images.
  • Support more output formats.
  • Expand the TypeScript UI into a full client-side image compression app while maintaining CLI support.

About

My implementation of Compression by K Means Clustering

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published