How it works

From one photograph to a referral decision.

Six stages, each one you can open up and inspect. Scroll, and watch the eye change as each stage does its job.

01 · Capture

A technician photographs both eyes.

A non-mydriatic fundus camera at the screening camp takes one photograph per eye. No specialist is needed at this point, only a trained operator.

  • About 4 min per patient, both eyes
  • Up to 2 retakes if the quality gate says no
02 · Quality gate

Can this photograph be graded at all?

Before any grading, three checks run on the image. The field of view is found with a circular Hough transform. Sharpness is the variance of the Laplacian of the green channel. Exposure comes from the brightness histogram inside the retina.

Pass Enhance with CLAHE Reject → retake

A rejected image never travels. That saves bandwidth, and it means a grade is never guessed from a photo that cannot support one.

assessImageQuality.m
03 · Segmentation

Finding the anatomy first.

The optic disc is the brightest compact region. The fovea is the darkest area about two and a half disc diameters to its side. Vessels come from 24 matched filters, at two widths and twelve orientations, followed by hysteresis thresholding.

Every threshold is a fraction of the retina’s own radius, so the same settings work across cameras and resolutions without retuning.

segmentRetina.m
04 · Lesions

Counting what damages the retina.

  • Microaneurysms Tiny red dots, isolated with a top-hat transform.
  • Hard exudates Bright yellow deposits, found against a median-filtered background.
  • Haemorrhages Dark blots away from the vessels, kept only if their shape is blob-like.

Lesions are counted per quadrant around the optic disc, because the severe grade depends on where they are, not only how many.

05 · Two graders

Two independent opinions, one decision.

Clinical rules

Applies the ICDR scale directly to the lesion counts, including the 4-2-1 rule for severe disease. Every grade lists the criteria that triggered it.

gradeByRules.m

Neural network

EfficientNet-B0 fine-tuned on APTOS 2019. Its confidence is calibrated, and its referral cut-off is chosen for at least 90% sensitivity.

predictDRGrade.m
Agree → the grade stands Disagree → a human reviews, and the case is referable if either grader says so
06 · Report

A result the clinic and the patient can read.

The clinic gets the grade, the referral decision, a colour-coded lesion overlay and, when the network ran, a Grad-CAM map of where it looked. The patient gets a PDF in plain language.

A language model writes the plain-language paragraphs and nothing else. The grade is a fixed input it cannot change. Without a key or a network, a built-in paragraph is used and the report still generates.

report_generator.py
Designed for real camps

It degrades instead of failing.

Each missing piece removes one capability. The screening keeps running.

No trained network Rule-based grading and the lesion overlay still run. The report says which mode was used.
No Image Processing Toolbox A pure-MATLAB layer supplies every image function the pipeline needs, checked by 61 tests.
No language-model key The PDF uses a built-in, clinically neutral paragraph instead.
No network at the camp Images are stored and forwarded when the link returns.
real_full

A trained network loads. Consensus grade, Grad-CAM, calibrated confidence and the lesion overlay.

real_no_cnn

No usable network. Rule-based ICDR grade and the lesion overlay. No Grad-CAM, no confidence score.

The bigger picture

One eye is solved. What about a hundred thousand?

A screening programme is a chain of queues, and it breaks at the narrowest one. Our Simulink model finds it.