Skip to content

EricZimmermann/ECSE444-Filtering

Repository files navigation

ECSE444-Filtering

The following readme has been written in markdown and should therefore be viewed with the proper format for optimal clarity.

Directory Structure

├── README.md
├── Stochastic_Analysis.ipynb
├── prototyping
│   ├── obj.py
│   ├── processing.py
│   ├── test.png
│   └── validation.ipynb
├── requirements.txt
├── scripts
│   ├── autotest.py
│   ├── postprocess.py
│   ├── preprocess.py
│   └── utils.py
├── src
│   └── imaging
│   ├── Makefile
│   ├── conv.c
│   ├── conv.h
│   ├── filter.c
│   ├── filter.h
│   ├── fourier.c
│   ├── fourier.h
│   ├── image.c
│   ├── image.h
│   ├── main.c
│   ├── processmake
│   ├── utils.c
│   └── utils.h
└── test.png

Project Description

The project provides implementations from scratch!!! of classical image denoising algorithms that include:
Image Convolutions - src/imaging/conv.c
Fourier Transforms (DFT and FFT) - src/imaging/fourier.c

Image and complex image structures can be found in src/imaging/image.c while filter structures are found in src/imaging/filter.c

Note: A test image has been provided in root! please use this for simplicity!

Environment Preparation

Pre and Post processing of images are done using Python, whose requirements are found in the root directory of the project and are to be installed via: pip install -r requirements.txt

If any issues persist with installations, please pip install numpy and pip install opencv-python.

Note: use pip install jupyter if you would like to look at notebooks. To run notebooks, pip install matplotlib

Preprocessing

Done once! Colored images in .jpg or .png are converted from RBG to grayscale, resampled, and flattened into .txt files for processing. Preprocess pipeline creates a clean.txt and noise.txt outputs where a noise image is created to validate the algorithms below.

1 .python scripts/preprocess.py --input <full path to image> --output <directory of .txt creation> --size <target image size 2^n>
2. clean.txt and noise.txt created in output directory

Optional cmds are:
--r_noise <range of additive noise ~ default 15>
--p_noise <probability of additive noise ~ default 0.5>

Note: image size must be of base power 2: {2, 4, 16, 32, 64, 128, 256, 512}

Steps to run Convolution (requires terminal):

  1. cd src/imaging (navigate into the directory containing the Makefile)
  2. make processmake (build the executable)
  3. ./processmake -c <full path to the target directory containing input txt> <input txt filename> <size of img> <sigma of kernel as float> <size of kernel eg: 3, 5, 7>
  4. output.txt contains the resulting image and logging.txt contains the parameters we used (located in same directory as specified)

Note: image size must be identical to that selected in preprocessing
Note: kernel size must be odd and smaller than size of image

Steps to run Naive FFT (requires terminal):

  1. cd src/imaging (navigate into the directory containing the Makefile)
  2. make processmake (build the executable)
  3. ./processmake -f <full path to the target directory containing input txt> <input txt filename> <size of img ideally <=32, eg: 32> <r value as float: eg: 1.0>
  4. output.txt contains the resulting image and logging.txt contains the parameters we used (located in same directory as specified)

Note: sizes of >128 will take too long

Steps to run Cooley-Tukey FFT (requires terminal):

  1. cd src/imaging (navigate into the directory containing the Makefile)
  2. make processmake (build the executable)
  3. ./processmake -t <full path to the target directory containing input txt> <input txt filename> <size of img, eg: 32, 128, 512> <r value as float: eg: 1.0>
  4. output.txt contains the resulting image and logging.txt contains the parameters we used (located in same directory as specified)

Postprocessing

Compute PSNR metrics and add to logging.txt, create .jpg for output.txt file

  1. python scripts/postprocess.py --input <full path to directory of .txt files>
  2. logging.txt updated
  3. output.jpg created

Example

  1. mkdir experiment
  2. python scripts/preprocess.py --input ./test.png --output ./experiment --size 256
  3. cd src/imaging
  4. make processmake
  5. ./processmake -t ../../experiment/ noise.txt 256 0.3
  6. cd ../../
  7. python scripts/postprocess.py --input ./experiment

Note: Repeat steps 5 - 7 as needed

Automated Testing (at your own risk!)

Runs a set of configs to compure batch ffts and persist info. Please edit configs before running or else! Run from root!

python scripts/autotest.py --input <full path to test img>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published