X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkBackProjectImageFilter.txx;h=b1f84e260426db6becc2a0261be699742ee759da;hb=02f230e65dbfde06e84da374bb085643e29b5090;hp=f70fa9e164346883929d0baa464742795da97825;hpb=a26cd8a19e1b9ad8344ab501436045f171a73713;p=clitk.git diff --git a/itk/clitkBackProjectImageFilter.txx b/itk/clitkBackProjectImageFilter.txx index f70fa9e..b1f84e2 100644 --- a/itk/clitkBackProjectImageFilter.txx +++ b/itk/clitkBackProjectImageFilter.txx @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,12 +14,13 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ +===========================================================================**/ #ifndef __clitkBackProjectImageFilter_txx #define __clitkBackProjectImageFilter_txx #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); @@ -220,7 +223,7 @@ namespace clitk BackProjectImageFilter ::CalculateProjectionMatrix( void ) { - InputSpacingType inputSpacing=this->GetInput()->GetSpacing(); + //InputSpacingType inputSpacing=this->GetInput()->GetSpacing(); // Projection on YZ plane+pixelTrans itk::Matrix temp; @@ -300,12 +303,14 @@ namespace clitk template void BackProjectImageFilter +#if ITK_VERSION_MAJOR >= 4 + ::ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, itk::ThreadIdType threadId ) +#else ::ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, int threadId ) +#endif { //Projection pointer InputImageConstPointer inputPtr=this->GetInput(); - InputPixelType * beginPtr=const_cast(this->GetInput()->GetBufferPointer()); - InputPixelType * pp; //Volume pointer OutputImagePointer outputPTr= this->GetOutput(); @@ -324,9 +329,6 @@ namespace clitk iPoint.Fill(itk::NumericTraits::Zero); 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 +339,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);