Algorithm Search⌘K

Algorithmadvanced

Lambda tomography

Also called local tomography.

Reconstruct Lambda f, the square root of minus the Laplacian of f, from local data. It is not f, but it has the same edges, and each value needs only the rays near the point.

Time
O(a d + a n^2) worst
Space
O(a d + n^2) extra
Where
a = the number of projection angles; d = the number of detector bins; n = the side of the n x n output image
Properties
deterministicnot in placenot iterativelineariterative
Origin
A. Faridani, E. L. Ritman, K. T. Smith, 1992

Lambda tomography reconstructs, from parallel-beam CT data, the image Λf=(−Δ)1/2f\Lambda f = (-\Delta)^{1/2} f in place of the attenuation ff. The algorithm is filtered back-projection with the ramp filter replaced by minus the second derivative: Λf=12πR#(−∂s2Rf)\Lambda f = \frac{1}{2\pi}\mathcal{R}^\#(-\partial_s^2\mathcal{R}f). A second derivative is local, so the value at a point needs only the rays that pass near that point. This makes the method work on truncated projections, where the interior problem has no unique solution for ff. The output is not ff. It has the same edges as ff, at the same places, but its values are different: Λf\Lambda f has no mean value and is unbounded at a jump. With aa angles, dd bins and an n×nn \times n image it takes O(ad+an2)O(a d + a n^2) time.

In plain words

Ordinary CT needs every ray through the whole object. The filter of ordinary CT has long tails, so a pixel is affected by rays that pass far from it. If the detector is too small and some rays are missing, every pixel gets some error.

Lambda tomography uses a short filter: at each detector cell, it compares the reading with its two neighbors. A pixel then depends only on the rays that pass close to it. If the region of interest is fully covered by the measured rays, the missing rays do not matter.

The price is that the picture is not the density. It is a sharpened version of the density, in which a constant area is close to flat but each boundary shows as a strong bright and dark line. For finding edges, cracks and the shape of a structure, this is often enough.

The problem

The data is a parallel sinogram P[k][j]P[k][j] for k=0,…,a−1k = 0, \ldots, a - 1 and j=0,…,d−1j = 0, \ldots, d - 1. Row kk samples Rf(θk,⋅)\mathcal{R}f(\theta_k, \cdot) at θk=kπ/a\theta_k = k\pi/a, and bin jj has its center at sj=(j−(d−1)/2)τs_j = (j - (d-1)/2)\tau. Here Rf(θ,s)=∫f(s ω+t ω⊥) dt\mathcal{R}f(\theta, s) = \int f(s\,\omega + t\,\omega^\perp)\,dt is the Radon transform, with ω=(cos⁡θ,sin⁡θ)\omega = (\cos\theta, \sin\theta) and ω⊥=(−sin⁡θ,cos⁡θ)\omega^\perp = (-\sin\theta, \cos\theta). The back-projection is R#q(x)=∫0πq(θ,x⋅ω(θ)) dθ\mathcal{R}^\# q(x) = \int_0^\pi q(\theta, x\cdot\omega(\theta))\,d\theta, the back-projection operator. Bins outside the measured range count as 0. The output is an n×nn \times n image on [−1,1]2[-1, 1]^2, with pixel (i,j)(i, j) centered at xj=−1+(2j+1)/nx_j = -1 + (2j+1)/n and yi=1−(2i+1)/ny_i = 1 - (2i+1)/n.

With the Fourier transform in ordinary frequency, Λ\Lambda multiplies f^(ξ)\hat f(\xi) by 2π∣ξ∣2\pi|\xi|, and Λ−1\Lambda^{-1} multiplies it by 1/(2π∣ξ∣)1/(2\pi|\xi|). The algorithm evaluates

Λf=12π R#(−∂s2 Rf),and optionallyΛf+μ Λ−1f=12π R#((−∂s2+μ) Rf).\Lambda f = \frac{1}{2\pi}\,\mathcal{R}^\#\left(-\partial_s^2\,\mathcal{R}f\right), \qquad \text{and optionally} \qquad \Lambda f + \mu\,\Lambda^{-1}f = \frac{1}{2\pi}\,\mathcal{R}^\#\left((-\partial_s^2 + \mu)\,\mathcal{R}f\right).

Some texts write R#(−∂s2Rf)\mathcal{R}^\#(-\partial_s^2\mathcal{R}f) without the constant. The constant 1/(2π)1/(2\pi) makes the output equal to Λf\Lambda f in this convention. The term μΛ−1f\mu\Lambda^{-1}f is not local. It adds a smooth image that brings back some of the contrast between regions.

