Simple Lossy Compression
This applet demonstrates a simple form of lossy compression where
some relatively unimportant information is thrown away. The original image and
its size in bytes are displayed. The user can pressa button to compress the
image. For this applet, compression is performed by computing the first difference
of the pixel values in the image.The compression algorithm then looks for patterns
of (1,-1), (-1,1), (1,0,-1), (-1,0,1), (1,0,0,-1) and (-1,0,0,1). These patterns
correspond to locations where the adjacent pixels are very similiar in color
values.These patterns are then replaced by all zeros, increasing the chance
that long strings of zeros will result, yielding efficient run-length coding.
This allows for greater compression rates, at the cost of a loss in some of
the fine details of the image.
The number of bytes needed to store the compressed image is shown in the applet
window.
Try replacing professor.gif with these other examples:
- bicycle.gif
- firehydrant.gif
- glass.gif
- tree.gif
Advanced users may also try other images, by typing in the path to the image.