CTrec Class Reference
[CT and TS reconstruction.]

CT reconstruction class. More...

#include <kernel.h>

List of all members.

Public Member Functions

 CTrec (int px, Contrast cn, int tr=0, const Filter &ft=Filter())
 Constructor.
 CTrec (int px, Contrast cn, const Filter &ft)
 Constructor.
 ~CTrec ()
 Destructor.
int pixels () const
 Width of the reconstructed image.
void contrast (Contrast cn)
 Changes type of the contrast.
Contrast contrast () const
 Type of the contrast.
void threads (int tr)
 Changes number of threads.
int threads () const
 Number of threads.
void filter (const Filter &ft)
 Changes type of the filter function.
Filter filter () const
 Type of the filter function.
void reconstruct (Map &sinogram, Map &result, const float center) const
 Actual reconstruction of a single sinogram.
void addLine (Line &sinoline, Map &result, const float Theta, const float center) const
 Adding one sinogram line to the reconstruction.

Static Public Member Functions

static void finilize (Map &result, int thetas, float pixelSize=1.0)
 Finalize the calculations.

Private Member Functions

void pixels (int px)
 Pixels.
void reconstruct_uni (Map &sinogram, Map &result, float center) const
 Core reconstruction (currently universal for all types of contrast).
void reconstruct_abs (Map &sinogram, Map &result, float center) const
 Core reconstruction: absorption.
void reconstruct_abs_thr (Map &sinogram, Map &result, float center) const
 Core reconstruction: absorption, parallel approach.
void reconstruct_ref (Map &sinogram, Map &result, float center) const
 Core reconstruction: refraction.
void reconstruct_ref_thr (Map &sinogram, Map &result, float center) const
 Core reconstruction: refraction, parallel approach.
void addLine_ref (Line &sinoline, Map &result, const float Theta, const float center) const
 Core addLine: refraction.
void addLine_abs (Line &sinoline, Map &result, const float Theta, const float center) const
 Core addLine: absorption.
void addLine_uni (Line &sinoline, Map &result, const float Theta, const float center) const
 Core function to add a projection line into the reconstruction.
void choose_algorithm ()
 Sets _reconstruct.

Private Attributes

int _pixels
 Width of the reconstructed image.
Contrast _contrast
 Type of the contrast.
int _threads
 Number of threads.
Filter _filter
 Type of the filter function.
Line filt_window
 The array containing the filter window.
fftwf_plan planF
 Forward FFT transformation.
fftwf_plan planB
 Backward FFT transformation.
void(CTrec::* _reconstruct )(Map &, Map &, float) const
 Actual reconstruction function.
void(CTrec::* _addLine )(Line &, Map &, const float, const float) const
 Actual function which adds the sinogram line to the result.

Static Private Attributes

static const std::string modname = "reconstruction"
 Module name.
static const float zPad = 2.0
 Zero-padding coefficient.

Detailed Description

CT reconstruction class.

This class first collects all information needed for the CT reconstruction (size, contrast type, filter, etc.) and then performs the reconstruction using either CTrec::reconstruct or CTrec::addLine methods I designed the CT as the class not as a function in order to provide easy way to plug in any new contrast and/or algorithm (f.e. GPU-, FPGA-, bla-bla-bla-based).

