Skip to content
Pratim/Dasude
07/Segmentation1 min read

Retina vein segmentation with U-Net

Outcome

A U-Net trained to segment retinal vessels from fundus images.

SegmentationU-NetMedical imaging

U-Net, PyTorch, Medical imaging

A retinal fundus photograph next to its binary vessel mapfundus
A retinal fundus image and its vessel map, from the project notebook.
Ground truth vessel maps for four retinal images
Ground truth vessel maps.
Model predicted vessel maps for the same four retinal images
Model predictions for the same images.

Draft write-up

A U-Net model that labels every pixel of a retinal fundus image as vessel or background. Retinal vessel maps are a standard input for screening and for tracking diseases that change the vascular tree.

01Problem

Retinal vessels are thin, branch repeatedly and fade into the background near their tips. Simple thresholding breaks on uneven lighting, and a classifier that sees only whole images cannot say where the vessels are. The task needs dense, pixel-level prediction that keeps thin structures connected.

02Approach

  1. 01

    Frame it as pixel-wise segmentation

    Predict a binary vessel mask for every input image, trained against annotated vessel maps.

  2. 02

    Use a U-Net

    An encoder-decoder with skip connections, which keeps fine spatial detail from early layers available to the decoder. That matters for thin vessels.

  3. 03

    Evaluate overlap with the annotations

    Compare predicted masks with annotated vessels using overlap-based measures, since plain pixel accuracy is dominated by the background.

03Architecture

Image in, vessel mask out, through a standard U-Net encoder-decoder.

01InputFUNDUS IMAGE02EncoderU-NET CONTRACTING PATH03DecoderU-NET EXPANDING PATH04OutputPER-PIXEL PROBABILITY
  1. 01Input

    Fundus image

    Retinal photograph, preprocessed and resized.

  2. 02Encoder

    U-Net contracting path

    Convolution and downsampling blocks that build context.

  3. 03Decoder

    U-Net expanding path

    Upsampling with skip connections that restore fine detail.

  4. 04Output

    Per-pixel probability

    Thresholded into a binary vessel mask.

  • Pixel-level vessel masks
  • Skip connections for thin structures
  • Overlap-based evaluation

04Challenges

  • Vessels are a tiny fraction of pixels, so a model can score well by predicting background.

    FixJudge the model on mask overlap with the annotations instead of pixel accuracy.

05Learnings

Outcomes

  • A trained U-Net for retinal vessel segmentation
  • A repeatable notebook workflow from images to masks

What I learned

  • Class imbalance decides which metric is honest.
  • Skip connections are what keep thin structures intact.

06Next

  • 01Add the dataset name, split and overlap scores
  • 02Show predicted masks next to the annotations