The algorithm

  1. LAMBDA(P, τ, n, μ) ▷ P[k][j]: angle θ_k = kπ/a, bin center s_j = (j - (d-1)/2) τ
  2. 1a, d ← the number of rows and of columns of P
  3. 2q_k[j] ← -(P[k][j+1] - 2 P[k][j] + P[k][j-1])/τ² + μ P[k][j] for each k and j ▷ P = 0 outside
  4. 3for each pixel (i, j) with center (x_j, y_i) do
  5. 4f[i][j] ← Σ_k LININTERP(q_k, (x_j cos θ_k + y_i sin θ_k)/τ + (d-1)/2)
  6. 5return f/(2a)

Line L2 is the central second difference, which approximates −∂s2-\partial_s^2, plus the optional term. Line L4 is the discrete back-projection, with linear interpolation and 0 outside the detector. Line L5 applies the weight 12π⋅πa=12a\frac{1}{2\pi}\cdot\frac{\pi}{a} = \frac{1}{2a}. With μ=0\mu = 0, the value at a pixel xx uses only the bins whose centers lie within 2τ2\tau of x⋅ω(θk)x\cdot\omega(\theta_k) in each row.

Example

Take the disk of radius R=1/2R = 1/2 with density 1. Its projection is 21/4−s22\sqrt{1/4 - s^2} at every angle. With d=7d = 7 bins and τ=1/4\tau = 1/4:

quantity values at j=0,…,6j = 0, \ldots, 6
projection P[k][j]P[k][j] 0, 0, 0.8660, 1, 0.8660, 0, 0
filtered qk[j]q_k[j] 0, -13.8564, 11.7128, 4.2872, 11.7128, -13.8564, 0

The center value is qk[3]=−(0.8660−2+0.8660)⋅16=4.2872q_k[3] = -(0.8660 - 2 + 0.8660) \cdot 16 = 4.2872. With a=4a = 4 angles the value at the origin is 18⋅4⋅4.2872=2.1436\frac{1}{8} \cdot 4 \cdot 4.2872 = 2.1436. The filtered profile is large and positive just inside the edge and negative just outside it, which is how the edge shows up.

The exact Λf\Lambda f of this disk follows from the formula. The projection p(s)=2R2−s2p(s) = 2\sqrt{R^2 - s^2} has −p′′(s)=2R2/(R2−s2)3/2-p''(s) = 2R^2/(R^2 - s^2)^{3/2}, so for ∣x∣<R|x| < R, with k=∣x∣/Rk = |x|/R,

Λf(x)=12π∫0π2R2 dθ(R2−∣x∣2cos⁡2θ)3/2=2E(k)πR (1−k2),\Lambda f(x) = \frac{1}{2\pi}\int_0^\pi \frac{2R^2\,d\theta}{(R^2 - |x|^2\cos^2\theta)^{3/2}} = \frac{2E(k)}{\pi R\,(1 - k^2)},

where E(k)=∫0π/21−k2sin⁡2ϕ dϕE(k) = \int_0^{\pi/2}\sqrt{1 - k^2\sin^2\phi}\,d\phi is the complete elliptic integral of the second kind. At the center E(0)=π/2E(0) = \pi/2 and Λf(0)=1/R=2\Lambda f(0) = 1/R = 2, so the coarse example above is off by 7 percent. The value grows like 1/(π(R−∣x∣))1/(\pi(R - |x|)) near the edge.

A finer grid, measured with the code: a=32a = 32 angles, d=65d = 65 bins, τ=22/65=0.0435\tau = 2\sqrt{2}/65 = 0.0435. These are measurements of this setup.

point x=(x1,0)x = (x_1, 0) code exact Λf\Lambda f
x1=0x_1 = 0 2.0038 2
x1=0.25x_1 = 0.25 2.5143 2.4912
x1=0.4x_1 = 0.4 4.7938 4.5142
x1=0.45x_1 = 0.45 8.1860 7.8518
x1=0.6x_1 = 0.6, outside the disk -2.6084 negative

For the Gaussian f(x)=e−4π∣x∣2f(x) = e^{-4\pi|x|^2} the exact value at the origin is Λf(0)=∫2π∣ξ∣⋅14e−π∣ξ∣2/4 dξ=2π\Lambda f(0) = \int 2\pi|\xi| \cdot \frac{1}{4}e^{-\pi|\xi|^2/4}\,d\xi = 2\pi. The code gives 6.20906.2090 there, and its largest error over the 16×1616 \times 16 grid against the exact formula is 0.1080.108.

