X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkCropLikeImageFilter.txx;h=5a9696e8b935434ed969194e89c1e7dd4236c09d;hb=184e72d6817dd7450c804735686745c6ba712943;hp=0af957bb20c6e8ae57e5b560920c3a907719ceea;hpb=573d80d0f7a17607d2ee883c21c940c0ba020282;p=clitk.git diff --git a/itk/clitkCropLikeImageFilter.txx b/itk/clitkCropLikeImageFilter.txx index 0af957b..5a9696e 100644 --- a/itk/clitkCropLikeImageFilter.txx +++ b/itk/clitkCropLikeImageFilter.txx @@ -21,9 +21,7 @@ // clitk #include "clitkCommon.h" - -// itk -#include "itkPasteImageFilter.h" +#include "clitkPasteImageFilter.h" //-------------------------------------------------------------------- template @@ -136,6 +134,16 @@ GenerateOutputInformation() { << ") of 'like' is " << likeSpacing[i] << "."); } } + + // Check that we must crop along each dimension. If not, we use the + // size of the input image + for(unsigned int i=0; iGetLargestPossibleRegion().GetIndex()[i]; + likeSize[i] = input->GetLargestPossibleRegion().GetSize()[i]; + } + } + // Define output region m_OutputRegion.SetIndex(likeStart); m_OutputRegion.SetSize(likeSize); @@ -218,7 +226,7 @@ GenerateData() { output->FillBuffer(GetBackgroundValue()); // Paste image inside - typedef itk::PasteImageFilter PasteFilterType; + typedef clitk::PasteImageFilter PasteFilterType; typename PasteFilterType::Pointer pasteFilter = PasteFilterType::New(); //pasteFilter->ReleaseDataFlagOn(); // change nothing ? // pasteFilter->InPlaceOn(); // makt it seg fault @@ -233,5 +241,23 @@ GenerateData() { } //-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +template +typename ImageType::Pointer +clitk::ResizeImageLike(const ImageType * input, + const itk::ImageBase * like, + typename ImageType::PixelType backgroundValue) +{ + typedef clitk::CropLikeImageFilter CropFilterType; + typename CropFilterType::Pointer cropFilter = CropFilterType::New(); + cropFilter->SetInput(input); + cropFilter->SetCropLikeImage(like); + cropFilter->SetBackgroundValue(backgroundValue); + cropFilter->Update(); + return cropFilter->GetOutput(); +} +//-------------------------------------------------------------------- + -#endif //#define CLITKAUTOCROPFILTER +#endif //#define CLITKCROPLIKEIMAGEFILTER_TXX