X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkSegmentationUtils.txx;h=e031079bfcb505f6c5a210869d27917a06a85801;hb=b4b174778ef56f804ad0bfca28b5dc745f9025d8;hp=0f5ebfbd58b9f7a9888e906091129b48909737e2;hpb=48f513811d9b13e6c7df67d8dc16fa073aa0751a;p=clitk.git diff --git a/itk/clitkSegmentationUtils.txx b/itk/clitkSegmentationUtils.txx index 0f5ebfb..e031079 100644 --- a/itk/clitkSegmentationUtils.txx +++ b/itk/clitkSegmentationUtils.txx @@ -127,6 +127,24 @@ clitk::SetBackground(typename ImageType::ConstPointer input, //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +template +int clitk::GetNumberOfConnectedComponentLabels(typename ImageType::Pointer input, + typename ImageType::PixelType BG, + bool isFullyConnected) { + // Connected Component label + typedef itk::ConnectedComponentImageFilter ConnectFilterType; + typename ConnectFilterType::Pointer connectFilter = ConnectFilterType::New(); + connectFilter->SetInput(input); + connectFilter->SetBackgroundValue(BG); + connectFilter->SetFullyConnected(isFullyConnected); + connectFilter->Update(); + + // Return result + return connectFilter->GetObjectCount(); +} +//-------------------------------------------------------------------- + //-------------------------------------------------------------------- template typename ImageType::Pointer