---
title: X-ray imaging and computed tomography
heading: Producing X-rays in a tube, exponential attenuation with half-value layers, contrast between bone and soft tissue, projections as line integrals, reconstructing slices by filtered back-projection, Hounsfield units, and the photon noise that sets dose
eyebrow: S15 · Lesson 38 · X-ray imaging and computed tomography
xp: 50
---

::: hook
An X-ray image is a shadow: photons that make it through the body expose the detector, and bone, which absorbs more, leaves a light silhouette. A plain radiograph flattens the whole body onto one plane. Computed tomography measures thousands of such shadows from every angle around the patient and solves for the attenuation at every point in a slice, the inverse problem that won Hounsfield and Cormack the 1979 Nobel Prize. The mathematics is the Fourier-slice theorem of S7's world, and the limit on image quality is counting statistics: each pixel is only as good as the number of photons behind it.
:::

::: play
- The fraction of X-rays transmitted through soft tissue ($\mu_s$, about 0.19 cm⁻¹ at diagnostic energies) of thickness L, with and without a 3 cm bone ($\mu_b$) in the path.
- Attenuation is exponential, so each half-value layer, $\ln 2/\mu$, halves the beam.
- The contrast between paths with and without bone, $1 - e^{-(\mu_b - \mu_s)b}$, doesn't depend on how much soft tissue surrounds it.
:::

```sim plot
view: graph
x: L = 5..40
y: T = 0.0001..1 log
slider: s = 0.15..0.25 step 0.005 = 0.19
slider: b = 0.3..1 step 0.02 = 0.5
plot: exp(-s*L) | samples: 200 | label: soft tissue only
plot: exp(-s*(L - 3) - b*3) | samples: 200 | color: ch3 | label: with 3 cm of bone
readout: half-value layer, cm = ln(2)/s | digits: 3
readout: bone contrast = 1 - exp(-(b - s)*3) | digits: 3
```

::: predict
## Diagnostic X-rays are attenuated by soft tissue with μ ≈ 0.19 cm⁻¹. What fraction passes straight through a 20 cm abdomen?

- [ ] About 20%
- [ ] About 50%
- [x] About 2%
- [ ] About 0.001%

::: reveal
$e^{-0.19 \times 20} = e^{-3.8}$ = 0.022. Only 2% of the photons reach the detector unscattered; the rest are absorbed or scattered, depositing dose. Each half-value layer is ln 2/0.19 = 3.6 cm, and 20 cm is five and a half of them.
:::
:::

::: nameit
## Making X-rays

Electrons accelerated through the tube voltage (60 to 140 kV) strike a tungsten anode. Most of their energy becomes heat; under 1% becomes bremsstrahlung and characteristic X-rays, with photon energies up to e times the tube voltage, so a 100 kV tube's shortest wavelength is $hc/E$ = 1.24 nm·keV/100 keV = 0.0124 nm.

## Attenuation

A narrow beam through a uniform material falls as

$$I = I_0e^{-\mu x}, \qquad \text{HVL} = \frac{\ln 2}{\mu}$$

μ depends on photon energy and on the material's density and atomic number (photoelectric absorption grows roughly as $Z^3/E^3$), which is why calcium-rich bone and iodine contrast agents stand out. Through a path of different materials the exponents add: $I = I_0\exp(-\sum\mu_ix_i)$.

## Projections and reconstruction

Each CT measurement gives a line integral of attenuation:

$$p = \ln\frac{I_0}{I} = \int\mu\,dl$$

The set of all projections at all angles is the Radon transform of the slice. **Filtered back-projection** filters each projection with a ramp filter |k| and smears it back across the image along its direction; summed over angles, that inverts the transform. Sampling needs about $\frac{\pi}{2}N$ views for N detector bins across the field.

## Hounsfield units

CT reports attenuation relative to water:

$$\text{HU} = 1000\,\frac{\mu - \mu_w}{\mu_w - \mu_\text{air}} \approx 1000\,\frac{\mu - \mu_w}{\mu_w}$$

so water is 0, air −1000, soft tissues tens to a few tens of HU, and dense bone around +1000 or more.

## Noise and dose

