Educational demo. Not a clinical diagnostic tool.
- Language
- Python, in a notebook
- Scope
- Educational demo
- Data
- Five grayscale brain MRI slices, 256×256
- Stack
- Python 3.8+, OpenCV 4.x, Google Colab
- Built with
- AI (code)
Design: mine
Overview
The notebook shows how non-linear morphological operations change anatomical shapes in 2D brain MRI. It is strictly classical image processing: no machine learning, deep learning or classifiers.
What it covers
- Otsu automatic thresholding to binarise each slice.
- Erosion and dilation.
- Opening, which removes noise, and closing, which fills holes.
- Boundary extraction, β(A) = A − (A ⊖ B).
- Structuring-element experiments: 3×3, 5×5 and 7×7, rectangular and elliptical.
- Kernel heatmaps, multi-scale experiments, and idempotency and duality as worked questions.
Try it
The same four operations on a small synthetic mask. Change the operation and radius and watch which pixels are kept, added or removed.
- Kept
- Added
- Removed
Synthetic mask, not a patient scan.
Limits
Known limits
- Educational by design; the README says it is not a clinical diagnostic tool.
- Five slices only, so it demonstrates the operations and proves nothing about performance.
- No validation against clinical standards, and the README reports no quantitative results.
Run it
The main artifact is a Google Colab notebook. It loads the local images and falls back to a download in Colab. Open it from the repository.