← Module 2 overview
Module 2 · Lesson 2.3
2.3
What is a medical image to a computer?

Images as Data

Pixels and CT numbers, the DICOM file format, windowing, image quality, and how images become datasets for AI

Overview

Mr. Diaz's CT pulmonary angiogram (CTPA) took about ten seconds. During that time the scanner did not take a photograph. It collected a signal: measurements of how much X-ray got through his body from hundreds of angles. A computer then processed that signal into images of his chest, a step called reconstruction. The images are stored as files full of numbers, together with a lot of information about the patient and the scan. This lesson opens those files. It is the "data" half of everything you learned about AI in Module 1. We use CT as the main example, because its numbers have a fixed meaning. About 15-20 minutes. New terms are in the Module 2 glossary (opens in a new tab).

By the end of this lesson you can:

An image is a grid of numbers

Every digital image is made of tiny squares called pixels (picture elements). Each pixel holds one number, and the screen turns that number into a shade of gray. On a phone photo, each pixel has three numbers for red, green and blue. Most medical images are grayscale, so one number is enough.

Left: a small blurry patch of a chest CT showing dark lung, gray chest wall and a white rib. Right: the same patch as an 8 by 8 grid, each square labeled with its CT number, around -850 for lung, +40 for muscle and +700 for bone.
Figure 1. What you see, and what the computer stores. An AI model never "sees" the picture on the left; it receives the numbers on the right.

On CT, the number in each pixel has a fixed meaning. It is a CT number, measured in Hounsfield units (HU), named after Godfrey Hounsfield, who built the first CT scanner. The scale is pinned to two points: water is 0 and air is -1000. Fat is about -100, blood and muscle about +40, contrast-filled blood around +300, and dense bone +1000 or more. That is the scale from Lesson 2.1's density figure, now with numbers attached.

Because a CT slice is a slice of a volume, each pixel actually stands for a tiny block of tissue, called a voxel (volume element), often under 1 mm on each side. A typical CT slice is 512 by 512 pixels, and a chest CT has hundreds of slices: tens of millions of numbers for one scan. X-ray and MRI pixels also hold numbers, but they have no fixed scale like HU: the same tissue can get different numbers on different machines. Remember that for the section on AI below.

Reconstruction involves choices too. The same CT signal can be reconstructed into thin or thick slices, and with a sharp setting (a "kernel") that makes lung and bone edges crisp but grainy, or a smooth one that suits soft tissue. That is why one CT study usually holds several image sets, which you will meet below as series.

Think about it

A doctor looks at an image. An AI model only ever receives a grid of numbers. What could change those numbers without changing the patient? (Scanner brand, settings, reconstruction kernel and slice thickness, contrast timing, patient movement, a different hospital's software. Keep your list in mind; Lesson 1.5's "distribution shift" lives here.)

DICOM files and metadata: a letter in an envelope

Medical images are stored in a standard format called DICOM (Digital Imaging and Communications in Medicine). Every scanner and every viewing system in the world speaks it, which is why an image from one company's scanner can be opened on another company's workstation.

A useful way to picture a DICOM file is a letter in an envelope. The letter is the pixel data: the grid of numbers. The envelope is the header (also called metadata, "data about the data"): hundreds of labeled fields saying who the patient is, which scanner made the image, how it was made and where this slice sits in the body.

Four boxes left to right: Patient (Mr. Diaz), Study (CT pulmonary angiogram, 12 March 01:40), Series (scout, thin contrast slices, lung-window slices, coronal reformats), Images (hundreds of single slices, each its own DICOM file).
Figure 2. How DICOM organizes Mr. Diaz's scan. One study is one exam; it holds several series (sets of images made in one way); each series holds many single images.

Click through the tabs to see what is written on Mr. Diaz's "envelope." The values are made up but the field names are real.

1

Who the patient is

Protected health information: removed before images are shared for research

FieldValue
Patient's NameDIAZ^MIGUEL
Patient IDMRN 00482217
Patient's Birth Date19640219
Patient's SexM
Institution NameCITY GENERAL HOSPITAL