Photons arrive randomly, so a measurement built on N detected photons has relative noise $1/\sqrt{N}$. Halving the noise takes four times the photons, and four times the dose.
:::

::: example
## A beam crosses 20 cm of soft tissue, or 17 cm of soft tissue plus 3 cm of bone with μ = 0.5 cm⁻¹. What's the contrast between the two paths, and what's one projection value?

::: solution
1. **Contrast between the paths.** The bone path transmits
   $$\begin{aligned} \frac{I_b}{I_t} &= e^{-(0.5 - 0.19) \times 3} \\ &= 0.395 \end{aligned}$$
   times as much, a contrast of 60%.
2. **Soft tissue alone.**
   $$\frac{I}{I_0} = 0.0224$$
3. **Projection value.**
   $$\begin{aligned} p &= \ln\frac{1}{0.0224} \\ &= 3.80 \end{aligned}$$
   which is just μL = 0.19 × 20.

**Answer:** the bone path transmits 0.395 times as much, a 60% contrast, and the soft-tissue path's projection value is 3.80.
:::
:::

::: example
## A tissue has μ = 0.21 cm⁻¹ where water's is 0.19. What's its CT number? How many photons give 1% noise, and how many views does a 512-bin detector need?

::: solution
1. **CT number.**
   $$\begin{aligned} \text{HU} &= 1000 \times \frac{0.02}{0.19} \\ &= +105 \end{aligned}$$
2. **Photons for 1% noise.**
   $$\begin{aligned} N &= \frac{1}{0.01^2} \\ &= 10\,000 \end{aligned}$$
   per measurement.
3. **Views.** A 512-bin detector needs about
   $$\frac{\pi}{2} \times 512 \approx 800$$
   views around the patient.

**Answer:** the tissue's CT number is +105, 1% noise takes 10,000 photons per measurement, and the detector needs about 800 views.
:::
:::

::: example
## A CT protocol gives acceptable noise at 2 mSv with 1 mm pixels and 5 mm slices. What dose would keep the same noise with 0.5 mm pixels and 2.5 mm slices?

::: solution
1. **How noise scales.** In CT the noise variance in a voxel goes as
   $$\sigma^2 \propto \frac{1}{Dw^3h}$$
   with D the dose, w the pixel width and h the slice thickness.
2. **Why.** Fewer photons pass through each smaller voxel, and the reconstruction filter amplifies the finer detail's noise.
3. **Dose for the smaller voxels.** Halving w costs a factor of 8, and halving h another 2:
   $$\begin{aligned} D &= 2\ \text{mSv} \times 8 \times 2 \\ &= 32\ \text{mSv} \end{aligned}$$
   a sixteenfold rise.
4. **Consequence.** That's why high-resolution scans are limited to small regions or accept more noise.

**Answer:** it would take 32 mSv, sixteen times the dose.
:::
:::

::: check
given: m = 0.15 | 0.19 | 0.25; x = 5 | 15 | 30
answer: exp(-m*x)
tolerance: 0.5%

## What fraction of a narrow X-ray beam passes through {x} cm of tissue with μ = {m} cm⁻¹?

::: right
Right. $e^{-\mu x}$ = {answer}.
:::

::: misses
- [10^(-m*x)] Linear attenuation coefficients use the natural exponential.
- [any] Not yet. Exponential attenuation.
:::
:::

::: check
given: m = 0.15 | 0.19 | 0.5 | 1.5
answer: ln(2)/m
unit: cm
tolerance: 0.5%

## What's the half-value layer of a material with μ = {m} cm⁻¹?

::: right
Right. ln 2/μ = {answer} cm.
:::

::: misses
- [1/m] That's the mean free path, where the beam falls to 1/e.
- [any] Not yet. Solve $e^{-\mu x} = 1/2$.
:::
:::

::: check
given: m = 0.17 | 0.23 | 0.38; w = 0.19 | 0.2
answer: 1000*(m - w)/w
tolerance: 0.5%

## A voxel has μ = {m} cm⁻¹ and water's is {w} cm⁻¹. What's its CT number, taking air as zero?

::: right
Right. $1000(\mu - \mu_w)/\mu_w$ = {answer} HU.
:::

::: misses
- [1000*m/w] Subtract water's attenuation first: water is 0 HU.
- [any] Not yet. The Hounsfield scale.
:::
:::