Correctness

The proof in proofs/correctness.md has four parts. First, by the Fourier slice theorem and polar coordinates, back-projecting a projection filtered by the multiplier m(σ)m(\sigma) gives the image filtered by m(∣ξ∣)/∣ξ∣m(|\xi|)/|\xi|. With m(σ)=4π2σ2m(\sigma) = 4\pi^2\sigma^2, the multiplier of −∂s2-\partial_s^2, this gives 2πΛf2\pi\Lambda f, and with m=1m = 1 it gives 2πΛ−1f2\pi\Lambda^{-1}f. Second, the formula needs ∂s2Rf\partial_s^2\mathcal{R}f only on the lines through the point, so it is local. Third, the second difference has the error O(τ2)O(\tau^2), the linear interpolation has the error O(τ2)O(\tau^2), and the sum over angles is the trapezoidal rule for a periodic function. The discrete value at a point uses only the bins within 2τ2\tau of the lines through it. Fourth, Λ\Lambda is an elliptic pseudodifferential operator of order 1, so Λf\Lambda f and ff have the same singular support. This is the theorem behind the method: the edges are in the right places.

Proof: Correctness of lambda tomographyfull

We use the conventions of the page. ω(θ)=(cos⁡θ,sin⁡θ)\omega(\theta) = (\cos\theta, \sin\theta), the Radon transform is p(θ,s)=Rf(θ,s)=∫f(s ω+t ω⊥) dtp(\theta, s) = \mathcal{R}f(\theta, s) = \int f(s\,\omega + t\,\omega^\perp)\,dt, the back-projection is R#q(x)=∫0πq(θ,x⋅ω(θ)) dθ\mathcal{R}^\# q(x) = \int_0^\pi q(\theta, x\cdot\omega(\theta))\,d\theta, and the Fourier transform is f^(ξ)=∫f(x)e−2πix⋅ξ dx\hat f(\xi) = \int f(x)e^{-2\pi i x\cdot\xi}\,dx. The operator Λ=(−Δ)1/2\Lambda = (-\Delta)^{1/2} has the multiplier 2π∣ξ∣2\pi|\xi|, so Λf^(ξ)=2π∣ξ∣f^(ξ)\widehat{\Lambda f}(\xi) = 2\pi|\xi|\hat f(\xi), and Λ−1\Lambda^{-1} has the multiplier 1/(2π∣ξ∣)1/(2\pi|\xi|).

The proof has four parts. Part 1 proves the formula that the algorithm discretizes. Part 2 proves that it is local. Part 3 says what the algorithm computes in the discrete case and why the computed value at a point uses only the data near the lines through it. Part 4 proves that Λf\Lambda f has the same singular support as ff, which is why the method shows the edges.

Part 1. The formula

Lemma 1 (filtered back-projection with a general filter). Let f∈Cc∞(R2)f \in C^\infty_c(\mathbb{R}^2), and let mm be an even continuous function on R\mathbb{R} with ∣m(σ)∣≤C(1+∣σ∣)2|m(\sigma)| \le C(1 + |\sigma|)^2. Put q(θ,s)=∫m(σ) p^θ(σ) e2πisσ dσq(\theta, s) = \int m(\sigma)\,\hat p_\theta(\sigma)\,e^{2\pi i s\sigma}\,d\sigma, where p^θ\hat p_\theta is the 1D transform of p(θ,⋅)p(\theta, \cdot). If ∫∣m(∣ξ∣)∣ ∣f^(ξ)∣ ∣ξ∣−1 dξ<∞\int |m(|\xi|)|\,|\hat f(\xi)|\,|\xi|^{-1}\,d\xi < \infty, then

R#q(x)=∫R2m(∣ξ∣)∣ξ∣ f^(ξ) e2πix⋅ξ dξ.\mathcal{R}^\# q(x) = \int_{\mathbb{R}^2} \frac{m(|\xi|)}{|\xi|}\,\hat f(\xi)\,e^{2\pi i x\cdot\xi}\,d\xi.

Proof. By the Fourier slice theorem, p^θ(σ)=f^(σ ω(θ))\hat p_\theta(\sigma) = \hat f(\sigma\,\omega(\theta)). So

