This project performs image segmentation on MRI brain image to identify and segment tumor regions using binary masking and labeling techniques in Python.
In this project, I used binary masking technique to segment tumors in MRI brain scan slices. The segmented images highlight tumor boundaries, and distinguish multi-region tumors using intensity differences and region labeling.
This can assist medical practitioners or serve as a proof-of-concept for more advanced models.
-
Type: MRI scan brain images
-
Format:
.nii
(Neuroimaging Informatics Technology Initiative format) -
Slices: 2D grayscale slices from 3D volumes
📥 Download Link -
Full Data Source
- Detect and visualize tumor regions in brain CT images.
- Label nested and overlapping tumors with separate colors.
- Improve visibility by applying masks and filtering borders.
- Enable easy inspection and interpretation of segmented regions.
- Data
- Loaded
.nii
image usingnibabel
- Loaded
- Segmentation via binary masking
- Tumor regions identified by pixel intensities (image > 8000) & (image <= 10500) pixel values
- Separated high and low intensity tumors using color-mesh
- Masking
- Binary masks created using NumPy
- Border Clearing
skimage.segmentation.clear_border()
used to remove artifacts
- Labeling
skimage.measure.regionprops()
to identify tumor regions and their properties such as area, bounding boxes, center_of_massscipy.measure.label()
to label connected regions and identified region areas
- Visualization
matplotlib.pyplot.pcolormesh()
for color visualizationscipy.ndimage.zoom()
to reduce axes dimensionsplotly.graph_objects()
for 3D visualisation of segmented tumors
Example segmented slice (slice index = 110):
Original | Segmented |
---|---|
![]() |
![]() |
Nested tumors:
- Small tumor : Higher intensity
- Larger tumor: Moderately Lower intensity, re-labeled as a distinct region
git clone https://github.com/Amos77Robert/segmentation-of-brain-tumors-without-AI.git
cd segmentation-of-brain-tumors-without-A
## 🧪 Dependencies
- numpy
- matplotlib
- nibabel
- scipy
- scikit-image
Install them via:
```bash
pip install -r requirements.txt
# Run the notebook in VS Code, Colab, Jupyter or any Python environment
python iMAGE sEGMENTATION sCRIPT.ipynb
- Differentiating nested tumors with close intensity ranges
- Choosing optimal thresholds across variable slices
- Amoss Robert
- Master of Data Science Candidate | Researcher