::: check
given: r = 0.005 | 0.02 | 0.1
answer: ln(1/r)
tolerance: 0.5%

## A CT detector sees {r} of the unattenuated intensity. What's the projection value, ∫μ dl?

::: right
Right. $\ln(I_0/I)$ = {answer}.
:::

::: misses
- [log(1/r)] Use the natural logarithm.
- [any] Not yet. Take the log of the attenuation.
:::
:::

::: check
given: e = 0.005 | 0.01 | 0.03
answer: 1/e^2
tolerance: 0.5%

## How many detected photons give a relative noise of {e}?

::: right
Right. $1/\epsilon^2$ = {answer}.
:::

::: misses
- [1/e] Noise falls as $1/\sqrt{N}$, so square it.
- [any] Not yet. Poisson statistics.
:::
:::

::: check
given: s = 0.19 | 0.21; b = 0.45 | 0.6; t = 1 | 3 | 5
answer: 1 - exp(-(b - s)*t)
tolerance: 0.5%

## Bone with μ = {b} cm⁻¹ replaces {t} cm of soft tissue with μ = {s} cm⁻¹ in a beam's path. What's the contrast, the fractional drop in transmitted intensity?

::: right
Right. $1 - e^{-(\mu_b - \mu_s)t}$ = {answer}.
:::

::: misses
- [exp(-(b - s)*t)] That's the ratio of intensities; contrast is one minus it.
- [any] Not yet. Compare the two paths.
:::
:::

::: check
kind: parts
given: D = 1 | 5; w = 0.5 | 0.75; h = 0.5 | 0.4; k = 0.5 | 0.7

## A CT scan at {D} mSv is changed: pixel width scaled by {w}, slice thickness by {h}, and target noise (standard deviation) by a factor of {k}.

::: part
answer: D/(w^3*h*k^2)
unit: mSv
tolerance: 0.5%

### What dose does the new protocol need?

::: misses
- [D/(w^2*h*k^2)] Noise variance goes as $1/(Dw^3h)$: the pixel width enters cubed.
- [D/(w^3*h*k)] Noise is a standard deviation; variance goes as its square.
- [any] $D' = D/(w^3hk^2)$.
:::
:::
:::

::: check
kind: derivation
vars: m = 0.05..1, x = 0..30, w = 0.15..0.25

## A material has attenuation coefficient μ (cm⁻¹); water's is $\mu_w$.

::: step
answer: exp(-m*x)

### What fraction of a narrow beam passes through x cm?
:::

::: step
answer: ln(2)/m

### What is its half-value layer?
:::

::: step
answer: 1000*(m - w)/w

### What is its CT number?
:::

::: right
Right. Attenuation, half-value layer and Hounsfield units are three views of the same coefficient.
:::
:::

::: explain
## Why does a CT image need projections from many angles, when a radiograph uses only one?

::: model
A single projection records only the total attenuation along each line through the body, so structures at different depths along the same line add together and can't be separated: a radiograph superimposes everything on one plane. Each additional angle gives new line integrals through the same points along different paths. With projections over a full half-turn, there are enough independent line integrals to solve for the attenuation at every point in the slice, which is what filtered back-projection does. The ramp filter is needed because simple back-projection over-weights the low spatial frequencies near the center of Fourier space, where every projection's slice overlaps.
:::
:::

::: practice

::: check
given: m = 0.1 | 2; x = 0.5 | 40
answer: exp(-m*x)
tolerance: 0.5%

## Transmission: μ = {m} cm⁻¹, x = {x} cm?

::: misses
- [any] $e^{-\mu x}$.
:::
:::

::: check
given: m = 0 | 3; w = 0.17 | 0.21
answer: 1000*(m - w)/w
tolerance: 0.5%

## HU: μ = {m}, water {w}?

::: misses
- [any] $1000(\mu - \mu_w)/\mu_w$.
:::
:::

::: check
given: e = 0.001 | 0.003 | 0.01 | 0.02 | 0.05 | 0.1
answer: 1/e^2
tolerance: 0.5%

## Photons for noise {e}?

::: misses
- [any] $1/\epsilon^2$.
:::
:::
:::