MRN means medical record number. Dates are written year, month, day.

2

What exam this is

Lets the viewer sort images into the right study and series

FieldValue
ModalityCT
Study DescriptionCT ANGIO CHEST PE PROTOCOL
Study Date / Time20260312 / 014012
Accession NumberA9917342 (the order number; links images to the order and the report)
Series Description1.0mm CTA SOFT TISSUE
Body Part ExaminedCHEST
3

How the image was made

The part people rarely look at, and AI models quietly pick up

FieldValue
Manufacturer(scanner company)
Slice Thickness1.0 (mm)
KVP100 (the X-ray tube voltage)
Contrast Bolus AgentIODINATED, 70 mL
Window Center / Width40 / 400 (the default display setting; see Windowing below)
Slice Location-112.5 (where this slice is along the body, in mm)
4

The letter itself

The grid of numbers

FieldValue
Rows / Columns512 / 512
Pixel Spacing0.74 / 0.74 (mm per pixel)
Bits Stored12 (each pixel can hold one of 4,096 values)
Rescale Slope / Intercept1 / -1024 (how to turn stored values into HU)
Pixel Data262,144 numbers

The screen can show only about 256 shades of gray, and the eye can tell apart fewer still. That is why you need windowing.

Why the envelope matters for AI

In Lesson 1.5 you saw an AI that learned to spot the hospital instead of the disease. The header and the pixels themselves carry many such clues: the scanner brand, a "PORTABLE" label burned into the corner, the slice thickness, the hospital's name. A model can learn any pattern that happens to go along with the label. Good AI developers check which scanners and hospitals their data came from, and test on data from somewhere else. The header is also how an AI tool knows which images to look at: a chest CT tool that receives a head CT because the Body Part field was wrong may still give an answer.

Finding a finding: plane, slice and window

A CT or MRI exam is not one picture but a stack of hundreds of slices, so a reader makes three choices to find a finding. First the plane: axial, coronal or sagittal (Lesson 2.1). The scanner usually collects axial slices, and the viewer can rebuild the other two planes from the same numbers. Second the slice: the reader scrolls through the stack to the image or images that show the finding, which is why a report or an AI label often names an image number. Third the window: which range of CT numbers to show in gray, so the finding stands out from what surrounds it.

The same three choices matter when images are prepared for AI. A model may be given one slice, a few slices or the whole stack, in one plane or in all three, and someone has to choose the window it sees. Researchers have shown that the window setting itself changes how well a model finds bleeding in the brain or kidney stones, and that it can even be tuned as part of training (see Go further).

Windowing: one slice, many pictures

A CT slice holds values from -1000 to over +1000, but the screen can only show a limited number of grays. So the viewer shows just a slice of the range at a time, called the window:

A narrow window shows small differences between similar tissues. A wide window shows many tissues but flattens the differences. Radiologists switch windows constantly while they read.

Interactive: window a chest CT

This is a drawn slice through a chest at the level of the heart, made for this lesson; it is not a real patient. It has a clot in one lung artery and a small nodule hiding in it, like Mr. Diaz. Try the preset windows, then move the sliders. Point at the image to read the CT number under the cursor.

Notice that the clot is invisible in the lung window and the nodule is invisible in the soft-tissue window. A reader, or an AI tool, that only looks at one window can miss half the findings. Many AI models are given images in one fixed window, and some are trained on several windows stacked together, as a radiologist would read them.

Image needed

The same real axial chest CT slice shown three times: lung window, soft-tissue (mediastinal) window and bone window. Ideally a CTPA with a visible filling defect in a pulmonary artery.

When the picture is not quite right

Not every image is perfect. An artifact is something on the image that is not really in the patient, created by the scanner, the patient or the physics. Radiologists learn to recognize artifacts so they do not mistake them for disease, and to say in the report when image quality limits what they can see. AI models often have no idea an image is poor and give a confident answer anyway.

