Docsity

Carsten Hoilund Radon, Notas de estudo de Informática

Pré-visualização parcial do texto

Baixe Carsten Hoilund Radon e outras Notas de estudo em PDF para Informática, somente na Docsity!

The Radon Transform

Carsten Høilund

Aalborg University, VGIS, 07gr

November 12, 2007

Contents

  • 1 Introduction
  • 2 Theory
  • 3 Implementation
  • 4 Results
  • Bibliography

Chapter 2

Theory

This section is based on [2, 3].

Applying the Radon transform on an image f ( x , y ) for a given set of angles can be thought of as com-

puting the projection of the image along the given angles. The resulting projection is the sum of the

intensities of the pixels in each direction, i.e. a line integral. The result is a new image R (ρ, θ). This is

depicted in Figure 2.1 on the facing page.

This can be written mathematically by defining

ρ = x cos θ + y sin θ (2.1)

after which the Radon transform can be written as

R (ρ, θ) =

Z ∞

−∞

Z ∞

−∞

f ( x , y )δ(ρ − x cos θ − y sin θ) dx dy (2.2)

where δ(·) is the Dirac delta function.

There are two distinct Radon transforms. The source can either be a single point (not shown) or it can

be a array of sources (as shown in Figure 2.1 on the next page). The method discussed in this report

uses an array of sources. The theory is explained in Figures 2.1 on the facing page to 2.7 on page 8.

The Radon transform is a mapping from the Cartesian rectangular coordinates ( x , y ) to a distance and

an angel (ρ, θ), also known as polar coordinates.

An example of the transform of an image for a specific angle is given in Figure 2.4 on page 6 and

Figure 2.6 on page 7. The transform for a set of angels can be depicted in an image, as in Figure 2.7 on

page 8.

Figure 2.1: The source and sensor contrapment is rotated about the center of the

object. For each angle θ the density of the matter the rays from the source passes

through is accumulated at the sensor. This is repeated for a given set of angels,

usually from θ ∈ [0; 180). The angel 180 is not included since the result would be

identical to the angel 0.

Figure 2.2: For each angle θ and each distance ρ the intensity of the matter a ray

perpendicular to the ρ axis crosses are summed up at R (ρ, θ).

Figure 2.5: When θ = 64 o^ the line will be distributed over a very small interval.

ρ Cumulative intensity θ = 64o

Figure 2.6: The result of a Radon transform with θ = 64 o, perpendicular to the

line in the image. This results in a peak, which makes it possible to read the line

parameters.

R(ρ,θ) θ (degrees) ρ 20 40 60 80 100 120 140 160 180

Figure 2.7: The complete Radon transform of the image. The white spot is the

distance from the center and the angel at which the sum of intensities in the image

peaks. It is thus the slope of the line along with the position.

Figure 3.1: The pixel coordinates in an image is usually only positive. The first step

is therefore to center the image which can be accomplished by subtracting half the

width from each x coordinate and likewise half the height from each y coordinate.

Figure 3.2: The equation of the summation line is given as y = ax + b. As can

be seen by using trigonometry, the inclination is a = − cos sin ((θθ)) and the intersection

with the y axis is b = sin ρ(θ). This fits with Eq. (2.1) on page 4. These parameters

are determined for each combination of θ and ρ. The maximum ρ is set equal to

the length of the diagonal of the image. The ρ coordinates are, like x and y , also

centered.

Figure 3.3: In order to reduce the number of calculations necessary the maximum

and minimum of either x or y are determined.

Figure 3.4: Whether x or y is used as the variable and how the minimum and maxi-

mum of said variable is calculated depends on in which of the four areas depicted

θ is in since using e.g. x as the variably when the summation line has an absolute

inclination of more than 1 will cause some pixels to be skipped. Neither θ = 0

nor θ = 180 is included since the line perpendicular to this would have infinite

inclination.

Listing 3.1: Implementation

1 f u n c t i o n [ r e s ] = myradon ( f ) 2 3 [N M] = s i z e ( f ) ; 4 5 % C e n t e r o f t h e image 6 m = round (M/ 2 ) ; 7 n = round (N / 2 ) ; 8 9 % The t o t a l number o f rho ’ s i s t h e number o f p i x e l s on t h e d i a g o n a l , s i n c e 10 % t h i s i s t h e l a r g e s t s t r a i g h t l i n e on t h e image when r o t a t i n g 11 rhomax = c e i l ( s q r t (Mˆ 2 + Nˆ 2 ) ) ; 12 r c = round ( rhomax / 2 ) ; 13 mt = max ( t h e t a ) ; 14 15 % P r e a l l o c a t e t h e m a t r i x u s e d t o s t o r e t h e r e s u l t 16 % add 1 t o be s u r e , c o u l d a l s o be s u b t r a c t e d when c h e c k i n g bounds 17 r e s = c a s t ( z e r o s ( rhomax +1 , mt ) , ’ d o u b l e ’ ) ; 18 19 t i c 20 f o r t = 1 : 4 5 % below 45 d e g r e e s , u s e y a s v a r i a b l e 21 c o s t h e t a = c o s ( t ∗ p i / 1 8 0 ) ; 22 s i n t h e t a = s i n ( t ∗ p i / 1 8 0 ) ; 23 a = − c o s t h e t a / s i n t h e t a ; % y = ax + b 24 f o r r = 1 : rhomax 25 r h o = r − r c ; 26 b = r h o / s i n t h e t a ; % y = ax + b 27 ymax = min ( round (−a ∗m+b ) , n −1) ; 28 ymin = max ( round ( a ∗m+b ) ,−n ) ; 29 f o r y = ymin : ymax 30 x = ( y−b ) / a ; 31 x f l o o r = f l o o r ( x ) ; % The i n t e g e r p a r t o f x 32 xup = x − x f l o o r ; % The d e c i m a l s o f x 33 xlow = 1 − xup ; % What i t s a y s 34 x = x f l o o r ; 35 x = max ( x ,−m) ; 36 x = min ( x , m−2) ; 37 r e s ( rhomax − r + 1 , mt−t ) = r e s ( rhomax − r + 1 , mt−t ) + xlow ∗ f ( y+n +1 , x+mց +1) ; 38 r e s ( rhomax − r + 1 , mt−t ) = r e s ( rhomax − r + 1 , mt−t ) + xup ∗ f ( y+n +1 , x+m+2)ց ; 39 end 40 end 41 end 42 f o r t = 4 6 : 9 0 43 c o s t h e t a = c o s ( t ∗ p i / 1 8 0 ) ; 44 s i n t h e t a = s i n ( t ∗ p i / 1 8 0 ) ; 45 a = − c o s t h e t a / s i n t h e t a ; % y = ax + b 46 f o r r = 1 : rhomax

