From: dsarrut Date: Fri, 22 Oct 2010 07:34:46 +0000 (+0000) Subject: simplified image pointer (const/non const) X-Git-Tag: v1.2.0~327 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=68674d29b9dd06b4a786d8ce7a14acd1d97f907e;p=clitk.git simplified image pointer (const/non const) --- diff --git a/itk/clitkSegmentationUtils.h b/itk/clitkSegmentationUtils.h index 80d4e93..6959883 100644 --- a/itk/clitkSegmentationUtils.h +++ b/itk/clitkSegmentationUtils.h @@ -48,27 +48,12 @@ namespace clitk { //-------------------------------------------------------------------- template typename TInternalImageType::Pointer - SetBackground(typename TInternalImageType::ConstPointer input, - typename TMaskInternalImageType::ConstPointer mask, + SetBackground(const TInternalImageType * input, + const TMaskInternalImageType * mask, typename TMaskInternalImageType::PixelType maskBG, typename TInternalImageType::PixelType outValue); //-------------------------------------------------------------------- - - //-------------------------------------------------------------------- - template - typename TInternalImageType::Pointer - SetBackground(typename TInternalImageType::Pointer input, - typename TMaskInternalImageType::Pointer mask, - typename TMaskInternalImageType::PixelType maskBG, - typename TInternalImageType::PixelType outValue) { - return SetBackground - (static_cast(input), - static_cast(mask), - maskBG, outValue); - } - //-------------------------------------------------------------------- - //-------------------------------------------------------------------- template diff --git a/itk/clitkSegmentationUtils.txx b/itk/clitkSegmentationUtils.txx index e031079..aef202f 100644 --- a/itk/clitkSegmentationUtils.txx +++ b/itk/clitkSegmentationUtils.txx @@ -36,7 +36,7 @@ void clitk::ComputeBBFromImageRegion(typename ImageType::Pointer image, IndexType lastIndex; for(unsigned int i=0; iGetImageDimension(); i++) { firstIndex[i] = region.GetIndex()[i]; - lastIndex[i] = region.GetSize()[i]; + lastIndex[i] = firstIndex[i]+region.GetSize()[i]; } typedef itk::BoundingBoxGetMaximum(); PointType mins = bb->GetMinimum(); for(unsigned int i=0; iGetSpacing()[i]); + // DD(maxs[i]); + // DD(mins[i]); + // DD((maxs[i] - mins[i])/image->GetSpacing()[i]); + regionSize[i] = lrint((maxs[i] - mins[i])/image->GetSpacing()[i]); + // DD(regionSize[i]); } // Create region @@ -111,8 +115,9 @@ void clitk::ComputeRegionFromBB(typename ImageType::Pointer image, //-------------------------------------------------------------------- template typename ImageType::Pointer -clitk::SetBackground(typename ImageType::ConstPointer input, - typename TMaskImageType::ConstPointer mask, +clitk::SetBackground(//typename ImageType::ConstPointer input, + const ImageType * input, + const TMaskImageType * mask, typename TMaskImageType::PixelType maskBG, typename ImageType::PixelType outValue) { typedef clitk::SetBackgroundImageFilter SetBackgroundImageFilterType; @@ -152,15 +157,18 @@ clitk::Labelize(typename ImageType::Pointer input, typename ImageType::PixelType BG, bool isFullyConnected, int minimalComponentSize) { + // InternalImageType for storing large number of component + typedef itk::Image InternalImageType; + // Connected Component label - typedef itk::ConnectedComponentImageFilter ConnectFilterType; + typedef itk::ConnectedComponentImageFilter ConnectFilterType; typename ConnectFilterType::Pointer connectFilter = ConnectFilterType::New(); connectFilter->SetInput(input); connectFilter->SetBackgroundValue(BG); connectFilter->SetFullyConnected(isFullyConnected); // Sort by size and remove too small area. - typedef itk::RelabelComponentImageFilter RelabelFilterType; + typedef itk::RelabelComponentImageFilter RelabelFilterType; typename RelabelFilterType::Pointer relabelFilter = RelabelFilterType::New(); relabelFilter->InPlaceOn(); relabelFilter->SetInput(connectFilter->GetOutput());