Implementation of four classical image segmentation methods in C compiled for the web.
Go to https://inventshah.github.io/image-segmentation/ in your browser.
Or run locally:
git clone https://github.com/inventshah/image-segmentation.git
- Start a static server
python -m http.server 8080
- Go to
localhost:8080
in your browser.
Change the parameters for each algorithm, toggle gamma correction, or click on an image to rerun the algorithm.
The clang compiler must be used.
Run make wasm
Non-make users:
clang -Os -flto -msimd128 -mbulk-memory --target=wasm32 -nostdlib -Wl,--no-entry -Wl,--allow-undefined -o main.wasm src/meanshift.c src/kmeans.c src/histogram.c src/splitmerge.c src/utils.c src/utils_wasm.c
Download the libpng dependency.
Run make native
Non-make users: cc -O3 -flto -o segment -lpng src/native.c src/kmeans.c src/meanshift.c src/histogram.c src/splitmerge.c src/utils.c
Run any of the following to produce an out.png file:
./segment kmeans <source png> <k value>
./segment meanshift <source png> <bandwidth value>
./segment splitmerge <source png> <tolerance>
./segment histogram <source png>
The implementations of the algorithms in this repository are based on the following:
- https://github.com/inventshah/Kmeans-C
- https://github.com/inventshah/Mean-Shift-C
- https://github.com/inventshah/Balanced-Histogram-Thresholding-C
- https://github.com/inventshah/Split-Merge-C
This repository updates those implementations for better WASM support.