Math_40_Final_Project

Fractal Image Compression Introduction

  • Paper: Yuval Fisher, Fractal image Compression, 1992.
  • Fractal compression is a lossy compression method for digical images based on fractals. The method is best suited for textuals & natural images, relying on the fact that parts of an image often resemble other parts of the same image. Fractal algorithm convert these part into mathematical data called "fractal code" which are used to recreate encoded image

Table of Contents

Background

The standard methods of image compression come in several varieties. The current most popular methods relies on eliminating high frequency components of the signal by storing only the low frequency Fourier coefficients. Other methods use a "building block" approach, breaking up images into a small number of canonical pieces and storing only a reference to which piece goes where.

  • Fractals scheme is promoted by M. Barnsley

Demo

SVD

  • Lena's image (512 * 512)

  • Above: Original

  • Above: Compressed with # singular value limit 200
Sigular Value limit Compression Ratio Generated Image
200 0.782012939453125 Lena 200
180 0.7038116455078125 Lena 180
160 0.6256103515625 Lena 160
140 0.5474090576171875 Lena 140
120 0.469207763671875 Lena 120
100 0.3910064697265625 Lena 100
80 0.31280517578125 Lena 80
60 0.2346038818359375 Lena 60
40 0.156402587890625 Lena 40
20 0.0782012939453125 Lena 20
  • As we could see from above, human eyes cannot easily see the difference between the original and the generated image when # singular value limit = 200. However, it is very blurry when # singular value limit = 20
  • The more singular value we use, the better our results normally.
  • Moreover, SVD doesn't require large dataset to train. It can be directly used without training.

Also, we could see that the fewer singular value we use, the worse our performance.

Fractal Image Compression

  • Lena's image (512 * 512)

  • Monkeys's image (256 * 256)

Autoencoder

  • Note: Autoencoder can only be trained on a dataset which contains similar objects. This is because autoencoders learn how to compress the data based on attributes (i.e. correlations between the input feature vector) discovered from data during training.
  • Trained on MNIST in our code
  • It is a little bit different with image compression, but it is a method which is commonly used for data compression. The latent representations generated in the training can be used for many analyses, and it is similar to PCA. Specifically, when the latent dimension = 2, we could plot the distribution using matplotlib.pyplot and this is really handy.
  • The reason why we include it here is that images are also data, since autoencoders are an important neural network structure in data compression and have a similar structure (encoder, decoder) as fractal image compression. (Although the intuition is quite different).

Feature & Todo List

  • SVD
  • Fractal Image Compression
    • Support more transformations
  • Autoencoder (VAE)
  • JPEG
  • Modify readme

Comparison

Method Compression Ratio Settings & Note
SVD 0.782012939453125 singular value limit - 200
Fractal Image Compression Cannot compute No specific special setting
JPEG Not implement yet Does not have time to implement : (

The 2 typical methods among all data/image compression methods are:

    1. Using the NN network
    1. Using some maths methods (i.e. fractal image compression, SVD, PCA, etc).

Difference:

  • Dataset
    • NN network: requires a huge dataset, labeled or unlabeled. Takes long to train.
    • SVD, fractal image compression: Only requires a single image.
  • 'Decoding'/reconstruction algorithm
    • NN network: Compute very quickly using the weight of each layer.
    • SVD, fractal image compression: Use an iterative reconstruction, which is normally computationally expensive.

Function

Function name Description
python svd.py SVD methods
python autoencoder.py Auto encoder implementation
python fractal_compress.py Fractal Image Compression implementation
  • Make sure you have the required package (pytorch, skimage, scipy, etc) downloaded before you run the project

Contributor

License

MIT