R#q(x)=∫0π∫Rm(σ) f^(σω) e2πiσ x⋅ω dσ dθ.\mathcal{R}^\# q(x) = \int_0^\pi \int_{\mathbb{R}} m(\sigma)\,\hat f(\sigma\omega)\,e^{2\pi i\sigma\,x\cdot\omega}\,d\sigma\,d\theta.

The map (θ,σ)↦ξ=σω(θ)(\theta, \sigma) \mapsto \xi = \sigma\omega(\theta) from [0,π)×R[0, \pi) \times \mathbb{R} covers the plane once up to a null set, with dξ=∣σ∣ dσ dθd\xi = |\sigma|\,d\sigma\,d\theta. Since mm is even, m(σ)=m(∣ξ∣)m(\sigma) = m(|\xi|), and the integral becomes the right side. It converges absolutely by the hypothesis, so Fubini applies. □\square

Theorem 1. For f∈Cc∞(R2)f \in C^\infty_c(\mathbb{R}^2),

Λf=12π R#(−∂s2 Rf),Λ−1f=12π R#Rf.\Lambda f = \frac{1}{2\pi}\,\mathcal{R}^\#\left(-\partial_s^2\,\mathcal{R}f\right), \qquad \Lambda^{-1} f = \frac{1}{2\pi}\,\mathcal{R}^\#\mathcal{R}f.

Proof. The function f^\hat f decays faster than any power. For the first formula take m(σ)=4π2σ2m(\sigma) = 4\pi^2\sigma^2, which is the multiplier of −∂s2-\partial_s^2. Lemma 1 gives R#(−∂s2p)(x)=∫4π2∣ξ∣ f^(ξ) e2πix⋅ξ dξ=2π Λf(x)\mathcal{R}^\#(-\partial_s^2 p)(x) = \int 4\pi^2|\xi|\,\hat f(\xi)\,e^{2\pi i x\cdot\xi}\,d\xi = 2\pi\,\Lambda f(x). For the second take m=1m = 1. The integral ∫∣f^(ξ)∣ ∣ξ∣−1 dξ\int |\hat f(\xi)|\,|\xi|^{-1}\,d\xi converges in 2D, because ∣ξ∣−1|\xi|^{-1} is integrable near 0 in the plane. Lemma 1 gives R#p(x)=∫∣ξ∣−1f^(ξ) e2πix⋅ξ dξ=2π Λ−1f(x)\mathcal{R}^\# p(x) = \int |\xi|^{-1}\hat f(\xi)\,e^{2\pi i x\cdot\xi}\,d\xi = 2\pi\,\Lambda^{-1}f(x). □\square

Compare with filtered back-projection, which uses m(σ)=∣σ∣m(\sigma) = |\sigma| and gives ff itself. Lambda tomography uses m(σ)=4π2σ2/(2π)=2πσ2m(\sigma) = 4\pi^2\sigma^2/(2\pi) = 2\pi\sigma^2, which is ∣σ∣|\sigma| times 2π∣σ∣2\pi|\sigma|, so its output is ff filtered by 2π∣ξ∣2\pi|\xi|.

Part 2. Locality

Corollary 1. Λf(x)\Lambda f(x) depends only on the values of Rf\mathcal{R}f on any open set of lines that contains all lines through xx.

Proof. By Theorem 1, 2πΛf(x)=−∫0π∂s2p(θ,s)∣s=x⋅ω(θ) dθ2\pi\Lambda f(x) = -\int_0^\pi \partial_s^2 p(\theta, s)|_{s = x\cdot\omega(\theta)}\,d\theta. For each θ\theta, the second derivative at s=x⋅ω(θ)s = x\cdot\omega(\theta) depends only on p(θ,⋅)p(\theta, \cdot) in a neighborhood of x⋅ω(θ)x\cdot\omega(\theta), and the line (θ,x⋅ω(θ))(\theta, x\cdot\omega(\theta)) passes through xx. □\square

So if the data is known only for the lines that meet a disk BB, then Λf\Lambda f is known on the open disk BB. In particular, truncated projections give Λf\Lambda f exactly inside the region of interest, while ff itself is not determined there (interior tomography). The operator Λ−1\Lambda^{-1} is not local: R#p(x)\mathcal{R}^\# p(x) uses pp on the lines through xx, but these lines leave the region of interest.

Part 3. The discrete algorithm

Line L2 replaces −∂s2p-\partial_s^2 p by the central second difference

qj=−pj+1−2pj+pj−1τ2+μ pj,q_j = -\frac{p_{j+1} - 2p_j + p_{j-1}}{\tau^2} + \mu\,p_j,

