]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of /home/dsarrut/clitk3.server
authorSimon Rit <simon.rit@creatis.insa-lyon.fr>
Mon, 30 May 2011 16:17:48 +0000 (18:17 +0200)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Mon, 30 May 2011 16:17:48 +0000 (18:17 +0200)
itk/clitkBackProjectImageFilter.h
itk/clitkBackProjectImageFilter.txx
tools/clitkConeBeamProjectImage.ggo
tools/clitkConeBeamProjectImageFilter.h
tools/clitkConeBeamProjectImageFilter.txx
tools/clitkConeBeamProjectImageGenericFilter.cxx

index ebaeffc49fee3ff2c3753d7d8a4d344e6b5c2cf5..7de71a116111326f2bed06060af31bc165a6ecb5 100644 (file)
@@ -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
index 65ac8017d4cb98b2009b573f3de03afb07e694db..befc8822013cb8543d7bbc0d3ece59b417f84b31 100644 (file)
@@ -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<OutputPixelType>::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<InputPixelType *>(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; i<outputSizeForThread[2]; i++)
       {
@@ -347,25 +350,15 @@ namespace clitk
          {
            for (unsigned int k=0; k<outputSizeForThread[0]; k++)
              {
-               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];
 
                //Check wether inside, convert to index (use modified with correct origin)
-               if( m_ModifiedInput->TransformPhysicalPointToContinuousIndex(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<OutputPixelType>( ( 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);
 
index 1c77551e0500be7c8b9601d67d1610b4c9a99fa1..4e80707a030803ce6c948b65206f792938c462fa 100644 (file)
@@ -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
index fcf8610c5798ab471583a69aa751316ce1e3682f..2363a5f1a3882567f5eaa926adf7d19c7b34abce 100644 (file)
@@ -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;
 
index dfc889827dfab2865ec6914910f0dad0763047b2..798fbd1c5bd10b83e5d5b8994ef8da36bf62e7e3 100644 (file)
@@ -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<OutputPixelType>::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<double>(sizeOuput[1]-1)*spacingOutput[1]/2.0 - m_PanelShift;
-    originOutput[2] = m_IsoCenter[2]-static_cast<double>(sizeOuput[2]-1)*spacingOutput[2]/2.0
+    originOutput[1] = m_IsoCenter[1]-static_cast<double>(sizeOuput[1]-1)*spacingOutput[1]/2.0 - m_PanelShift[0];
+    originOutput[2] = m_IsoCenter[2]-static_cast<double>(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;
 
index d659b969f8e2f48a75eb30ed8724eb1dc72d1ec2..e36b7d1b1febafabe4843a7a627516292d5ba2ea 100644 (file)
@@ -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