Giter Site home page Giter Site logo

svd-image-compression's Introduction

Optimal Facial Image Compression by SVD

Introduction

Images are prevalent in the Internet. While an excellent way to communicate information ("an image is worth a thousand words"), it is also an expensive form of data for transport over the network. To solve this problem, compression software is often used to encode an image to a smaller physical size so it can be transported more efficiently while minimizing the perceptible quality change from its original copy. How much could an image be compressed before it is no longer valuable in providing information to the user? In this project we explore how to optimize an image compression algorithm based on finding the singular value decomposition of a matrix. For an objective measurement, we introduce an image structural similarity index to the algorithm so it could adjust the compression ratio via a feedback loop.

Compression examples

Images at various levels of k: 5, 15, 25, 35 going from left to right, top to bottom.

example1

example2

example3

Plots

plot1

plot2

plot3

How to run

This program depends on the following Python libraries:

  • scipy
  • numpy
  • PIL
  • skimage
  • matplotlib

After dependencies are installed with pip, you can run like the following:

$ python image_compression.py
usage: image_compression.py [-h] [-c [COMPRESS]] [-k [K [K ...]]]
                            [-s SSIM SSIM] [-r SIZE] [-f [FNAME]]

Image compression with SVD

optional arguments:
  -h, --help      show this help message and exit
  -c [COMPRESS]   compress image using SVD
  -k [K [K ...]]  compression factor k (default 5)
  -s SSIM SSIM    calculate ssim between 2 images
  -r SIZE         image resize percentage (default 100)
  -f [FNAME]      saved compressed image to file

For example, to compress a gray scale image saving its top 10 singular values:

python image_compression.py -c myimage.png -k 10

For colored (RGB) images, if you don't want to use the default, make sure you enter a k value for each channel like this:

python image_compression.py -c myimage.png -k 10 10 10

svd-image-compression's People

Contributors

mutaphore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.