From: dsarrut Date: Tue, 15 Feb 2011 10:46:13 +0000 (+0000) Subject: add 'border' option X-Git-Tag: v1.2.0~253 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f20fc139cf80d306090aa035f0fd6a4dd77a77fe;p=clitk.git add 'border' option --- diff --git a/itk/clitkAutoCropFilter.h b/itk/clitkAutoCropFilter.h index f4f35bc..94cdb65 100644 --- a/itk/clitkAutoCropFilter.h +++ b/itk/clitkAutoCropFilter.h @@ -58,6 +58,11 @@ namespace clitk { // LabelImage information (BG) void SetBackgroundValue(ImagePixelType p); + + // Use a border + itkSetMacro(UseBorder, bool); + itkGetConstMacro(UseBorder, bool); + itkBooleanMacro(UseBorder); /** ImageDimension constants */ itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension); @@ -72,6 +77,7 @@ namespace clitk { ImagePixelType m_BackgroundValue; ImageRegionType m_Region; ImagePointer m_labeImage; + bool m_UseBorder; private: AutoCropFilter(const Self&); //purposely not implemented diff --git a/itk/clitkAutoCropFilter.txx b/itk/clitkAutoCropFilter.txx index 8f45f57..85ce7be 100644 --- a/itk/clitkAutoCropFilter.txx +++ b/itk/clitkAutoCropFilter.txx @@ -39,6 +39,7 @@ namespace clitk { AutoCropFilter():itk::ImageToImageFilter() { this->SetNumberOfRequiredInputs(1); m_BackgroundValue = 0; + UseBorderOn(); } //-------------------------------------------------------------------- @@ -95,8 +96,14 @@ namespace clitk { typedef itk::AutoCropLabelMapFilter 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; iSetCropBorder(s); + } + autoCropFilter->ReleaseDataFlagOn(); + // Convert to LabelImage typedef itk::LabelMapToLabelImageFilter MapToImageFilterType; typename MapToImageFilterType::Pointer labelToImageFilter = MapToImageFilterType::New(); @@ -114,8 +121,9 @@ namespace clitk { 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);