Interactive: spot the problem

For each description, decide what caused the problem.

Blurry, doubled edgesA chest CT in a patient who was too short of breath to hold still. The heart and diaphragm look smeared.
Motion. Breathing or moving during the scan blurs edges, and on a CTPA it can create fake dark spots in arteries that look like clots.
Bright and dark streaksA CT of the pelvis in a patient with a hip replacement. Streaks fan out from the hip.
Metal. Metal blocks almost all the X-rays, so the reconstruction math breaks down around it. Special software can reduce, but not remove, the streaks.
The heart looks largeA chest X-ray taken in bed in the ICU, with the beam coming from the front (AP).
Positioning. AP films magnify the heart compared with a standard standing PA film (Lesson 2.1). Compare like with like.
Grainy, speckled imageA low-dose CT in a large patient. Everything looks like it is covered in sand.
Noise. Too few X-rays reached the detector. Lowering the dose is good for the patient, but too low makes small things, like a nodule, hard to see. This is a real ALARA trade-off.
Part of the lung is missingA chest X-ray where the bottom of the right lung is cut off at the edge of the image.
Positioning. Anything outside the image cannot be read by a person or an AI. Reports should say when part of the area of interest was not included.

Image needed

A CT with metal streak artifact from a hip replacement or dental fillings.

Image needed

A CT with breathing motion artifact (blurred diaphragm or heart edges).

From hospital images to AI datasets

To train the AI models from Module 1, developers need thousands of images with labels. Hospitals hold millions of images, but they are full of private information. Before images leave the hospital they are de-identified: names, record numbers, birth dates and other identifying fields are removed or replaced in the header, and any text burned into the pixels (like a name in the corner) is blacked out. In the United States, the privacy rules come from a law called HIPAA (Health Insurance Portability and Accountability Act).

De-identification is harder than it sounds. Faces can be rebuilt from head CT and MRI, dates can identify people, and text can hide in unexpected places. Data sharing also raises the question of patient consent, which the committee and ethics boards take seriously.

Several large public chest X-ray datasets have trained many of the models you will meet:

DatasetSizeWhere the labels came from
MIMIC-CXR377,110 images, 65,379 patientsBeth Israel Deaconess Medical Center, Boston. Comes with the full radiology reports.
CheXpert224,316 radiographs, 65,240 patientsStanford Hospital. 14 labels pulled from reports by a computer program.
NIH ChestX-ray14112,120 images, 30,805 patientsNIH Clinical Center. 14 labels pulled from reports by a computer program.

Look at the last column. Most labels were not drawn by a radiologist looking at each image. A program read the report and guessed the label from words like "no pneumothorax" or "possible effusion." This is the label-quality problem from Lesson 1.3: if the report was hedged, wrong or silent about a finding, the label is too. It is one reason Lesson 2.4 spends time on how reports are written.

Try it: open real DICOM images

OHIF Viewer is a free, open-source DICOM viewer that runs in your web browser and comes with de-identified example studies. Open a CT study and try:

Nothing to install, no account needed. It may be slow on a phone; a laptop works best.

Knowledge check

Answer each question to continue. Any answer is fine; read the explanation.

On CT, a region measures about 0 HU. What is it most likely to be?

The Hounsfield scale is set so that water is 0 and air is -1000. Bone is several hundred or more.

The radiologist reading Mr. Diaz's CTPA switches from a lung window to a soft-tissue window. What changes?

Windowing changes only how the stored numbers are shown on screen. The data stays the same, so there is no extra radiation.

A chest X-ray AI was trained on CheXpert. Why should you be cautious about its labels?

Report-mined labels carry every gap and hedge of the original report, plus errors from the program reading it. This is the label noise from Lesson 1.3.

Key takeaways

Go further (optional)

Next lesson: the images exist and the numbers are stored. How do they get from the scanner to the radiologist's screen, and the result back to Mr. Diaz's team?

← The Journey of a Scan Next: Reading a Radiology Report →