// itk
#include <itkBoundingBox.h>
#include <itkJoinSeriesImageFilter.h>
+#include <itkChangeInformationImageFilter.h>
/*
According to
typename ImageType::PixelType & BG);
//--------------------------------------------------------------------
-
+ //--------------------------------------------------------------------
+ template<class ImageType>
+ typename ImageType::Pointer
+ RemoveNegativeIndexFromRegion(ImageType * input);
+ //--------------------------------------------------------------------
+
} // end clitk namespace
//--------------------------------------------------------------------
+ //--------------------------------------------------------------------
+ template<class ImageType>
+ typename ImageType::Pointer
+ RemoveNegativeIndexFromRegion(ImageType * input) {
+ typedef itk::ChangeInformationImageFilter< ImageType > InfoFilterType;
+ typename InfoFilterType::Pointer indexChangeFilter = InfoFilterType::New();
+ indexChangeFilter->ChangeRegionOn();
+ // The next line is commented because not exist in itk 3
+ // typename InfoFilterType::OutputImageOffsetValueType indexShift[3];
+ long indexShift[3];
+ typename ImageType::IndexType index = input->GetLargestPossibleRegion().GetIndex();
+ for(uint i=0;i<ImageType::ImageDimension; i++)
+ indexShift[i] = (index[i]<0 ? -index[i]:0);
+ typename ImageType::PointType origin;
+ for(uint i=0;i<ImageType::ImageDimension; i++)
+ origin[i] = input->GetOrigin()[i] - indexShift[i]*input->GetSpacing()[i];
+ indexChangeFilter->SetOutputOffset( indexShift );
+ indexChangeFilter->SetInput(input);
+ indexChangeFilter->SetOutputOrigin(origin);
+ indexChangeFilter->ChangeOriginOn();
+ indexChangeFilter->Update();
+ return indexChangeFilter->GetOutput();
+ }
+ //--------------------------------------------------------------------
} // end of namespace