Skip to content

Commit

Permalink
Added option in field of view for displaced detectors (proposed by Uf…
Browse files Browse the repository at this point in the history
…fe Bernchou)
  • Loading branch information
Simon Rit committed Oct 23, 2013
1 parent 3da3c37 commit ae71a4b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
1 change: 1 addition & 0 deletions applications/rtkfieldofview/rtkfieldofview.ggo
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ option "reconstruction" - "Reconstruction file unmasked"
option "path" p "Path where there are the projections" string yes
option "regexp" r "Regular expression to select projection files in path" string yes
option "mask" m "Output a binary mask instead of a masked image" flag off
option "displaced" d "Assume that a displaced detector has been used" flag off

6 changes: 6 additions & 0 deletions code/rtkFieldOfViewImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class ITK_EXPORT FieldOfViewImageFilter:
itkGetMacro(ProjectionsStack, ProjectionsStackPointer);
itkSetMacro(ProjectionsStack, ProjectionsStackPointer);

/** Assume that a displaced detector image filter, e.g.,
* rtk::DisplacedDetectorImageFilter, has been used. */
itkGetMacro(DisplacedDetector, bool);
itkSetMacro(DisplacedDetector, bool);

protected:
FieldOfViewImageFilter();
virtual ~FieldOfViewImageFilter() {};
Expand All @@ -103,6 +108,7 @@ class ITK_EXPORT FieldOfViewImageFilter:
double m_HatTangentSup;
double m_HatHeightInf;
double m_HatHeightSup;
bool m_DisplacedDetector;
};

} // end namespace rtk
Expand Down
19 changes: 16 additions & 3 deletions code/rtkFieldOfViewImageFilter.txx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ template<class TInputImage, class TOutputImage>
FieldOfViewImageFilter<TInputImage, TOutputImage>
::FieldOfViewImageFilter():
m_Geometry(NULL),
m_Mask(false)
m_Mask(false),
m_DisplacedDetector(false)
{
}

Expand Down Expand Up @@ -75,8 +76,20 @@ void FieldOfViewImageFilter<TInputImage, TOutputImage>

const double projOffsetX = m_Geometry->GetProjectionOffsetsX()[k];
const double sourceOffsetX = m_Geometry->GetSourceOffsetsX()[k];
m_Radius = std::min( m_Radius, vcl_abs( sourceOffsetX+mag*(corner1[0]+projOffsetX-sourceOffsetX) ) );
m_Radius = std::min( m_Radius, vcl_abs( sourceOffsetX+mag*(corner2[0]+projOffsetX-sourceOffsetX) ) );
const double r1 = vcl_abs( sourceOffsetX+mag*(corner1[0]+projOffsetX-sourceOffsetX) );
const double r2 = vcl_abs( sourceOffsetX+mag*(corner2[0]+projOffsetX-sourceOffsetX) );
if(m_DisplacedDetector)
{
// The largest of the two radii counts (the short one is assumed to be
// compensated for by the displaced detector filter)
m_Radius = std::min( m_Radius, std::max(r1, r2) );
}
else
{
// The minimum of two radii counts in the general case
m_Radius = std::min( m_Radius, r1 );
m_Radius = std::min( m_Radius, r2 );
}

const double projOffsetY = m_Geometry->GetProjectionOffsetsY()[k];
const double sourceOffsetY = m_Geometry->GetSourceOffsetsY()[k];
Expand Down
16 changes: 16 additions & 0 deletions testing/rtkfovtest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ int main(int , char** )
projectionsSource->SetSize( size );
projectionsSource->SetConstant( 1. );

std::cout << "\n\n****** Case 1: centered detector ******" << std::endl;

// Geometry
typedef rtk::ThreeDCircularProjectionGeometry GeometryType;
GeometryType::Pointer geometry = GeometryType::New();
Expand Down Expand Up @@ -183,6 +185,20 @@ int main(int , char** )
threshold->SetInsideValue(1.);
TRY_AND_EXIT_ON_ITK_EXCEPTION( threshold->Update() );

CheckImageQuality<OutputImageType>(fov->GetOutput(), threshold->GetOutput());
std::cout << "\n\nTest PASSED! " << std::endl;

std::cout << "\n\n****** Case 2: offset detector ******" << std::endl;

origin[0] = -54.;
projectionsSource->SetOrigin( origin );
size[0] = 78;
projectionsSource->SetSize( size );
projectionsSource->UpdateOutputInformation();
projectionsSource->UpdateLargestPossibleRegion();
fov->SetDisplacedDetector(true);
fov->Update();

CheckImageQuality<OutputImageType>(fov->GetOutput(), threshold->GetOutput());
std::cout << "\n\nTest PASSED! " << std::endl;

Expand Down

0 comments on commit ae71a4b

Please sign in to comment.