with p−1=pd=0p_{-1} = p_d = 0. For p∈C4p \in C^4 Taylor expansion gives −(p(s+τ)−2p(s)+p(s−τ))/τ2=−p′′(s)−τ2p′′′′(ξ)/12-(p(s + \tau) - 2p(s) + p(s - \tau))/\tau^2 = -p''(s) - \tau^2 p''''(\xi)/12 for some ξ\xi, so the error is at most τ2max⁡∣p′′′′∣/12\tau^2\max|p''''|/12. Line L4 reads qq at x⋅ω(θk)x\cdot\omega(\theta_k) by linear interpolation, with the error at most τ2max⁡∣q′′∣/8\tau^2\max|q''|/8 for a smooth qq, and line L5 replaces 12π∫0π dθ\frac{1}{2\pi}\int_0^\pi\,d\theta by 12π⋅πa∑k=12a∑k\frac{1}{2\pi}\cdot\frac{\pi}{a}\sum_k = \frac{1}{2a}\sum_k. The integrand has the period π\pi in θ\theta, so this is the trapezoidal rule for a periodic function, which converges faster than any power of 1/a1/a for smooth ff. With μ=0\mu = 0 the output is therefore Λf(x)+O(τ2)+O(a−k)\Lambda f(x) + O(\tau^2) + O(a^{-k}) for every kk and smooth ff. With μ≠0\mu \ne 0 it is Λf+μΛ−1f\Lambda f + \mu\Lambda^{-1}f up to the same errors, by the second formula of Theorem 1.

The discrete method is local in the same way as the continuous formula. The value at xx uses, for each kk, two interpolation nodes bb and b+1b + 1 around the fractional index u=x⋅ω(θk)/τ+(d−1)/2u = x\cdot\omega(\theta_k)/\tau + (d-1)/2, and qbq_b and qb+1q_{b+1} use pb−1,…,pb+2p_{b-1}, \ldots, p_{b+2}. All of these bins have centers within 2τ2\tau of x⋅ω(θk)x\cdot\omega(\theta_k). So with μ=0\mu = 0 the output at xx does not change when the data changes only at bins with ∣sj−x⋅ω(θk)∣>2τ|s_j - x\cdot\omega(\theta_k)| > 2\tau in row kk. The test checks this with random changes outside ∣s∣≤∣x∣+2τ|s| \le |x| + 2\tau, which is a smaller set since ∣x⋅ω∣≤∣x∣|x\cdot\omega| \le |x|.

Part 4. Edges

Theorem 2. For a distribution ff with compact support, Λf\Lambda f and ff have the same singular support, that is, Λf\Lambda f is smooth near a point if and only if ff is.

Proof sketch with the standard tools. Λ\Lambda is a classical pseudodifferential operator of order 1 with the principal symbol 2π∣ξ∣2\pi|\xi|, after a smooth cutoff of the symbol near ξ=0\xi = 0, which changes Λf\Lambda f only by a smooth function. Every pseudodifferential operator is pseudolocal, so the singular support of Λf\Lambda f lies in that of ff. The symbol 2π∣ξ∣2\pi|\xi| does not vanish for ξ≠0\xi \ne 0, so Λ\Lambda is elliptic and has a parametrix QQ of order −1-1 with QΛf−fQ\Lambda f - f smooth. Pseudolocality of QQ gives the other inclusion. □\square

This is the theorem that justifies the method: the jumps of ff show up in Λf\Lambda f at the same places. The values are not the same. Λ\Lambda multiplies the Fourier transform by 2π∣ξ∣2\pi|\xi|, so it removes the mean and changes the size of each feature. At a jump of a piecewise smooth ff, Λf\Lambda f is not bounded: for the disk of radius RR it grows like 1/(R−∣x∣)1/(R - |x|) near the edge from inside. The page computes this case in closed form.

Complexity

In the real-RAM model, line L2 takes O(d)O(d) per row, O(ad)O(a d) in total. Lines L3 and L4 take O(1)O(1) per angle and pixel, O(an2)O(a n^2) in total. The total is O(ad+an2)O(a d + a n^2) time and O(ad+n2)O(a d + n^2) space. The filter is cheaper than the ramp filter of FBP, which takes O(dlog⁡d)O(d \log d) per row with an FFT, but the back-projection dominates both. To reconstruct only a region of interest with nrn_r pixels, the cost is O(ad+anr)O(a d + a n_r), and the data needs to cover only the lines that meet the region.

