]> Creatis software - clitk.git/commitdiff
Resample mask to overcome the bug with mask that doesn't have the same
authordelmon <delmon>
Thu, 6 Jan 2011 09:13:37 +0000 (09:13 +0000)
committerdelmon <delmon>
Thu, 6 Jan 2011 09:13:37 +0000 (09:13 +0000)
resolution as the fixed image.

registration/clitkBLUTDIRGenericFilter.cxx

index 3e6c6ec18b36d8569b9d37e2e0e10a179e69f2c2..9640282ec800d2cf1d3a4aa622b3f244f6248c8d 100755 (executable)
@@ -340,13 +340,23 @@ namespace clitk
         }
         if (m_Verbose)std::cout <<"Reference image mask was read..." <<std::endl;
 
+        // Resample mask
+        typedef itk::ResampleImageFilter<ImageMaskType, ImageMaskType> ResamplerType;
+        typename ResamplerType::Pointer resampler = ResamplerType::New();
+        typedef itk::NearestNeighborInterpolateImageFunction<ImageMaskType, TCoordRep> InterpolatorType;
+        typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
+        resampler->SetOutputParametersFromImage(fixedImage);
+        resampler->SetInterpolator(interpolator);
+        resampler->SetInput(maskReader->GetOutput());
+        resampler->Update();
+
         // Set the image to the spatialObject
-        fixedMask->SetImage( maskReader->GetOutput() );
+        fixedMask->SetImage(resampler->GetOutput());
 
         // Find the bounding box of the "inside" label
         typedef itk::LabelGeometryImageFilter<ImageMaskType> GeometryImageFilterType;
         typename GeometryImageFilterType::Pointer geometryImageFilter=GeometryImageFilterType::New();
-        geometryImageFilter->SetInput(maskReader->GetOutput());
+        geometryImageFilter->SetInput(resampler->GetOutput());
         geometryImageFilter->Update();
         typename GeometryImageFilterType::BoundingBoxType boundingBox = geometryImageFilter->GetBoundingBox(1);