Skip to content

KaiTaiTong/image-compression

Repository files navigation

Image Compression

This is an implementation of a content-aware image compression algorithm. The content awareness mechanism is based on entropy, which is computed using the hue value frequency distribution of color pixels in a given rectangle. Then the parent rectangle image will be split (either horizontally or vertically) so that the weighted average entropy of the two sub-rectangles gets minimized. This process is repeated recursively until the 2 sub-rectangles become single pixels. Technically, this approach is a modified KD Tree.

As indicated in the section below, the input images get compressed without losing resolution in the most informative regions.

Demo

Input image Compressed image
temple_raw temple_comp
Input image Compressed image
sakula_raw sakula_comp
Input image Compressed image
DSC_0316_raw DSC_0316_comp

Reference

Skeleton code and structures are provided by Prof. Cinda K. Heeren as part of a course on data structure and algorithm in University of British Columbia (UBC).

Raw source images are cited here:
temple image
fuji image
totem image