Properties

  • Local. With μ=0\mu = 0 the value at a point depends only on the data on lines within a small distance of the point. Truncated projections give exact values (up to discretization) inside the region that the measured lines cover.
  • Not the density. Λf\Lambda f has the Fourier transform 2π∣ξ∣f^(ξ)2\pi|\xi|\hat f(\xi), which is 0 at ξ=0\xi = 0. So ∫Λf dx=0\int\Lambda f\,dx = 0 for an integrable Λf\Lambda f, and a large constant region has a value near 0 far from its edges.
  • Same edges. Λf\Lambda f is smooth exactly where ff is smooth. At a jump, Λf\Lambda f is unbounded, with opposite signs on the two sides, as the disk example shows.
  • Linear. The output is a linear function of the data.
  • Noise. The filter of line L2 with the factor 1/(2π)1/(2\pi) has the response 4sin⁡2(πντ)/(2πτ2)4\sin^2(\pi\nu\tau)/(2\pi\tau^2). At the Nyquist frequency ν=1/(2τ)\nu = 1/(2\tau) this is 2/(πτ2)2/(\pi\tau^2), against 1/(2τ)1/(2\tau) for the ramp of FBP, so it amplifies the noise at high frequency by the factor 4/(πτ)4/(\pi\tau) more. Practical codes smooth the data first.

Variants and improvements

  • Lambda plus a smooth part. Λf+μΛ−1f\Lambda f + \mu\Lambda^{-1}f adds back some low-frequency contrast. The second term is not local, so with truncated data it is only approximate. The code supports it with the parameter μ\mu.
  • Smoothed kernels. Replace −∂s2-\partial_s^2 by a smooth kernel with the same behavior at high frequency, such as the second derivative of a Gaussian. The result is a smoothed Λf\Lambda f, and the locality radius grows to the width of the kernel.
  • Fan-beam and cone-beam data. The same idea works for divergent beams with a change of variables, as in fan-beam filtered back-projection.
  • Exact interior reconstruction. If extra knowledge is available, for example the values of ff on a small subregion, the interior problem has a unique solution and other methods recover ff itself (interior tomography).

When to use it

Use lambda tomography when the detector does not cover the whole object, or when only a small region is of interest, and the goal is to find edges, boundaries or small features, not to measure densities. Examples are a region of interest scan of a large sample in micro CT, or the search for cracks in a part. Do not use it when the attenuation values themselves matter. In that case use full data and filtered back-projection, or interior tomography with extra knowledge.

Pitfalls

  • Reading the values as densities. Λf\Lambda f is not ff. A region of constant density shows as nearly 0 inside, with strong lines at its boundary.
  • The missing constant. The formula R#(−∂s2Rf)\mathcal{R}^\#(-\partial_s^2\mathcal{R}f) without the factor 1/(2π)1/(2\pi) gives 2πΛf2\pi\Lambda f. The scale does not matter for edge detection, but it matters when the result is combined with other images.
  • Noise. The second difference has a large gain at high frequency. Without smoothing the image is dominated by noise.
  • Wrong edges for the variant. The term μΛ−1f\mu\Lambda^{-1}f is not local, so with truncated data it adds an error that is smooth but not small. Choose μ\mu by experiment and do not read the result as ff.
  • Data that is not zero at the detector ends. The code treats the bins outside the detector as 0. At a truncated detector the second difference at the last bin then sees a jump and gives a large value. These values only affect pixels whose lines pass within 2τ2\tau of the detector end, so keep the region of interest at least that far inside.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

lambda_tomography.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/lambda-tomography/. The authors are listed in prov/8VWFH5.jsonl.
"""Lambda tomography: the local reconstruction Lambda f = (1 / (2 pi)) R^# (-d^2/ds^2) R f.

Conventions:
- omega(t) = (cos t, sin t). The sinogram P[k][j] samples the Radon transform
  R f(theta_k, s_j) with theta_k = k pi / a and s_j = (j - (d - 1) / 2) tau.
- R^# g(x) = integral_0^pi g(theta, x . omega(theta)) dtheta, approximated by
  (pi / a) sum_k.
- Lambda = (-Laplacian)^(1/2), with the Fourier multiplier 2 pi |xi| in
  ordinary frequency. Lambda^(-1) f = (1 / (2 pi)) R^# R f.
- The output is an n x n image on [-1, 1]^2, pixel (i, j) centered at
  x_j = -1 + (2 j + 1) / n and y_i = 1 - (2 i + 1) / n.
- A sample outside the detector counts as 0. Only the samples within one bin
  of x . omega(theta_k) enter the value at x (with mu = 0).
"""

