From fdc97293cc66a4894a2c1c4f04f53d6473ab8ab2 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Tue, 15 Feb 2011 10:45:04 +0000 Subject: [PATCH] add missing "allocate" --- itk/clitkCropLikeImageFilter.h | 3 --- itk/clitkCropLikeImageFilter.txx | 14 ++++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/itk/clitkCropLikeImageFilter.h b/itk/clitkCropLikeImageFilter.h index d288dc4..221f61c 100644 --- a/itk/clitkCropLikeImageFilter.h +++ b/itk/clitkCropLikeImageFilter.h @@ -64,8 +64,6 @@ namespace clitk { /** ImageDimension constants */ itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension); - - // void Update() { GenerateOutputInformation(); GenerateData(); } protected: CropLikeImageFilter(); @@ -82,7 +80,6 @@ namespace clitk { bool m_LikeFilenameIsGiven; PointType m_Origin; const itk::ImageBase * m_LikeImage; - //typename ImageType::Pointer m_LikeImage; std::vector m_CropAlongThisDimension; PointType m_StartPoint; // start point in physical world diff --git a/itk/clitkCropLikeImageFilter.txx b/itk/clitkCropLikeImageFilter.txx index 8b90fe3..74be28e 100644 --- a/itk/clitkCropLikeImageFilter.txx +++ b/itk/clitkCropLikeImageFilter.txx @@ -93,8 +93,7 @@ GenerateInputRequestedRegion() { template void clitk::CropLikeImageFilter:: -GenerateOutputInformation() { - DD("GenerateOutputInformation"); +GenerateOutputInformation() { // Get input pointers ImageConstPointer input = dynamic_cast(itk::ProcessObject::GetInput(0)); @@ -132,8 +131,8 @@ GenerateOutputInformation() { for(unsigned int i=0; iGetSpacing()[i]) { clitkExceptionMacro("Images must have the same spacing, but input's spacing(" << i - <<") is " << input->GetSpacing()[i] << " while like's spacing(" << i - << ") is " << likeSpacing[i] << "."); + <<") is " << input->GetSpacing()[i] << " while the spacing(" << i + << ") of 'like' is " << likeSpacing[i] << "."); } } // Define output region @@ -144,6 +143,7 @@ GenerateOutputInformation() { output->SetBufferedRegion(m_OutputRegion); output->SetSpacing(likeSpacing); output->SetOrigin(likeOrigin); + output->Allocate(); // Needed ? // get startpoint source/dest // for each dim @@ -199,6 +199,7 @@ GenerateOutputInformation() { for(int i=0; iGetOutput(0); - output->Allocate(); + output->FillBuffer(GetBackgroundValue()); // Paste image inside typedef itk::PasteImageFilter PasteFilterType; typename PasteFilterType::Pointer pasteFilter = PasteFilterType::New(); + //pasteFilter->ReleaseDataFlagOn(); // change nothing ? + // pasteFilter->InPlaceOn(); // makt it seg fault pasteFilter->SetSourceImage(input); pasteFilter->SetDestinationImage(output); pasteFilter->SetDestinationIndex(m_StartDestIndex); @@ -225,7 +228,6 @@ GenerateData() { pasteFilter->Update(); // Get (graft) output (SetNthOutput does not fit here because of Origin). - // this->GraftOutput(cropFilter->GetOutput()); this->GraftOutput(pasteFilter->GetOutput()); } //-------------------------------------------------------------------- -- 2.47.1