Giter VIP home page Giter VIP logo

reconstruction-and-compression-of-color-images's Introduction

Reconstruction and Compression of Color Image Using Principal Component Analysis PCA

While reviewing linear algebra, I decided to work on some funny projects that will help me to understand the concepts more deeply. In this repo, I have reconstructed a [600,600,3] RGB image using PCA. To undestand this project, one may need to have solid knowledge of eigendecomposition and covariance matrix. I have another repository where i have included these concepts with python codes, basically using Numpy. Feel free to have a look there!

The input image:

dhoni

with 10 principal components:

screenshot from 2017-06-03 22-09-09

20 Principal Components:

screenshot from 2017-06-03 22-09-53

50 Principal Components:

screenshot from 2017-06-03 22-10-33

100 Principal Components:

screenshot from 2017-06-03 22-11-27

Conclusion:

Using first 100 PCs, a quite good image has been recontructed. Remember our input image had 600 columns, so we had 600 PCs in our eigendecomposition step. So, clearly a great dimension reduction is possible using PCA analysis on any image. Added, in the mean normalising step, you can tune. For example you can use: 0.5 * np.mean(2D_image, axis = 1). It will reduce noise to some extent. Chect it.

I have added two .py files here. One is main fuction to do it and another is my practice file which I did for myself from scratch - but that's too helpful if anyone wants to understand each steps more clearly.

To run the code on ubuntu, save input file "dhoni.jpg" and "image_reconstruction_using_PCA.py" in same directory and run the .py file. However, install all required packages before running the code. You can use this code on any image, with a bit of change, for similar purpose.

Update:

If you are working with rectangular image shapes, just change: axis = None from axis = 0/1. I could change the code and make more generalized but not doing that right now.

reconstruction-and-compression-of-color-images's People

Contributors

nourozr avatar

Watchers

面白い 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.