import math


def lambda_filter(p, tau, mu=0.0):
    """q_j = -(p_(j+1) - 2 p_j + p_(j-1)) / tau^2 + mu p_j, with p = 0 outside the detector."""
    d = len(p)
    out = []
    for j in range(d):
        left = p[j - 1] if j > 0 else 0.0
        right = p[j + 1] if j + 1 < d else 0.0
        out.append(-(right - 2.0 * p[j] + left) / (tau * tau) + mu * p[j])
    return out


def lin_interp(q, u):
    """The linear interpolation of q at the fractional index u, and 0 outside [0, len(q) - 1]."""
    b = math.floor(u)
    w = u - b
    val = 0.0
    if 0 <= b < len(q):
        val += (1.0 - w) * q[b]
    if 0 <= b + 1 < len(q):
        val += w * q[b + 1]
    return val


def lambda_tomography(sino, tau, n, mu=0.0):
    """Lambda f + mu Lambda^(-1) f on an n x n grid from a parallel sinogram on [0, pi)."""
    a, d = len(sino), len(sino[0])  # @line L1
    qs = [lambda_filter(p, tau, mu) for p in sino]  # @line L2
    xs = [-1.0 + (2 * j + 1) / n for j in range(n)]
    ys = [1.0 - (2 * i + 1) / n for i in range(n)]
    c0 = (d - 1) / 2.0
    img = [[0.0] * n for _ in range(n)]
    for k, q in enumerate(qs):
        c, s = math.cos(k * math.pi / a), math.sin(k * math.pi / a)
        for i, y in enumerate(ys):  # @line L3
            row = img[i]
            for j, x in enumerate(xs):
                row[j] += lin_interp(q, (x * c + y * s) / tau + c0)  # @line L4
    w = 1.0 / (2.0 * a)  # (1 / (2 pi)) * (pi / a)
    return [[w * v for v in row] for row in img]  # @line L5


def lambda_at(sino, tau, x, y, mu=0.0):
    """The value of lambda_tomography at one point (x, y)."""
    a, d = len(sino), len(sino[0])
    c0 = (d - 1) / 2.0
    total = 0.0
    for k, p in enumerate(sino):
        q = lambda_filter(p, tau, mu)
        theta = k * math.pi / a
        total += lin_interp(q, (x * math.cos(theta) + y * math.sin(theta)) / tau + c0)
    return total / (2.0 * a)
test_lambda_tomography.py 104 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/lambda-tomography/. The authors are listed in prov/8VWFH5.jsonl.

import math
import random

from lambda_tomography import lambda_at, lambda_filter, lambda_tomography, lin_interp

A, D, N = 32, 65, 16
TAU = 2.0 * math.sqrt(2.0) / D
XS = [-1.0 + (2 * j + 1) / N for j in range(N)]
YS = [1.0 - (2 * i + 1) / N for i in range(N)]


def sinogram(fun, a=A, d=D, tau=TAU):
    return [[fun(k * math.pi / a, (j - (d - 1) / 2.0) * tau) for j in range(d)] for k in range(a)]


def gauss(theta, s):
    """R f for f(x) = exp(-4 pi |x|^2)."""
    return 0.5 * math.exp(-4.0 * math.pi * s * s)


def disk(theta, s, radius=0.5):
    return 2.0 * math.sqrt(radius * radius - s * s) if abs(s) < radius else 0.0


def lambda_gauss(x, y, m=400):
    """(1 / (2 pi)) integral_0^pi -p''(x . omega) dtheta for p(s) = exp(-4 pi s^2) / 2, by the midpoint rule."""
    total = 0.0
    for k in range(m):
        th = (k + 0.5) * math.pi / m
        s = x * math.cos(th) + y * math.sin(th)
        total += 0.5 * (8.0 * math.pi - 64.0 * math.pi ** 2 * s * s) * math.exp(-4.0 * math.pi * s * s)
    return total / (2.0 * m)


def test_filter_values() -> None:
    q = lambda_filter([0.0, 1.0, 4.0, 1.0], 0.5, mu=2.0)
    assert q == [-4.0 + 0.0, -(4.0 - 2.0) * 4.0 + 2.0, -(1.0 - 8.0 + 1.0) * 4.0 + 8.0, -(0.0 - 2.0 + 4.0) * 4.0 + 2.0]
    assert lin_interp([1.0, 3.0], 0.25) == 1.5 and lin_interp([1.0, 3.0], -1.0) == 0.0


