Java implementation of vector quantization compression method for images, using k-means clustering algorithm.
-
Put VectorCompression.java file as well as the one-channel rgb image (e.g. "image1-onechannel.rgb") under the same folder.
-
In terminal, run command:
javac VectorCompression.java
java VectorCompression <IMAGE> <SIZE> <NUMBER>
IMAGE : The one-channel rgb image file name.
SIZE : Any integer. Size of a vector you pick, a.k.a number of adjacent pixels side by side as a vector unit.
NUMBER : Any integer. Number of vectors of your choice. Making it a power of 2 can maximize usage of available indexes.
After running the program, original image and compressed version will be juxtaposed in a pop-up window as show below:
As an observation, compressed image will be more refined with the increase of NUMBER and the decrease of SIZE.
- This program supports one-channel rgb image file comepression only.
- Size of image is limited to 352 x 288.