47 r h o = r − r c ; 48 b = r h o / s i n t h e t a ; % y = ax + b 49 xmax = min ( round (( − n−b ) / a ) ,m−1) ; 50 xmin = max ( round ( ( n−b ) / a ) ,−m) ; 51 f o r x = xmin : xmax 52 y = a ∗x+b ; 53 y f l o o r = f l o o r ( y ) ; 54 yup = y − y f l o o r ; 55 ylow = 1 − yup ; 56 y = y f l o o r ; 57 y = max ( y ,−n ) ; 58 y = min ( y , n −2) ; 59 r e s ( rhomax − r + 1 , mt−t ) = r e s ( rhomax − r + 1 , mt−t ) + ylow ∗ f ( y+n +1 , x+mց +1) ; 60 r e s ( rhomax − r + 1 , mt−t ) = r e s ( rhomax − r + 1 , mt−t ) + yup ∗ f ( y+n +2 , x+m+1)ց ; 61 end 62 end 63 end 64 f o r t = 9 1 : 1 3 5 65 c o s t h e t a = c o s ( t ∗ p i / 1 8 0 ) ; 66 s i n t h e t a = s i n ( t ∗ p i / 1 8 0 ) ; 67 a = − c o s t h e t a / s i n t h e t a ; % y = ax + b 68 f o r r = 1 : rhomax 69 r h o = r − r c ; 70 b = r h o / s i n t h e t a ; % y = ax + b 71 xmax = min ( round ( ( n−b ) / a ) ,m−1) ; 72 xmin = max ( round (( − n−b ) / a ) ,−m) ; 73 f o r x = xmin : xmax 74 y = a ∗x+b ; 75 y f l o o r = f l o o r ( y ) ; 76 yup = y − y f l o o r ; 77 ylow = 1 − yup ; 78 y = y f l o o r ; 79 y = max ( y ,−n ) ; 80 y = min ( y , n −2) ; 81 r e s ( rhomax − r + 1 , mt−t ) = r e s ( rhomax − r + 1 , mt−t ) + ylow ∗ f ( y+n +1 , x+mց +1) ; 82 r e s ( rhomax − r + 1 , mt−t ) = r e s ( rhomax − r + 1 , mt−t ) + yup ∗ f ( y+n +2 , x+m+1)ց ; 83 end 84 end 85 end 86 f o r t = 1 3 6 : 1 7 9 % above 135 d e g r e e s , u s e y a s v a r i a b l e 87 c o s t h e t a = c o s ( t ∗ p i / 1 8 0 ) ; 88 s i n t h e t a = s i n ( t ∗ p i / 1 8 0 ) ; 89 a = − c o s t h e t a / s i n t h e t a ; % y = ax + b 90 f o r r = 1 : rhomax 91 r h o = r − r c ;

Chapter 4

Results

The results obtained with the algorithm as described here differs from the built-in MATLAB Radon

function. Using Figure 4.1 as the input image Figure 4.2 on the facing page shows the result of the

algorithm as described in this report and Figure 4.3 on the next page depicts the result from the built-in

MATLAB Radon transform.

Figure 4.1: The input image. Notice the two lines faintly visible.

θ (degrees) ρ R(ρ,θ) 20 40 60 80 100 120 140 160 180

x 10^4

Figure 4.2: The result obtained with the implementation given herein. The two

small, bright spots are the lines visible in the input image.

R(ρ,θ) θ (degrees) ρ 20 40 60 80 100 120 140 160 180

x 10^4

Figure 4.3: The result obtained using the built-in MATLAB Radon transform. The

two lines are also visible here, but competes with the general accumulation of pixel

intensities at θ = 45 o^ and θ = 135 o.

θ (degrees) ρ R(ρ,θ) 20 40 60 80 100 120 140 160 180

x 10^4

Figure 4.5: Result obtained with the implementation from this report. The fat line

is the largest, bright spot and the thin line is the small, bright spot. The curves not

meeting to form a bright spot is the wavy line.

R(ρ,θ) θ (degrees) ρ 20 40 60 80 100 120 140 160 180

x 10^4

Figure 4.6: Result obtained with the implementation from MATLAB. This is nearly

identical to Figure 4.5. The difference is presumably due to using a different inter-

polation.

Bibliography

[1] Muffet. CAT scanner for simulation. http://flickr.com/photos/calliope/357130113/.

[2] The MathWorks. Radon Transform. http://www.mathworks.com/access/helpdesk r13/help/toolbox/images/transfo9.html.

[3] Peter Toft. The Radon Transform. http://eivind.imm.dtu.dk/staff/ptoft/Radon/Radon.html.

[4] Wikipedia. Johann Radon. http://en.wikipedia.org/wiki/Johann Radon.