def test_gaussian_matches_sqrt_minus_laplacian() -> None:
    sino = sinogram(gauss)
    # Lambda f(0) = integral 2 pi |xi| (1/4) exp(-pi |xi|^2 / 4) d xi = 2 pi
    assert abs(lambda_at(sino, TAU, 0.0, 0.0) - 2.0 * math.pi) < 0.15
    img = lambda_tomography(sino, TAU, N)
    for i in range(N):
        for j in range(N):
            assert abs(img[i][j] - lambda_gauss(XS[j], YS[i])) < 0.2


def test_disk_values() -> None:
    sino = sinogram(disk)
    # For the disk of radius R: Lambda f(0) = 1 / R, and it grows toward the edge and is negative outside.
    assert abs(lambda_at(sino, TAU, 0.0, 0.0) - 2.0) < 0.05
    want = 2.0 * sum((1.0 - 0.25 * math.cos((k + 0.5) * math.pi / 2000) ** 2) ** -1.5 for k in range(2000)) / 2000
    assert abs(lambda_at(sino, TAU, 0.25, 0.0) - want) < 0.1
    assert lambda_at(sino, TAU, 0.45, 0.0) > 4.0
    assert lambda_at(sino, TAU, 0.6, 0.0) < 0.0


def test_local_data_suffices() -> None:
    # Change the data far from the point: the value at the point does not change.
    rng = random.Random(7)
    sino = sinogram(gauss)
    x, y = 0.2, -0.1
    radius = math.hypot(x, y) + 2.0 * TAU
    changed = [
        [v if abs((j - (D - 1) / 2.0) * TAU) <= radius else v + rng.uniform(-5, 5) for j, v in enumerate(row)]
        for row in sino
    ]
    assert lambda_at(changed, TAU, x, y) == lambda_at(sino, TAU, x, y)
    # truncated data: zero outside |s| < 0.4
    cut = [[v if abs((j - (D - 1) / 2.0) * TAU) < 0.4 else 0.0 for j, v in enumerate(row)] for row in sino]
    assert abs(lambda_at(cut, TAU, 0.05, 0.05) - lambda_at(sino, TAU, 0.05, 0.05)) < 1e-12


def test_mu_term_adds_the_smooth_part() -> None:
    sino = sinogram(gauss)
    mu = 3.0
    with_mu = lambda_at(sino, TAU, 0.0, 0.0, mu)
    without = lambda_at(sino, TAU, 0.0, 0.0)
    # Lambda^(-1) f(0) = (1 / (2 pi)) integral_0^pi R f(theta, 0) dtheta = 1/4 for this Gaussian
    assert abs((with_mu - without) / mu - 0.25) < 1e-12
    # in general the mu term is mu / (2 a) times the plain back-projection of the data
    x, y = 0.3, 0.1
    plain = 0.0
    for k, row in enumerate(sino):
        th = k * math.pi / A
        plain += lin_interp(row, (x * math.cos(th) + y * math.sin(th)) / TAU + (D - 1) / 2.0)
    diff = lambda_at(sino, TAU, x, y, mu) - lambda_at(sino, TAU, x, y)
    assert abs(diff - mu * plain / (2.0 * A)) < 1e-12


def test_point_and_grid_agree() -> None:
    sino = sinogram(disk, a=8, d=33, tau=0.05)
    img = lambda_tomography(sino, 0.05, 4)
    xs = [-1.0 + (2 * j + 1) / 4 for j in range(4)]
    ys = [1.0 - (2 * i + 1) / 4 for i in range(4)]
    for i in range(4):
        for j in range(4):
            assert abs(img[i][j] - lambda_at(sino, 0.05, xs[j], ys[i])) < 1e-12

History

Faridani, Ritman and Smith published their paper Local Tomography in 1992. They based the method on the operator Λ\Lambda and on the fact that Λf\Lambda f has the same singularities as ff. Faridani, Finch, Ritman and Smith continued the work in Local Tomography II in 1997. The formula itself follows from the Fourier slice theorem in the same way as filtered back-projection.

References

  1. A. Faridani, E. L. Ritman and K. T. Smith, Local Tomography, SIAM Journal on Applied Mathematics 52(2), 1992, pp. 459 to 484
  2. A. Faridani, D. V. Finch, E. L. Ritman and K. T. Smith, Local Tomography II, SIAM Journal on Applied Mathematics 57(4), 1997, pp. 1095 to 1127

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • at least three sources
  • a scene preset for the example