AI Hints
Computer Vision · Lesson 90 of 111

Medical Images

Pixels with real units.

⏱ 2 min read▶ Video at 2:21:28🎓 Free
Watch this lesson in the Computer Vision courseWatch on YouTube ↗Full Computer Vision course

In a normal photo, a brightness of two hundred doesn't mean anything in particular. In a CT scan, every number's a real physical measurement, of how dense that tissue is. Air, water, and bone each have known values. That makes medical imaging very different from anything else in this course.

Medical Images
From the video: Medical Images
  • CT numbers are real measurements
  • Air, water, and bone
  • A different world

Windowing a scan

CT values, called Hounsfield units, range from minus a thousand for air, to over a thousand for bone. Our screens can only show two hundred and fifty six greys. So radiologists choose a window. They pick a centre and a width, and everything's squeezed into that range. Run it. In the soft tissue view, air and lung go fully black, and we get fine detail around forty. In the lung view, the range is wide, so the air and lung values spread out. Same scan, and two very different pictures. Doctors switch between windows constantly, and models should be given the right windows too.

window.pypython
import numpy as np

hu = np.array([-1000, -500, -50, 40, 60, 400, 1000])

def window(values, centre, width):
    low = centre - width / 2
    return ((values - low) / width).clip(0, 1) * 255

print("Soft tissue view:", window(hu, 40, 400).round().astype(int).tolist())
print("Lung view:       ", window(hu, -600, 1500).round().astype(int).tolist())
Output
Soft tissue view: [0, 0, 70, 128, 140, 255, 255]
Lung view:        [60, 144, 221, 236, 240, 255, 255]

Rules of medical vision

This field has strict rules. Split data by patient, always. Scanners from different makers produce different images, so test on other hospitals. Labels may come from a few experts who disagree. Rare diseases mean that classes are heavily imbalanced. And a model doesn't replace a doctor, so it has to be approved as a medical device in most countries.

Split by patientnever by slice
Test across hospitalsscanners differ
Expert disagreementuse several readers
Regulatedmedical device rules

Summary

In medicine, the numbers mean something, and mistakes matter. Next, vision that has to move.

Key takeaways
  • CT values are physical
  • Windows select a range
  • Test across hospitals
Next up: Vision for Robots — seeing in order to act