In order to include new reconstruction algorithm you should follow these steps:

  1. Add the method which implements you algorithm. See CTrec::reconstruct_abs() and other CTrec::reconstruct_* methods for example (currently all of them just call the universal reconstruction CTrec::reconstruct_uni(), they are added into the class just for the architecture's flexibility).
  2. Set the CTrec::_reconstruct and CTrec::_addLine pointers to your method from the previous step. Please do it ONLY within CTrec::choose_algorithm(). The choice of the pointer may depend on any condition you can imagine and any parameter(s) you have added in the first step.
  3. If needed, add new member(s) into the class which are required for the algorithm (see CTrec::_filter for example). For these new member(s) create set/get methods (see CTrec::filter() and CTrec::filter(const Filter &) for example).
  4. If it is needed, add the new constructor, or update existing one.

Voala: you can initialize the reconstruction and reconstruct your sinogram using CTrec::reconstruct() method (f.e. see ct.cpp ).

Definition at line 213 of file kernel.h.


Constructor & Destructor Documentation

CTrec::CTrec ( int  px,
Contrast  cn,
int  tr = 0,
const Filter ft = Filter() 
)

Constructor.

Parameters:
px Width of the reconstructed image.
cn Type of the contrast.
tr Number of threads.
ft Type of the filter function.

Definition at line 738 of file kernel.cpp.

References _contrast, _filter, _pixels, _threads, choose_algorithm(), contrast(), filter(), pixels(), and threads().

CTrec::CTrec ( int  px,
Contrast  cn,
const Filter ft 
)

Constructor.

Parameters:
px Width of the reconstructed image.
cn Type of the contrast.
ft Type of the filter function.

Definition at line 753 of file kernel.cpp.

References _contrast, _filter, _pixels, _threads, choose_algorithm(), contrast(), filter(), pixels(), and threads().

CTrec::~CTrec (  ) 

Destructor.

Definition at line 690 of file kernel.cpp.

References planB, and planF.


Member Function Documentation

void CTrec::addLine ( Line sinoline,
Map result,
const float  Theta,
const float  center 
) const

Adding one sinogram line to the reconstruction.

Add one line to the reconstruction.

Parameters:
Theta Projection angle.
sinoline Projection data.
result Output result.
center Deviation of the rotation center.

Definition at line 658 of file kernel.cpp.

References _addLine, _contrast, _pixels, Contrast::ABS, modname, n2s(), throw_error(), and unzero().

Referenced by main().

void CTrec::addLine_abs ( Line sinoline,
Map result,
const float  Theta,
const float  center 
) const [private]

Core addLine: absorption.

Parameters:
sinoline Projection data.
result Output result.
Theta Projection angle.
center Deviation of the rotation center.

Definition at line 909 of file kernel.cpp.

References addLine_uni().

Referenced by choose_algorithm().

void CTrec::addLine_ref ( Line sinoline,
Map result,
const float  Theta,
const float  center 
) const [private]

Core addLine: refraction.

Parameters:
sinoline Projection data.
result Output result.
Theta Projection angle.
center Deviation of the rotation center.

Definition at line 921 of file kernel.cpp.

References addLine_uni().

Referenced by choose_algorithm().

void CTrec::addLine_uni ( Line sinoline,
Map result,
const float  Theta,
const float  center 
) const [private]

Core function to add a projection line into the reconstruction.

Parameters:
Theta Projection angle.
sinoline Projection data.
result Output result.
center Deviation of the rotation center.

Definition at line 594 of file kernel.cpp.

References _contrast, _pixels, Contrast::ABS, filt_window, filter_line(), planB, planF, project_line(), Contrast::REF, and zPad.

Referenced by addLine_abs(), addLine_ref(), and choose_algorithm().

void CTrec::choose_algorithm (  )  [private]

Sets _reconstruct.

Assigns one of the algorithms to the CTrec::_reconstruct pointer.

The assignment is done on the basis of the pre-defined members of the class. This method should be called whenever any algoritm-defining parameter is altered.

Definition at line 824 of file kernel.cpp.

References _addLine, _contrast, _reconstruct, _threads, Contrast::ABS, addLine_abs(), addLine_ref(), addLine_uni(), Contrast::contrast(), modname, Contrast::name(), Contrast::PHS, reconstruct_abs(), reconstruct_abs_thr(), reconstruct_ref(), reconstruct_ref_thr(), reconstruct_uni(), Contrast::REF, and warn().

Referenced by contrast(), CTrec(), and threads().

Contrast CTrec::contrast (  )  const

Type of the contrast.

Returns:
Type of the contrast.

Definition at line 709 of file kernel.cpp.

References _contrast.

Referenced by CTrec().

void CTrec::contrast ( Contrast  cn  ) 

Changes type of the contrast.

Parameters:
cn New contrast type.

Definition at line 788 of file kernel.cpp.

References _contrast, and choose_algorithm().

Filter CTrec::filter (  )  const

Type of the filter function.

Returns:
Type of the filter function.

Definition at line 727 of file kernel.cpp.

References _filter.

Referenced by CTrec(), and pixels().

void CTrec::filter ( const Filter ft  ) 

Changes type of the filter function.

Parameters:
ft New type of the filter function.

Definition at line 798 of file kernel.cpp.

References _contrast, _filter, _pixels, Filter::fill(), filt_window, Contrast::REF, and zPad.

void CTrec::finilize ( Map result,
int  thetas,
float  pixelSize = 1.0 
) [static]

Finalize the calculations.

The result of the reconstruction procedure is not normalized to represent the real physical values because the CT algorithm, for the simplicity does not know all parameters needed. This function will do the normalization of the result array. If the array was reconstructed using the CTrec::reconstruct() or CTrec::addLine() methods, with the correct physical values on input, after the normalization it will represent correct values of: $\mu$ - for the Contrast::ABS $\delta$ - for the Contrast::PHS and Contrast::REF.

Parameters:
result The array to be normalized
thetas Number of projections used in the CT reconstruction.
pixelSize Physical size of the pixel

Definition at line 926 of file kernel.cpp.

Referenced by main().

int CTrec::pixels (  )  const

Width of the reconstructed image.

Returns:
Width of the reconstructed image.

Definition at line 700 of file kernel.cpp.

References _pixels.

Referenced by CTrec().

void CTrec::pixels ( int  px  )  [private]

Pixels.

Sets _pixels, allocates FFT plans.

I made this method private because will have to reallocate FFT plans, resize and refill the filter window, etc. If you want to reconstruct with different width, you'd better create new CTrec object for this. May be I will change this behaviour in the future

Parameters:
px Width of the sinograms to be reconstructed

Definition at line 773 of file kernel.cpp.

References _filter, _pixels, filter(), modname, n2s(), planB, planF, throw_error(), and zPad.

void CTrec::reconstruct ( Map sinogram,
Map result,
const float  center 
) const

Actual reconstruction of a single sinogram.

Actual reconstruction.

Parameters:
sinogram Input sinogram. Can be altered by the reconstruction process.
result Output result.
center Deviation of the rotation center.

Definition at line 623 of file kernel.cpp.

References _contrast, _pixels, _reconstruct, Contrast::ABS, modname, n2s(), throw_error(), and unzero().

Referenced by main().

void CTrec::reconstruct_abs ( Map sinogram,
Map result,
float  center 
) const [private]

Core reconstruction: absorption.

Parameters:
sinogram Input sinogram. After the reconstruction represents filtered sinogram.
result Reconstructed result.
center Rotation center.

Definition at line 859 of file kernel.cpp.

References reconstruct_uni().

Referenced by choose_algorithm().

void CTrec::reconstruct_abs_thr ( Map sinogram,
Map result,
float  center 
) const [private]

Core reconstruction: absorption, parallel approach.

Parameters:
sinogram Input sinogram. After the reconstruction represents filtered sinogram.
result Reconstructed result.
center Rotation center.

Definition at line 883 of file kernel.cpp.

References reconstruct_uni().

Referenced by choose_algorithm().

void CTrec::reconstruct_ref ( Map sinogram,
Map result,
float  center 
) const [private]

Core reconstruction: refraction.

Parameters:
sinogram Input sinogram. After the reconstruction represents filtered sinogram.
result Reconstructed result.
center Rotation center.

Definition at line 871 of file kernel.cpp.

References reconstruct_uni().

Referenced by choose_algorithm().

void CTrec::reconstruct_ref_thr ( Map sinogram,
Map result,
float  center 
) const [private]

Core reconstruction: refraction, parallel approach.

Parameters:
sinogram Input sinogram. After the reconstruction represents filtered sinogram.
result Reconstructed result.
center Rotation center.

Definition at line 896 of file kernel.cpp.

References reconstruct_uni().

Referenced by choose_algorithm().

void CTrec::reconstruct_uni ( Map sinogram,
Map result,
float  center 
) const [private]

Core reconstruction (currently universal for all types of contrast).

Other reconstruction functions ( CTrec::reconstruct_*() ) are in their place to allow possible future branching of the reconstruction methods/algorithms. Currently all of them just call this universal reconstruction function

Parameters:
sinogram Input sinogram. After the reconstruction represents filtered sinogram.
result Reconstructed result.
center Rotation center.

Definition at line 559 of file kernel.cpp.

References _contrast, _pixels, _threads, Contrast::ABS, filt_window, filter_line(), planB, planF, project_sino(), Contrast::REF, and zPad.

Referenced by choose_algorithm(), reconstruct_abs(), reconstruct_abs_thr(), reconstruct_ref(), and reconstruct_ref_thr().

int CTrec::threads (  )  const

Number of threads.

Returns:
Number of threads.

Definition at line 718 of file kernel.cpp.

References _threads.

Referenced by CTrec().

void CTrec::threads ( int  tr = 1  ) 

Changes number of threads.

Parameters:
tr New number of threads.

Definition at line 811 of file kernel.cpp.

References _threads, choose_algorithm(), and nof_threads().


Member Data Documentation

void(CTrec::* CTrec::_addLine)(Line &, Map &, const float, const float) const [private]

Actual function which adds the sinogram line to the result.

Pointer to one of the addLine functions (see above) which would be used in the reconstruction algorithm.

Definition at line 254 of file kernel.h.

Referenced by addLine(), and choose_algorithm().

Type of the contrast.

Definition at line 222 of file kernel.h.

Referenced by addLine(), addLine_uni(), choose_algorithm(), contrast(), CTrec(), filter(), reconstruct(), and reconstruct_uni().

Type of the filter function.

Definition at line 224 of file kernel.h.

Referenced by CTrec(), filter(), and pixels().

int CTrec::_pixels [private]

Width of the reconstructed image.

Definition at line 221 of file kernel.h.

Referenced by addLine(), addLine_uni(), CTrec(), filter(), pixels(), reconstruct(), and reconstruct_uni().

void(CTrec::* CTrec::_reconstruct)(Map &, Map &, float) const [private]

Actual reconstruction function.

Pointer to one of the reconstruction functions (see above) which would be used in the reconstruction algorithm.

Definition at line 248 of file kernel.h.

Referenced by choose_algorithm(), and reconstruct().

int CTrec::_threads [private]

Number of threads.

Definition at line 223 of file kernel.h.

Referenced by choose_algorithm(), CTrec(), reconstruct_uni(), and threads().

The array containing the filter window.

Definition at line 229 of file kernel.h.

Referenced by addLine_uni(), filter(), and reconstruct_uni().

const string CTrec::modname = "reconstruction" [static, private]

Module name.

Definition at line 217 of file kernel.h.

Referenced by addLine(), choose_algorithm(), pixels(), and reconstruct().

fftwf_plan CTrec::planB [private]

Backward FFT transformation.

Definition at line 231 of file kernel.h.

Referenced by addLine_uni(), pixels(), reconstruct_uni(), and ~CTrec().

fftwf_plan CTrec::planF [private]

Forward FFT transformation.

Definition at line 230 of file kernel.h.

Referenced by addLine_uni(), pixels(), reconstruct_uni(), and ~CTrec().

const float CTrec::zPad = 2.0 [static, private]

Zero-padding coefficient.

The filtering is performed in the domain this times wider than the number of pixels (CTrec::_pixels). Must be >= 1.

Definition at line 218 of file kernel.h.

Referenced by addLine_uni(), filter(), pixels(), and reconstruct_uni().


The documentation for this class was generated from the following files:
Generated on Thu Jul 29 15:34:27 2010 for ctas by  doxygen 1.6.3