Unknownpgr

CT Reconstruction

2023-07-28 14:42:11 | English, Korean

This post was translated from Korean into English by AI.

Today, I suddenly became curious about how CT images are reconstructed. So I came up with a simple hypothesis about CT image reconstruction and tested it myself.

Hypothesis

I know the following facts about CT.

From these facts, we can make the following additional inferences.

Modeling

Based on this, I first modeled X-ray attenuation in a homogeneous object as follows.

I=I0eμxI = I_0 e^{-\mu x}

Here, I0I_0 is the intensity of the light before it passes through the object, II is its intensity after it passes through the object, μ\mu is the object's attenuation coefficient, and xx is the thickness of the object.

For convenience, if we set I0I_0 to 1, the equation can be rewritten as follows.

I=eμxI = e^{-\mu x}

From this, as an X-ray passes through an object,

then the intensity II of the light after it passes through the object can be expressed as follows.

I=eμ0Δx0eμ1Δx1eμ2Δx2...=ei=0nμiΔxiI = e^{-\mu_0 \Delta x_0} e^{-\mu_1 \Delta x_1} e^{-\mu_2 \Delta x_2} ... \\ = e^{-\sum_{i=0}^n \mu_i \Delta x_i}

Because this is difficult to calculate, we can take the logarithm of both sides and rewrite it as follows.

lnI=_i=0nμiΔxi\ln I =- \sum\_{i=0}^n \mu_i \Delta x_i

Here, nn and μi\mu_i have different values for each ray, so multiple rays cannot be represented in a single matrix. To solve this problem, we use the following method.

The equation above can then be expressed in the following form.

lnIi=j=0nμjWi,j\ln I*i = - \sum*{j=0}^n \mu*j W*{i,j}

This can be expressed as a matrix operation as follows.

lnI=Wμ\ln I = -W\mu

Here, μ\mu is a vector whose elements are the attenuation coefficients of the infinitesimal cross-sectional areas, and WW is the selection matrix. II is a vector whose elements are the measured light intensities of the respective rays.

If the number of infinitesimal areas into which the cross-section is divided is n and the number of rays is m, the matrices have the following dimensions.

μ=(n,1)W=(m,n)I=(m,1)\mu = (n, 1) \\ W = (m, n) \\ I = (m, 1)

In general, nmn \neq m, so WW is not a square matrix. Therefore, this matrix operation does not have an exact solution, and the solution must be found using the pseudo-inverse. It can then be expressed in the following form.

μ=W+lnI\mu = -W^+ \ln I

For convenience, if we let D=lnID = -\ln I,

W+D=μ(W+=(WTW)1WT)W^+ D= \mu\\(W^+ = (W^T W)^{-1} W^T)

Implementation

The code was implemented using Python, NumPy, and OpenCV, and is available in the repository below.

https://github.com/unknownpgr/ct-reconstruction

Result

We can see that the resulting image is very similar to the original.

Discussion

The most time-consuming task in the process above is finding the pseudo-inverse. The computational time complexity of the pseudo-inverse operation is O(m2n)O(m^2n) (where mm is the number of rays and nn is the number of infinitesimal areas), and the WW matrix is extremely large, with dimensions of approximately (23000,4096)(23000, 4096). However, once the ray emission pattern has been determined, the WW matrix does not change. Therefore, by deciding on the ray emission pattern in advance and precomputing the WW matrix and its pseudo-inverse, it should be possible to save a great deal of time later.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -