From 101e27e809f46df0cb5f7371b8d030d9648ae1a0 Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Fri, 3 Feb 2012 07:57:11 +0100 Subject: [PATCH] Moved from repository clitk to clitk.private/tests_dav --- segmentation/clitkRegionGrowing.cxx | 51 --- segmentation/clitkRegionGrowing.ggo | 34 -- .../clitkRegionGrowingGenericFilter.cxx | 72 ----- .../clitkRegionGrowingGenericFilter.h | 121 ------- .../clitkRegionGrowingGenericFilter.txx | 302 ------------------ 5 files changed, 580 deletions(-) delete mode 100644 segmentation/clitkRegionGrowing.cxx delete mode 100644 segmentation/clitkRegionGrowing.ggo delete mode 100644 segmentation/clitkRegionGrowingGenericFilter.cxx delete mode 100644 segmentation/clitkRegionGrowingGenericFilter.h delete mode 100644 segmentation/clitkRegionGrowingGenericFilter.txx diff --git a/segmentation/clitkRegionGrowing.cxx b/segmentation/clitkRegionGrowing.cxx deleted file mode 100644 index 83aa816..0000000 --- a/segmentation/clitkRegionGrowing.cxx +++ /dev/null @@ -1,51 +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://www.centreleonberard.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 -===========================================================================**/ - -/* ================================================= - * @file clitkRegionGrowing.cxx - * @author - * @date - * - * @brief - * - ===================================================*/ - - -// clitk -#include "clitkRegionGrowing_ggo.h" -#include "clitkIO.h" -#include "clitkRegionGrowingGenericFilter.h" - - -//-------------------------------------------------------------------- -int main(int argc, char * argv[]) { - - // Init command line - GGO(clitkRegionGrowing, args_info); - CLITK_INIT; - - // Filter - clitk::RegionGrowingGenericFilter::Pointer genericFilter=clitk::RegionGrowingGenericFilter::New(); - - genericFilter->SetArgsInfo(args_info); - genericFilter->Update(); - - return EXIT_SUCCESS; -}// end main - -//-------------------------------------------------------------------- diff --git a/segmentation/clitkRegionGrowing.ggo b/segmentation/clitkRegionGrowing.ggo deleted file mode 100644 index 60bcae2..0000000 --- a/segmentation/clitkRegionGrowing.ggo +++ /dev/null @@ -1,34 +0,0 @@ -#File clitkRegionGrowing.ggo -package "clitkRegionGrowing" -version "1.0" -purpose "Region growing from a seed point using various types of conditions to control the growing" - -option "config" - "Config file" string no -option "verbose" v "Verbose" flag off - -section "I/O" - -option "input" i "Input image filename" string yes -option "output" o "Output image filename" string yes - - -section "Parameters" - -option "type" t "Region growing filter type: 0=threshold , 1=neighborhood-threshold , 2=confidence , 3= locally-adaptive-threshold, 4= explosion-controlled-threshold" int no default="0" -option "lower" l "1,2,3,4: Lower threshold value" double no default="0" -option "upper" u "1,2,3,4: Upper threshold value" double no default="1" -option "maxUpper" - "4: Maximum upper threshold value" double no default="2000" -option "minLower" - "4: Minimum lower threshold value" double no default="-1000" -option "step" - "4: Threshold step size" double no default="64.0" -option "minStep" - "4: Minimum threshold step size" double no default="1" -option "adaptLower" - "3,4: (locally) adapt lower thresholding" flag off -option "adaptUpper" - "3,4: (locally) adapt upper thresholding" flag off -option "multiplier" m "2-4: (2-3) accept if within mean+-mutiplier*SD, (4) explosion if size increases multiplier times" double no default="2.0" -option "seed" s "Seed index postion (in voxels)" int multiple no default="0" -option "seedRadius" - "Radius used for seed dilatation(in voxel)" int multiple no default="0" -option "pad" p "The replace padding value" double no default="1.0" -option "radius" r "1-3: The radius of the neighborhood" int no multiple default="1" -option "maxSD" - "3: Limit to SD" double no -option "full" - "4: use full connectivity (not implemented yet)" flag off -option "iter" - "2: Iterations" int no default="5" - diff --git a/segmentation/clitkRegionGrowingGenericFilter.cxx b/segmentation/clitkRegionGrowingGenericFilter.cxx deleted file mode 100644 index f5092ba..0000000 --- a/segmentation/clitkRegionGrowingGenericFilter.cxx +++ /dev/null @@ -1,72 +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://www.centreleonberard.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 clitkRegionGrowingGenericFilter_cxx -#define clitkRegionGrowingGenericFilter_cxx - -/* ================================================= - * @file clitkRegionGrowingGenericFilter.cxx - * @author - * @date - * - * @brief - * - ===================================================*/ - -#include "clitkRegionGrowingGenericFilter.h" - - -namespace clitk -{ - - - //----------------------------------------------------------- - // Constructor - //----------------------------------------------------------- - RegionGrowingGenericFilter::RegionGrowingGenericFilter() - { - m_Verbose=false; - m_InputFileName=""; - } - - - //----------------------------------------------------------- - // Update - //----------------------------------------------------------- - void RegionGrowingGenericFilter::Update() - { - // Read the Dimension and PixelType - int Dimension; - std::string PixelType; - ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType); - - - // Call UpdateWithDim - if(Dimension==2) UpdateWithDim<2>(PixelType); - else if(Dimension==3) UpdateWithDim<3>(PixelType); - // else if (Dimension==4)UpdateWithDim<4>(PixelType); - else - { - std::cout<<"Error, Only for 2 or 3 Dimensions!!!"< Pointer; - typedef itk::SmartPointer ConstPointer; - - // Method for creation through the object factory - itkNewMacro(Self); - - // Run-time type information (and related methods) - itkTypeMacro( RegionGrowingGenericFilter, LightObject ); - - - //---------------------------------------- - // Typedefs - //---------------------------------------- - - - //---------------------------------------- - // Set & Get - //---------------------------------------- - void SetArgsInfo(const args_info_clitkRegionGrowing & a) - { - m_ArgsInfo=a; - m_Verbose=m_ArgsInfo.verbose_flag; - m_InputFileName=m_ArgsInfo.input_arg; - } - - - //---------------------------------------- - // Update - //---------------------------------------- - void Update(); - - protected: - - //---------------------------------------- - // Constructor & Destructor - //---------------------------------------- - RegionGrowingGenericFilter(); - ~RegionGrowingGenericFilter() {}; - - - //---------------------------------------- - // Templated members - //---------------------------------------- - template void UpdateWithDim(std::string PixelType); - template void UpdateWithDimAndPixelType(); - - - //---------------------------------------- - // Data members - //---------------------------------------- - args_info_clitkRegionGrowing m_ArgsInfo; - bool m_Verbose; - std::string m_InputFileName; - - }; - - -} // end namespace clitk - -#ifndef ITK_MANUAL_INSTANTIATION -#include "clitkRegionGrowingGenericFilter.txx" -#endif - -#endif // #define clitkRegionGrowingGenericFilter_h diff --git a/segmentation/clitkRegionGrowingGenericFilter.txx b/segmentation/clitkRegionGrowingGenericFilter.txx deleted file mode 100644 index eead0d5..0000000 --- a/segmentation/clitkRegionGrowingGenericFilter.txx +++ /dev/null @@ -1,302 +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://www.centreleonberard.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 clitkRegionGrowingGenericFilter_txx -#define clitkRegionGrowingGenericFilter_txx -#include -#include - -namespace clitk -{ - - //------------------------------------------------------------------- - // Update with the number of dimensions - //------------------------------------------------------------------- - template - void - RegionGrowingGenericFilter::UpdateWithDim(std::string PixelType) - { - if (m_Verbose) std::cout << "Image was detected to be "<(); - } - // else if(PixelType == "unsigned_short"){ - // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl; - // UpdateWithDimAndPixelType(); - // } - - else if (PixelType == "unsigned_char"){ - if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl; - UpdateWithDimAndPixelType(); - } - - // else if (PixelType == "char"){ - // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl; - // UpdateWithDimAndPixelType(); - // } - else { - if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl; - UpdateWithDimAndPixelType(); - } - } - - - //------------------------------------------------------------------- - // Update with the number of dimensions and the pixeltype - //------------------------------------------------------------------- - template - void - RegionGrowingGenericFilter::UpdateWithDimAndPixelType() - { - - // ImageTypes - typedef itk::Image InputImageType; - typedef itk::Image OutputImageType; - - // Read the input - typedef itk::ImageFileReader InputReaderType; - typename InputReaderType::Pointer reader = InputReaderType::New(); - reader->SetFileName( m_InputFileName); - reader->Update(); - typename InputImageType::Pointer input= reader->GetOutput(); - - // Seed - typedef typename std::vector SeedsType; - SeedsType seeds(1); - if(m_ArgsInfo.seed_given==Dimension) - for (unsigned int i=0; i BallType; - typename BallType::RadiusType r; - - if (m_ArgsInfo.seedRadius_given == Dimension) - for (unsigned i = 0; i < Dimension; i++) - r[i] = m_ArgsInfo.seedRadius_arg[i]; - else - r.Fill(m_ArgsInfo.seedRadius_arg[0]); - - BallType ball; - ball.SetRadius(r); - ball.CreateStructuringElement(); - - typedef itk::ConstShapedNeighborhoodIterator IteratorType; - IteratorType it(ball.GetRadius(), - input, - input->GetLargestPossibleRegion()); -#if ITK_VERSION_MAJOR < 4 - typename BallType::ConstIterator nit; - unsigned idx = 0; - for (nit = ball.Begin(); nit != ball.End(); ++nit, ++idx) - { - if (*nit) - { - it.ActivateOffset(it.GetOffset(idx)); - } - else - { - it.DeactivateOffset(it.GetOffset(idx)); - } - } -#else - it.CreateActiveListFromNeighborhood(ball); - it.NeedToUseBoundaryConditionOff(); -#endif - - it.SetLocation(seeds[0]); - for (typename IteratorType::ConstIterator i = it.Begin(); !i.IsAtEnd(); ++i) - { - typename InputImageType::IndexType id = seeds[0] + i.GetNeighborhoodOffset(); - if (id != seeds[0] && input->GetLargestPossibleRegion().IsInside(id)) - seeds.push_back(id); - } - } - - // Filter - typedef itk::ImageToImageFilter ImageToImageFilterType; - typename ImageToImageFilterType::Pointer filter; - - switch (m_ArgsInfo.type_arg) - { - case 0: { - - typedef itk::ConnectedThresholdImageFilter ImageFilterType; - typename ImageFilterType::Pointer f= ImageFilterType::New(); - - f->SetLower(m_ArgsInfo.lower_arg); - f->SetUpper(m_ArgsInfo.upper_arg); - f->SetReplaceValue(static_cast(m_ArgsInfo.pad_arg)); - for (typename SeedsType::const_iterator it = seeds.begin(); it != seeds.end(); ++it) - f->AddSeed(*it); - filter=f; - if(m_Verbose)std::cout<<"Using the connected threshold image filter..."< ImageFilterType; - typename ImageFilterType::Pointer f= ImageFilterType::New(); - - // Radius - typename InputImageType::SizeType size; - if(m_ArgsInfo.radius_given==Dimension) - for (unsigned int i=0; iSetLower(m_ArgsInfo.lower_arg); - f->SetUpper(m_ArgsInfo.upper_arg); - f->SetReplaceValue(static_cast(m_ArgsInfo.pad_arg)); - for (typename SeedsType::const_iterator it = seeds.begin(); it != seeds.end(); ++it) - f->AddSeed(*it); - f->SetRadius(size); - filter=f; - if(m_Verbose)std::cout<<"Using the neighborhood threshold connected image filter..."< ImageFilterType; - typename ImageFilterType::Pointer f= ImageFilterType::New(); - - // Radius - typename InputImageType::SizeType size; - if(m_ArgsInfo.radius_given==Dimension) - for (unsigned int i=0; iSetMultiplier( m_ArgsInfo.multiplier_arg ); - f->SetNumberOfIterations( m_ArgsInfo.multiplier_arg ); - for (typename SeedsType::const_iterator it = seeds.begin(); it != seeds.end(); ++it) - f->AddSeed(*it); - f->SetNumberOfIterations( m_ArgsInfo.iter_arg); - f->SetReplaceValue(static_cast(m_ArgsInfo.pad_arg)); - f->SetInitialNeighborhoodRadius(size[0]); - filter=f; - if(m_Verbose)std::cout<<"Using the confidence threshold connected image filter..."< ImageFilterType; - typename ImageFilterType::Pointer f= ImageFilterType::New(); - - // Radius - typename InputImageType::SizeType size; - if(m_ArgsInfo.radius_given==Dimension) - for (unsigned int i=0; iSetLower(m_ArgsInfo.lower_arg); - f->SetUpper(m_ArgsInfo.upper_arg); - f->SetLowerBorderIsGiven(m_ArgsInfo.adaptLower_flag); - f->SetLowerBorderIsGiven(m_ArgsInfo.adaptUpper_flag); - f->SetReplaceValue(static_cast(m_ArgsInfo.pad_arg)); - f->SetMultiplier(m_ArgsInfo.multiplier_arg); - f->SetMaximumSDIsGiven(m_ArgsInfo.maxSD_given); - if (m_ArgsInfo.maxSD_given) f->SetMaximumSD(m_ArgsInfo.maxSD_arg); - for (typename SeedsType::const_iterator it = seeds.begin(); it != seeds.end(); ++it) - f->AddSeed(*it); - f->SetRadius(size); - filter=f; - if(m_Verbose)std::cout<<"Using the locally adaptive threshold connected image filter..."< ImageFilterType; - typename ImageFilterType::Pointer f= ImageFilterType::New(); - - // // Radius - // typename InputImageType::SizeType size; - // if(m_ArgsInfo.radius_given==Dimension) - // for (unsigned int i=0; iSetVerbose(m_ArgsInfo.verbose_flag); - f->SetLower(m_ArgsInfo.lower_arg); - f->SetUpper(m_ArgsInfo.upper_arg); - f->SetMinimumLowerThreshold(m_ArgsInfo.minLower_arg); - f->SetMaximumUpperThreshold(m_ArgsInfo.maxUpper_arg); - f->SetAdaptLowerBorder(m_ArgsInfo.adaptLower_flag); - f->SetAdaptUpperBorder(m_ArgsInfo.adaptUpper_flag); - f->SetReplaceValue(static_cast(m_ArgsInfo.pad_arg)); - f->SetMultiplier(m_ArgsInfo.multiplier_arg); - f->SetThresholdStepSize(m_ArgsInfo.step_arg); - f->SetMinimumThresholdStepSize(m_ArgsInfo.minStep_arg); - f->SetFullyConnected(m_ArgsInfo.full_flag); - for (typename SeedsType::const_iterator it = seeds.begin(); it != seeds.end(); ++it) - f->AddSeed(*it); - filter=f; - if(m_Verbose)std::cout<<"Using the explosion controlled threshold connected image filter..."<SetInput(input); - filter->Update(); - typename OutputImageType::Pointer output=filter->GetOutput(); - - // Output - typedef itk::ImageFileWriter WriterType; - typename WriterType::Pointer writer = WriterType::New(); - writer->SetFileName(m_ArgsInfo.output_arg); - writer->SetInput(output); - writer->Update(); - } - -}//end clitk - -#endif //#define clitkRegionGrowingGenericFilter_txx -- 2.47.1