Note
For information about creating projection data from line integrals
along paths that radiate from a single source, called fan-beam projections,
see Fan-Beam Projection Data. To convert parallel-beam projection
data to fan-beam projection data, use the |
The radon
function computes projections of
an image matrix along specified directions.
A projection of a two-dimensional function f(x,y) is
a set of line integrals. The radon
function computes
the line integrals from multiple sources along parallel paths, or beams,
in a certain direction. The beams are spaced 1 pixel unit apart. To
represent an image, the radon
function takes multiple,
parallel-beam projections of the image from different angles by rotating
the source around the center of the image. The following figure shows
a single projection at a specified rotation angle.
Parallel-Beam Projection at Rotation Angle Theta
For example, the line integral of f(x,y) in the vertical direction is the projection of f(x,y) onto the x-axis; the line integral in the horizontal direction is the projection of f(x,y) onto the y-axis. The following figure shows horizontal and vertical projections for a simple two-dimensional function.
Horizontal and Vertical Projections of a Simple Function
Projections can be computed along any angle [[THETA]]. In general, the Radon transform of f(x,y) is the line integral of f parallel to the y´-axis
$${R}_{\theta}\left(x\prime \right)={\displaystyle {\int}_{-\infty}^{\infty}f\left(x\prime \mathrm{cos}\theta -y\prime \mathrm{sin}\theta ,x\prime \mathrm{sin}\theta +y\prime \mathrm{cos}\theta \right)dy\prime}$$
where
$$\left[\begin{array}{c}x\prime \\ y\prime \end{array}\right]=\left[\begin{array}{cc}\text{}\mathrm{cos}\theta & \text{sin}\theta \\ -\mathrm{sin}\theta & \text{cos}\theta \end{array}\right]\left[\begin{array}{c}x\\ y\end{array}\right]$$
The following figure illustrates the geometry of the Radon transform.
Geometry of the Radon Transform
You can compute the Radon transform of an image I
for
the angles specified in the vector theta
using
the radon
function with this syntax.
[R,xp] = radon(I,theta);
The columns of R
contain the Radon transform
for each angle in theta
. The vector xp
contains
the corresponding coordinates along the x′-axis.
The center pixel of I
is defined to be floor((size(I)+1)/2)
;
this is the pixel on the x′-axis
corresponding
to $$x\prime =0$$.
The commands below compute and plot the Radon transform at 0°
and 45° of an image containing a single square object. xp
is
the same for all projection angles.
I = zeros(100,100);
I(25:75, 25:75) = 1;
imshow(I)
[R,xp] = radon(I,[0 45]);
figure; plot(xp,R(:,1)); title('R_{0^o} (x\prime)')
Radon Transform of a Square Function at 0 Degrees
figure; plot(xp,R(:,2)); title('R_{45^o} (x\prime)')
Radon Transform of a Square Function at 45 Degrees
The Radon transform for a large number of angles is often displayed as an image. In this example, the Radon transform for the square image is computed at angles from 0° to 180°, in 1° increments.
theta = 0:180; [R,xp] = radon(I,theta); imagesc(theta,xp,R); title('R_{\theta} (X\prime)'); xlabel('\theta (degrees)'); ylabel('X\prime'); set(gca,'XTick',0:20:180); colormap(hot); colorbar
Radon Transform Using 180 Projections
The Radon transform is closely related to a common computer
vision operation known as the Hough transform. You can use the radon
function
to implement a form of the Hough transform used to detect straight
lines. The steps are
Compute a binary edge image using the edge
function.
I = fitsread('solarspectra.fts'); I = mat2gray(I); BW = edge(I); imshow(I), figure, imshow(BW)
Compute the Radon transform of the edge image.
theta = 0:179; [R,xp] = radon(BW,theta); figure, imagesc(theta, xp, R); colormap(hot); xlabel('\theta (degrees)'); ylabel('x\prime'); title('R_{\theta} (x\prime)'); colorbar
Radon Transform of an Edge Image
Find the locations of strong peaks in the Radon transform matrix. The locations of these peaks correspond to the locations of straight lines in the original image.
In the following figure, the strongest peaks in R
correspond
to $$\theta ={1}^{\circ}$$ and $$x\prime =-80$$. The line perpendicular to that
angle and located at $$x\prime =-80$$ is shown below,
superimposed in red on the original image. The Radon transform geometry
is shown in black. Notice that the other strong lines parallel to
the red line also appear as peaks at $$\theta ={1}^{\circ}$$ in
the transform. Also, the lines perpendicular to this line appear as
peaks at $$\theta ={91}^{\circ}$$.
Radon Transform Geometry and the Strongest Peak (Red)