项目作者: gzt

项目描述 :
Image compression using the block k-means algorithm
高级语言: C
项目地址: git://github.com/gzt/kmeans-image-compression.git
创建时间: 2019-06-03T03:38:11Z
项目社区:https://github.com/gzt/kmeans-image-compression

开源协议:GNU General Public License v3.0

下载


kmeans-image-compression

Image compression using the block k-means algorithm

Run make all and make sure that kmeans-compress.sh is marked as executable.

This uses the files from replaceR,
though it can be rewritten to use Rmath.h easily if you prefer that.
It depends on having libtiff and zpaq installed.

On Fedora, I recommend running dnf install libtiff libtiff-devel zpaq zpaq-devel,
as this depends on having libtiff and libzpaq. Appropriate packages are available
in Ubuntu as well.

Basic usage is:

./kmeans-compress.sh -i inputimage.tiff -o outputimage.tiff -p blocksize -k numberofclusters

For example, on the included test image, you may try:

./kmeans-compress.sh -i baboon.tiff -o baboon-test.tiff -p 5 -k 50

There are additional options controlling other settings (method of initialization of clustering,
assigning seeds, etc). It outputs a TIFF version of the compressed image and a file
representing the compressed version of the input image. The program also writes some diagnostic
information to logresults.txt. This works by passing your arguments to block-tiff and then
compressing the output using the zpaq library. The zpaq-compressed output is saved as
outputimage.kmns, taken from the -o argument.
The uncompressed binary files are saved as .out files. A text file,
block-means-text.out, of the first-stage means is provided as well for diagnostic purposes.
There is another program called block-master which takes in a text file representation of an
image which was used for some of the images in the corresponding paper. This is included
for the sake of reproducibility.

  1. Usage: ./block-tiff [-v] -i input-TIFF-file
  2. -o output-TIFF-file
  3. -k number-clusters
  4. [-n] number of tries
  5. -p block size
  6. [-m] initialization method (1 = kmeans||, 2 = kmeans++, 3 = kmeans random starts)
  7. [-r] initialization rounds
  8. [-l] for kmeans|| centers per round
  9. [-L] for kmeans|| multiplication factor (k*L = l), only specify one of L and l
  10. [-s] seed file for PRNG (takes two seeds)
  11. [-S] seed file for PRNG, plus hash of arguments to seed
  12. [-t] uses time(NULL) and getpid() as a seed
  13. Note: -v indicates debugging option, default for -n = 1000, default for -m = 1
  14. default is for L=2 and r=5 for kmeans||
  15. default for kmeans++ is -r 25, default for kmeans random starts is r 1000
  16. default is to hash arguments as a seed

A library of example images will be posted soon with DOI 10.5281/zenodo.3234043 when ready.

Licensing

  • See ZPAQ for more information about the lossless compression
    used here.