From: Simon Rit Date: Mon, 30 May 2011 17:18:28 +0000 (+0200) Subject: Merge branch 'master' of /home/dsarrut/clitk3.server X-Git-Tag: v1.3.0~321^2~3^2~8^2 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e168843d038efea6d865549cd5aef6901643dbf8;hp=d6a1ee2d530580d2499ad41d007da37cd1f3c676;p=clitk.git Merge branch 'master' of /home/dsarrut/clitk3.server --- diff --git a/itk/clitkBackProjectImageFilter.h b/itk/clitkBackProjectImageFilter.h index ebaeffc..7de71a1 100644 --- a/itk/clitkBackProjectImageFilter.h +++ b/itk/clitkBackProjectImageFilter.h @@ -148,6 +148,11 @@ namespace clitk } } + void SetPanelShift(double x, double y) + { + m_PanelShift[0] = x; + m_PanelShift[1] = y; + } // itkSetMacro(IsoCenter, OutputPointType); // itkGetConstReferenceMacro(IsoCenter, OutputPointType) // itkSetMacro( SourceToScreen, double ); @@ -258,6 +263,7 @@ namespace clitk double m_SourceToAxis; OutputPixelType m_EdgePaddingValue; double m_ProjectionAngle; + double m_PanelShift[2]; // Output image info OutputSizeType m_OutputSize; // Size of the output image diff --git a/itk/clitkBackProjectImageFilter.txx b/itk/clitkBackProjectImageFilter.txx index 65ac801..befc882 100644 --- a/itk/clitkBackProjectImageFilter.txx +++ b/itk/clitkBackProjectImageFilter.txx @@ -20,6 +20,7 @@ #include "clitkBackProjectImageFilter.h" #include "itkContinuousIndex.h" #include "vnl/vnl_math.h" +#include "itkLinearInterpolateImageFunction.h" namespace clitk { @@ -39,6 +40,8 @@ namespace clitk this->m_SourceToAxis = 1000.0; this->m_EdgePaddingValue = itk::NumericTraits::Zero;//density images this->m_RigidTransformMatrix.SetIdentity(); + this->m_PanelShift[0] = 0.; + this->m_PanelShift[1] = 0.; //Parameters for output this->m_OutputSpacing.Fill(1); @@ -304,8 +307,6 @@ namespace clitk { //Projection pointer InputImageConstPointer inputPtr=this->GetInput(); - InputPixelType * beginPtr=const_cast(this->GetInput()->GetBufferPointer()); - InputPixelType * pp; //Volume pointer OutputImagePointer outputPTr= this->GetOutput(); @@ -325,8 +326,6 @@ namespace clitk OutputIndexType oIndex; ContinuousInputIndexType iIndex; InputSizeType inputSize=inputPtr->GetLargestPossibleRegion().GetSize(); - double dx,dy,dxm,dym; - int lx, ly; //Get the first output coordinate oIndex=iterator.GetIndex();//costly but only once a thread @@ -337,9 +336,13 @@ namespace clitk //Compute the first input coordinate (invert Y/X) homInputPoint= (m_ProjectionMatrix * homOutputPoint); - iPoint[0]=-homInputPoint[0]/homInputPoint[2]; - iPoint[1]=homInputPoint[1]/homInputPoint[2]; - + iPoint[0]=-homInputPoint[0]/homInputPoint[2] + m_PanelShift[0]; + iPoint[1]=homInputPoint[1]/homInputPoint[2] + m_PanelShift[1]; + + typedef itk::LinearInterpolateImageFunction< InputImageType, double > InterpolatorType; + typename InterpolatorType::Pointer interpolator = InterpolatorType::New(); + interpolator->SetInputImage(this->GetInput()); + //Run over all output voxels for (unsigned int i=0; iTransformPhysicalPointToContinuousIndex(iPoint, iIndex) ) - { - //Own (fast bilinear) interpolation - lx = (int)floor(iIndex[0]); dx = iIndex[0]-lx; dxm = 1.-dx; - ly = (int)floor(iIndex[1]); dy = iIndex[1]-ly; dym = 1.-dy; - pp = beginPtr + ly*inputSize[0]+lx; - value =static_cast( ( dxm * dym*(double)(*pp) - + dx * dym*(double)(*(pp+1)) - + dxm* dy *(double)(*(pp + inputSize[0])) - + dx * dy *(double)(*(pp + inputSize[0]+1))) ); - - } + if (m_ModifiedInput->TransformPhysicalPointToContinuousIndex(iPoint, iIndex) && interpolator->IsInsideBuffer(iIndex)) + value = interpolator->EvaluateAtContinuousIndex(iIndex); //Outside: padding value - else value=m_EdgePaddingValue; - + else + value=m_EdgePaddingValue; //Set it iterator.Set(value); diff --git a/tools/clitkConeBeamProjectImage.ggo b/tools/clitkConeBeamProjectImage.ggo index 1c77551..4e80707 100644 --- a/tools/clitkConeBeamProjectImage.ggo +++ b/tools/clitkConeBeamProjectImage.ggo @@ -35,4 +35,4 @@ option "size" - "Size for the output image" int multiple no default="512" option "spacing" - "Spacing for the output image" double multiple no default="0.8" option "panel_position" - "Approximate position of the panel: small, medium or large" string no default="small" -option "panel_shift" - "Precise position of the panel in mm" double no +option "panel_shift" - "Precise position of the panel in mm" double multiple no diff --git a/tools/clitkConeBeamProjectImageFilter.h b/tools/clitkConeBeamProjectImageFilter.h index fcf8610..2363a5f 100644 --- a/tools/clitkConeBeamProjectImageFilter.h +++ b/tools/clitkConeBeamProjectImageFilter.h @@ -188,11 +188,16 @@ namespace clitk } /** Set the panelshift. */ - void SetPanelShift(double shift) + void SetPanelShift(double x, double y) { - if (m_PanelShift!=shift) + if (m_PanelShift[0] != x) { - m_PanelShift=shift; + m_PanelShift[0] = x; + m_IsInitialized=false; + } + if (m_PanelShift[1] != y) + { + m_PanelShift[1] = y; m_IsInitialized=false; } } @@ -229,7 +234,7 @@ namespace clitk double m_SourceToScreen; double m_SourceToAxis; double m_ProjectionAngle; - double m_PanelShift; + double m_PanelShift[2]; MatrixType m_RigidTransformMatrix; OutputPixelType m_EdgePaddingValue; diff --git a/tools/clitkConeBeamProjectImageFilter.txx b/tools/clitkConeBeamProjectImageFilter.txx index dfc8898..798fbd1 100644 --- a/tools/clitkConeBeamProjectImageFilter.txx +++ b/tools/clitkConeBeamProjectImageFilter.txx @@ -36,6 +36,8 @@ namespace clitk m_IsoCenter.Fill(0.0); m_SourceToScreen=1536.; m_SourceToAxis=1000.; + m_PanelShift[0] = 0.; + m_PanelShift[1] = 0.; m_ProjectionAngle=0.; m_RigidTransformMatrix.SetIdentity(); m_EdgePaddingValue=itk::NumericTraits::Zero;//density images @@ -163,15 +165,15 @@ namespace clitk spacingOutput[1] = m_OutputSpacing[0]; // pixel spacing along Y of the 2D DRR image [mm] spacingOutput[2] = m_OutputSpacing[1]; // pixel spacing along Y of the 2D DRR image [mm] m_Resampler->SetOutputSpacing( spacingOutput ); - if (m_Verbose)std::cout<<"The output size is "<< m_OutputSpacing <<"..."<< std::endl; + if (m_Verbose)std::cout<<"The output spacing is "<< m_OutputSpacing <<"..."<< std::endl; // The position of the DRR is specified, we presume that for an angle of 0° the flatpanel is located at the negative x-axis // JV -1 seems to correspond better with shearwarp of Simon Rit typename InterpolatorType::InputPointType originOutput; originOutput[0] = m_IsoCenter[0]- (m_SourceToScreen - m_SourceToAxis); DD(m_PanelShift); - originOutput[1] = m_IsoCenter[1]-static_cast(sizeOuput[1]-1)*spacingOutput[1]/2.0 - m_PanelShift; - originOutput[2] = m_IsoCenter[2]-static_cast(sizeOuput[2]-1)*spacingOutput[2]/2.0; + originOutput[1] = m_IsoCenter[1]-static_cast(sizeOuput[1]-1)*spacingOutput[1]/2.0 - m_PanelShift[0]; + originOutput[2] = m_IsoCenter[2]-static_cast(sizeOuput[2]-1)*spacingOutput[2]/2.0 - m_PanelShift[1]; m_Resampler->SetOutputOrigin( originOutput ); if (m_Verbose)std::cout<<"The origin of the flat panel is at "<< originOutput <<",..."<< std::endl; diff --git a/tools/clitkConeBeamProjectImageGenericFilter.cxx b/tools/clitkConeBeamProjectImageGenericFilter.cxx index d659b96..e36b7d1 100644 --- a/tools/clitkConeBeamProjectImageGenericFilter.cxx +++ b/tools/clitkConeBeamProjectImageGenericFilter.cxx @@ -133,14 +133,14 @@ namespace clitk DD(m_ArgsInfo.panel_position_arg); if (m_ArgsInfo.panel_shift_given) // one should read the specific values for each angle in Frame.dbf - filter->SetPanelShift(m_ArgsInfo.panel_shift_arg); + filter->SetPanelShift(m_ArgsInfo.panel_shift_arg[0], m_ArgsInfo.panel_shift_arg[1]); else { // approximate panel positions hard coded values for the elekta synergy if (strcmp(m_ArgsInfo.panel_position_arg,"small") ==0) - filter->SetPanelShift(0.); + filter->SetPanelShift(0., 0.); else if (strcmp(m_ArgsInfo.panel_position_arg,"medium") ==0) - filter->SetPanelShift(114.84); + filter->SetPanelShift(114.84, 0.); // VD : 120 , 0 ? else if (strcmp(m_ArgsInfo.panel_position_arg,"large") ==0) - filter->SetPanelShift(190.); + filter->SetPanelShift(190., 0.); else assert(false); //Unsupported panel position } // Output image info