From: dsarrut Date: Thu, 1 Jul 2010 08:36:55 +0000 (+0000) Subject: files merged in SegmentationUtils X-Git-Tag: v1.2.0~572 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=94e5eaf4476a635f54944beaad2982112a90195c;p=clitk.git files merged in SegmentationUtils --- diff --git a/itk/clitkSegmentationFunctions.h b/itk/clitkSegmentationFunctions.h deleted file mode 100644 index e39c3e5..0000000 --- a/itk/clitkSegmentationFunctions.h +++ /dev/null @@ -1,111 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ======================================================================-====*/ - -#ifndef CLITKSEGMENTATIONFUNCTIONS_H -#define CLITKSEGMENTATIONFUNCTIONS_H - -#include "clitkAutoCropFilter.h" - -//-------------------------------------------------------------------- -namespace clitk { - - //-------------------------------------------------------------------- - template - typename TInternalImageType::Pointer - SetBackground(typename TInternalImageType::ConstPointer input, - typename TMaskInternalImageType::ConstPointer 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 - typename TImageType::Pointer - Labelize(typename TImageType::Pointer input, - typename TImageType::PixelType BG, - bool isFullyConnected, - int minimalComponentSize); - //-------------------------------------------------------------------- - - - //-------------------------------------------------------------------- - template - typename TImageType::Pointer - RemoveLabels(typename TImageType::Pointer input, - typename TImageType::PixelType BG, - std::vector & labelsToRemove); - //-------------------------------------------------------------------- - - - //-------------------------------------------------------------------- - template - typename ImageType::Pointer - AutoCrop(typename ImageType::Pointer input, - typename ImageType::PixelType BG) { - typedef clitk::AutoCropFilter AutoCropFilterType; - typename AutoCropFilterType::Pointer autoCropFilter = AutoCropFilterType::New(); - autoCropFilter->SetInput(input); - autoCropFilter->Update(); - return autoCropFilter->GetOutput(); - } - - //-------------------------------------------------------------------- - //-------------------------------------------------------------------- - template - typename TImageType::Pointer - KeepLabels(typename TImageType::Pointer input, - typename TImageType::PixelType BG, - typename TImageType::PixelType FG, - typename TImageType::PixelType firstKeep, - typename TImageType::PixelType lastKeep, - bool useLastKeep); - //-------------------------------------------------------------------- - - - //-------------------------------------------------------------------- - template - typename TImageType::Pointer - LabelizeAndSelectLabels(typename TImageType::Pointer input, - typename TImageType::PixelType BG, - typename TImageType::PixelType FG, - bool isFullyConnected, - int minimalComponentSize, - LabelizeParameters * param); -} -//-------------------------------------------------------------------- - -#include "clitkSegmentationFunctions.txx" -//-------------------------------------------------------------------- - -#endif diff --git a/itk/clitkSegmentationFunctions.txx b/itk/clitkSegmentationFunctions.txx deleted file mode 100644 index 6da6b7b..0000000 --- a/itk/clitkSegmentationFunctions.txx +++ /dev/null @@ -1,139 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ======================================================================-====*/ - -// clitk -#include "clitkSetBackgroundImageFilter.h" - -// itk -#include -#include -#include - -//-------------------------------------------------------------------- -template -typename TImageType::Pointer -clitk::SetBackground(typename TImageType::ConstPointer input, - typename TMaskImageType::ConstPointer mask, - typename TMaskImageType::PixelType maskBG, - typename TImageType::PixelType outValue) { - typedef clitk::SetBackgroundImageFilter SetBackgroundImageFilterType; - typename SetBackgroundImageFilterType::Pointer setBackgroundFilter = SetBackgroundImageFilterType::New(); - setBackgroundFilter->SetInput(input); - setBackgroundFilter->SetInput2(mask); - setBackgroundFilter->SetMaskValue(maskBG); - setBackgroundFilter->SetOutsideValue(outValue); - setBackgroundFilter->Update(); - return setBackgroundFilter->GetOutput(); -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -template -typename TImageType::Pointer -clitk::Labelize(typename TImageType::Pointer input, - typename TImageType::PixelType BG, - bool isFullyConnected, - int minimalComponentSize) { - - // Connected Component label - 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; - typename RelabelFilterType::Pointer relabelFilter = RelabelFilterType::New(); - relabelFilter->InPlaceOn(); - relabelFilter->SetInput(connectFilter->GetOutput()); - relabelFilter->SetMinimumObjectSize(minimalComponentSize); - relabelFilter->Update(); - - // Return result - return relabelFilter->GetOutput(); -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -template -typename TImageType::Pointer -clitk::RemoveLabels(typename TImageType::Pointer input, - typename TImageType::PixelType BG, - std::vector & labelsToRemove) { - typename TImageType::Pointer working_image = input; - for (unsigned int i=0; i SetBackgroundImageFilterType; - typename SetBackgroundImageFilterType::Pointer setBackgroundFilter = SetBackgroundImageFilterType::New(); - setBackgroundFilter->SetInput(input); - setBackgroundFilter->SetInput2(input); - setBackgroundFilter->SetMaskValue(labelsToRemove[i]); - setBackgroundFilter->SetOutsideValue(BG); - setBackgroundFilter->Update(); - working_image = setBackgroundFilter->GetOutput(); - } - return working_image; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -template -typename TImageType::Pointer -clitk::KeepLabels(typename TImageType::Pointer input, - typename TImageType::PixelType BG, - typename TImageType::PixelType FG, - typename TImageType::PixelType firstKeep, - typename TImageType::PixelType lastKeep, - bool useLastKeep) { - typedef itk::BinaryThresholdImageFilter BinarizeFilterType; - typename BinarizeFilterType::Pointer binarizeFilter = BinarizeFilterType::New(); - binarizeFilter->SetInput(input); - binarizeFilter->SetLowerThreshold(firstKeep); - if (useLastKeep) binarizeFilter->SetUpperThreshold(lastKeep); - binarizeFilter->SetInsideValue(FG); - binarizeFilter->SetOutsideValue(BG); - binarizeFilter->Update(); - return binarizeFilter->GetOutput(); -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -template -typename TImageType::Pointer -clitk::LabelizeAndSelectLabels(typename TImageType::Pointer input, - typename TImageType::PixelType BG, - typename TImageType::PixelType FG, - bool isFullyConnected, - int minimalComponentSize, - LabelizeParameters * param) -{ - typename TImageType::Pointer working_image; - working_image = Labelize(input, BG, isFullyConnected, minimalComponentSize); - working_image = RemoveLabels(working_image, BG, param->GetLabelsToRemove()); - working_image = KeepLabels(working_image, - BG, FG, - param->GetFirstKeep(), - param->GetLastKeep(), - param->GetUseLastKeep()); - return working_image; -} -//--------------------------------------------------------------------