Skip to content

nnamanx/image-pre-processing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Processing

This project implements three classical image processing tasks:

  1. Chemical Noise Removal and Reconstruction
  2. Speckle Noise Removal
  3. MRI Visualization

Requirements

Install dependencies:

pip install -r requirements.txt

Libraries

  • opencv-python
  • numpy
  • matplotlib
  • pydicom

Project Folder Structure

src/
  main.py
  chemical.py
  speckle.py
  mri.py
  utils.py

noisy/
  chemical/
  speckle/

output/
  chemical/
  speckle/
  mri/

How to Run

Run the main application:

python src/main.py

Then choose a task:

  1. Chemical Noise Removal
  2. Speckle Removal
  3. MRI Visualization
  4. Run All Tasks

Notes

  • Each task automatically selects 3 images randomly
  • All results are saved in the output/ folder

Task 1: Chemical Noise Removal and Reconstruction

Goal

Remove noise from chemical structure images and reconstruct clean shapes (lines, letters, bonds).

Pipeline

  1. Apply filters:
    • Mean
    • Median
    • Gaussian
  2. Convert to binary using Otsu thresholding
  3. Reconstruct shapes using morphological operations
  4. Evaluating results

Visualization

comparison sample

Observations:

  • Mean filter produced the most consistent and visually correct results.
  • Gaussian filter often caused fragmentation of structures.
  • Median filter sometimes removed too much information, making structures faint or incomplete.
  • The evaluation metric did not always match visual quality, so visual inspection was also considered.

Overall, the mean filter performed best, while Gaussian and median filters showed limitations depending on noise and structure.

Insight

The evaluation metric is based on number of connected components and small noise regions.

However, fewer components does NOT always mean better result and median filter can get good scores but produce unusable images

Therefore, both quantitative metrics and visual inspection were used


Task 2: Speckle Noise Removal

Goal

Remove speckle noise using non-ML techniques.

Filters Used

  • Median
  • Gaussian
  • Bilateral

Visualization

comparison sample

Observations

  • Bilateral filter achieved the best balance between noise reduction and edge preservation.
  • Gaussian filter smoothed noise effectively but blurred important details.
  • Median filter reduced noise but sometimes removed useful texture.
  • Overall, bilateral filtering was the most reliable method.

Evaluation

Score is based on:

  • noise level (Laplacian)
  • edge preservation (Sobel)

Task 3: MRI Visualization

Goal

  • Read the file
  • Extract metadata
  • Visualize slices

Input

When running this task, you must provide a MRI file path:

Example paths: noisy/mri/sample.dcm

Output

  • metadata.txt
  • slice images
  • grid visualization

Visualization

comparison sample

Observations:

  • Metadata extraction provided useful information about the scan and image properties.
  • Slice visualization allowed clear understanding of the MRI structure.
  • Grid visualization helped compare different layers effectively.
  • The task demonstrated handling of real-world medical image data formats.

Important Note

The MRI file is NOT included in repository due to size.


Requirements

✔ Python only
✔ No machine learning (especially for speckle)
✔ Using standard libraries (OpenCV, NumPy, etc.)
✔ Random selection of 3 images per task
✔ Outputs saved in structured folders
✔ Clean, readable, user-friendly code


Methodology Note

All algorithms and techniques used in this project are based on concepts covered in our course lectures, primarily from the 07_Image_processing.pdf material.

The implementation follows standard approaches introduced in the lecture, including:

  • image filtering (mean, median, Gaussian, bilateral)
  • thresholding (Otsu method)
  • morphological operations (opening, closing)
  • connected component analysis
  • edge and noise estimation (Sobel, Laplacian)

I have not used any external or advanced methods beyond the lecture scope.

Summary

This project demonstrates classical image processing techniques, noise removal strategies, importance of combining metrics with visual analysis and structured user-friendly application design.

The results show that different noise types require different approaches and no single filter is universally optimal. Careful evaluation and visualization are essential for selecting the best method.

About

a3-image-pre-processing-nnamanx created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%