Medical Image Processing & Tumour Segmentation

Medical Image Processing & Tumour Segmentation

Objective

Isolate a brain tumour with classical computer vision

Before any learned model can segment a lesion, a clinician or engineer needs to understand what the pixels are doing. This experiment applies the core toolbox of medical image processing to a contrast-enhanced axial brain MRI with a visible tumour, building up from basic intensity operations to a working segmentation of the lesion and the skull boundary.

Every step is implemented with OpenCV and NumPy and visualised side by side with its input.

Tools & Data

Language Python
Computer vision OpenCV (cv2)
Numerics NumPy — FFT, custom kernels
Visualisation Matplotlib
Environment Google Colab
Data Contrast-enhanced axial brain MRI (teaching image)

Processing Pipeline

From raw intensities to a segmented lesion

  1. Intensity operations

    Colour-to-grayscale conversion, complement (negative) image, and gray-to-binary / binary-to-gray conversion by thresholding.

  2. Geometric transforms

    Rotation about the image centre (45°), horizontal flip and region-of-interest cropping around the lesion.

  3. Contrast & frequency

    Histogram equalisation with before/after histograms, and the centred 2D Fourier magnitude spectrum.

  4. Edge detection

    Sobel, Prewitt (custom kernels), Roberts (2×2 diagonal kernels) and Canny compared on the same slice.

  5. Segmentation

    Global thresholding, morphological opening and closing to clean the mask, then Otsu + distance transform + watershed to separate touching regions.

Tumour and Skull Segmentation

Tumour and Skull Segmentation

Techniques Implemented

Histogram Equalisation

Redistributes intensities to expose low-contrast tissue boundaries around the lesion.

Fourier Analysis

Spatial-to-frequency transform to inspect the image's frequency content.

Edge Operators

First-order (Sobel, Prewitt, Roberts) versus multi-stage Canny with hysteresis thresholding.

Thresholding

Two-class foreground/background separation isolating the enhancing tumour.

Morphology

Opening removes small bright noise; closing fills small dark holes in the mask.

Watershed

Otsu binarisation, distance transform and marker-based watershed to split connected regions.

Why It Matters

The baseline every learned model must beat

Classical pipelines like this remain the pre-processing stage of most medical AI systems — contrast normalisation, masking and morphology clean the data a neural network learns from — and they are the baseline a segmentation model has to outperform to justify itself.

Coursework for the Medical Imaging Laboratory (BME-3202), B.Sc. Biomedical Engineering, Islamic University.

Want something like this?

Let's talk about your project requirements.

Start a Project