Skip to content

Image denoising using PCA, NMF, K-SVD, Spectral decomposition, CNN and state of the art generative adversarial denoising autoencoder

Notifications You must be signed in to change notification settings

heartyguy/ml-image-denoising

Repository files navigation

ML Image Denoising

Python License: MIT Theano

A comprehensive suite of image denoising techniques, from classical statistical methods to state-of-the-art deep learning models. This repository provides implementations and comparisons of Principal Component Analysis (PCA), Non-negative Matrix Factorization (NMF), Singular Value Decomposition (SVD), Spectral Decomposition, Convolutional Neural Networks (CNN), and a Generative Adversarial Denoising Autoencoder (GAN-DAE).

image --> image

🎯 Overview

Image denoising is a fundamental problem in computer vision and image processing. This project serves as both a practical toolkit and an educational resource for understanding and comparing various denoising methodologies across traditional and modern approaches.

Key Features

  • Classical Methods: Implementation of foundational techniques including PCA, NMF, SVD, and Spectral Decomposition
  • Deep Learning: Custom Convolutional Neural Network designed for effective noise reduction
  • State-of-the-Art: Sophisticated Generative Adversarial Network-based Denoising Autoencoder for high-fidelity reconstruction
  • Comprehensive Evaluation: Built-in PSNR metrics and visual comparison tools
  • Modular Design: Extensible codebase for easy experimentation with new techniques
  • Interactive Notebooks: Jupyter notebooks for each method with detailed explanations

πŸš€ Quick Start

Prerequisites

  • Python 3.6+
  • Git
  • pip
  • virtualenv

Installation

  1. Clone the repository

    git clone https://github.com/your-username/ml-image-denoising.git
    cd ml-image-denoising
  2. Set up environment

    chmod +x install.sh
    ./install.sh

    This creates a virtual environment and installs all necessary dependencies.

  3. Activate the virtual environment

    source bin/activate  # On Windows: Scripts\activate

Dataset Preparation

This project uses the CelebA dataset:

  1. Download the dataset

    • Download img_align_celeba.zip from the CelebA project website
    • Extract to the parent directory: ../img_align_celeba/
  2. Process the data

    python dataprocessing.py

    This script crops images to the required size and converts them to efficient HDF5 format.

πŸ“Š Usage

Jupyter Notebooks

Launch Jupyter to explore the different denoising methods:

jupyter notebook

Available Notebooks

  • adversarial_autoencoder_denoising.ipynb - GAN-based denoising autoencoder
  • cnn_denoising.ipynb - Convolutional Neural Network approach
  • pca_denoising.ipynb - Principal Component Analysis method
  • nmf_denoising.ipynb - Non-negative Matrix Factorization technique

Example Usage

# Load and preprocess data
from helper import cmp_images_psnr
import numpy as np

# Compare denoising methods
psnr_score = cmp_images_psnr(clean_images, denoised_images, num_samples)
print(f"PSNR: {psnr_score:.2f} dB")

πŸ—οΈ Project Structure

ml-image-denoising/
β”œβ”€β”€ adversarial_autoencoder_denoising.ipynb  # GAN-DAE implementation
β”œβ”€β”€ cnn_denoising.ipynb                      # CNN-based denoising
β”œβ”€β”€ pca_denoising.ipynb                      # PCA method
β”œβ”€β”€ nmf_denoising.ipynb                      # NMF technique
β”œβ”€β”€ dataprocessing.py                        # Data preprocessing script
β”œβ”€β”€ helper.py                                # Utility functions (PSNR, etc.)
β”œβ”€β”€ install.sh                               # Environment setup script
β”œβ”€β”€ requirements.txt                         # Python dependencies
└── lib/                                     # Core library modules
    β”œβ”€β”€ activations.py                       # Activation functions
    β”œβ”€β”€ updates.py                           # Optimization algorithms
    β”œβ”€β”€ ops.py                               # Neural network operations
    β”œβ”€β”€ metrics.py                           # Evaluation metrics
    └── ...

πŸ”¬ Methods Implemented

Classical Approaches

Method Description Notebook
PCA Dimensionality reduction via principal components pca_denoising.ipynb
NMF Non-negative matrix factorization nmf_denoising.ipynb
SVD Singular value decomposition pca_denoising.ipynb
Interpolation Bilinear and bicubic upsampling pca_denoising.ipynb

Deep Learning Approaches

Method Description Notebook
CNN Custom convolutional neural network cnn_denoising.ipynb
GAN-DAE Generative adversarial denoising autoencoder adversarial_autoencoder_denoising.ipynb

πŸ“ˆ Performance

Typical PSNR improvements on CelebA dataset:

  • Bilinear Interpolation: ~25.5 dB
  • Bicubic Interpolation: ~26.2 dB
  • CNN Denoising: ~28-30 dB
  • GAN-DAE: ~30-35 dB

Results may vary based on noise levels and training parameters.

πŸ› οΈ Configuration

Training Parameters

Key parameters can be modified in the notebook cells:

# Training configuration
batch_size = 128
learning_rate = 0.0002
num_epochs = 200
l2_regularization = 1e-5

Model Architecture

The GAN-DAE uses an encoder-decoder architecture:

  • Encoder: Progressively downsamples from 128Γ—128 to 8Γ—8
  • Decoder: Reconstructs high-resolution output
  • Discriminator: Ensures realistic image generation

πŸ“‹ Requirements

Core Dependencies

  • Theano==0.7.0
  • Pillow>=3.0.0
  • numpy>=1.10.2
  • h5py>=2.5.0
  • tqdm>=3.4.0
  • ipython>=4.0.0

See requirements.txt for complete dependency list.

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Areas for Contribution

  • Implementation of additional denoising algorithms
  • Performance optimizations
  • Better evaluation metrics
  • Documentation improvements
  • Bug fixes and code quality improvements

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • CelebA Dataset for providing the facial image dataset
  • Theano deep learning framework
  • Original DCGAN implementation inspiration
  • The open-source community for various utility functions

πŸ“ž Contact

For questions, suggestions, or collaboration opportunities:

πŸ”— Related Work


⭐ Star this repository if you find it helpful!

About

Image denoising using PCA, NMF, K-SVD, Spectral decomposition, CNN and state of the art generative adversarial denoising autoencoder

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •