AutoCropFilter():itk::ImageToImageFilter<ImageType, ImageType>() {
this->SetNumberOfRequiredInputs(1);
m_BackgroundValue = 0;
+ UseBorderOn();
}
//--------------------------------------------------------------------
typedef itk::AutoCropLabelMapFilter<LabelMapType> AutoCropFilterType;
typename AutoCropFilterType::Pointer autoCropFilter = AutoCropFilterType::New();
autoCropFilter->SetInput(imageToLabelFilter->GetOutput());
- autoCropFilter->ReleaseDataFlagOff();
-
+ // autoCropFilter->ReleaseDataFlagOff();
+ if (GetUseBorder()) {
+ typename ImageType::SizeType s;
+ for(uint i=0; i<ImageType::ImageDimension; i++) s[i] = 1;
+ autoCropFilter->SetCropBorder(s);
+ }
+ autoCropFilter->ReleaseDataFlagOn();
+
// Convert to LabelImage
typedef itk::LabelMapToLabelImageFilter<LabelMapType, ImageType> MapToImageFilterType;
typename MapToImageFilterType::Pointer labelToImageFilter = MapToImageFilterType::New();
typename ImageType::IndexType index;
index.Fill(0);
m_Region.SetIndex(index);
- DD(m_Region);
}
+
+ // Set the region to output
output->SetLargestPossibleRegion(m_Region);
output->SetRequestedRegion(m_Region);
output->SetBufferedRegion(m_Region);
// Extract the region with RegionOfInterestImageFilter or ExtractImageFilter ?
// The second is when reducing the nb of dimension (index always zero)
- // The first keep index
+ // The first keep index.
+ // OLD : typedef itk::ExtractImageFilter<ImageType, ImageType> CropFilterType;
+ // OLD : cropFilter->SetExtractionRegion(m_Region);
typedef itk::RegionOfInterestImageFilter<ImageType, ImageType> CropFilterType;
- //typedef itk::ExtractImageFilter<ImageType, ImageType> CropFilterType;
m_labeImage->SetRequestedRegion(m_labeImage->GetLargestPossibleRegion());
typename CropFilterType::Pointer cropFilter = CropFilterType::New();
cropFilter->SetInput(m_labeImage);
cropFilter->SetReleaseDataFlag(this->GetReleaseDataFlag());
-
cropFilter->SetRegionOfInterest(m_Region);
- //cropFilter->SetExtractionRegion(m_Region);
// Go !
cropFilter->Update();