X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=segmentation%2FclitkExtractLungFilter.h;h=3183457dde0a6eb7ff06d445670cb132523a2ae8;hb=5668d4a49a5a6b68dc80fa28f0f82b54187cb70c;hp=781a885f67eca478cb989b347696eee61a67434b;hpb=c8d53d40ac8f5f83843193c51ac1787a8f38ee90;p=clitk.git diff --git a/segmentation/clitkExtractLungFilter.h b/segmentation/clitkExtractLungFilter.h index 781a885..3183457 100644 --- a/segmentation/clitkExtractLungFilter.h +++ b/segmentation/clitkExtractLungFilter.h @@ -24,6 +24,7 @@ #include "clitkDecomposeAndReconstructImageFilter.h" #include "clitkExplosionControlledThresholdConnectedImageFilter.h" #include "clitkSegmentationUtils.h" +#include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h" // itk #include "itkStatisticsImageFilter.h" @@ -54,15 +55,18 @@ namespace clitk { */ //-------------------------------------------------------------------- - template + //-------------------------------------------------------------------- + template class ITK_EXPORT ExtractLungFilter: - public clitk::FilterBase, - public itk::ImageToImageFilter + public virtual clitk::FilterBase, + public clitk::FilterWithAnatomicalFeatureDatabaseManagement, + public itk::ImageToImageFilter > { public: /** Standard class typedefs. */ - typedef itk::ImageToImageFilter Superclass; + typedef itk::Image MaskImageType; + typedef itk::ImageToImageFilter Superclass; typedef ExtractLungFilter Self; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; @@ -75,36 +79,45 @@ namespace clitk { FILTERBASE_INIT; /** Some convenient typedefs */ - typedef TInputImageType InputImageType; - typedef typename InputImageType::ConstPointer InputImageConstPointer; - typedef typename InputImageType::Pointer InputImagePointer; - typedef typename InputImageType::RegionType InputImageRegionType; - typedef typename InputImageType::PixelType InputImagePixelType; - typedef typename InputImageType::SizeType InputImageSizeType; - typedef typename InputImageType::IndexType InputImageIndexType; + typedef TImageType ImageType; + typedef typename ImageType::ConstPointer InputImageConstPointer; + typedef typename ImageType::Pointer InputImagePointer; + typedef typename ImageType::RegionType InputImageRegionType; + typedef typename ImageType::PixelType InputImagePixelType; + typedef typename ImageType::SizeType InputImageSizeType; + typedef typename ImageType::IndexType InputImageIndexType; + typedef typename ImageType::PointType InputImagePointType; - typedef TMaskImageType MaskImageType; typedef typename MaskImageType::ConstPointer MaskImageConstPointer; typedef typename MaskImageType::Pointer MaskImagePointer; typedef typename MaskImageType::RegionType MaskImageRegionType; typedef typename MaskImageType::PixelType MaskImagePixelType; typedef typename MaskImageType::SizeType MaskImageSizeType; typedef typename MaskImageType::IndexType MaskImageIndexType; + typedef typename MaskImageType::PointType MaskImagePointType; - itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension); + itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension); typedef int InternalPixelType; - typedef itk::Image InternalImageType; - typedef typename InternalImageType::Pointer InternalImagePointer; - typedef typename InternalImageType::IndexType InternalIndexType; - typedef LabelizeParameters LabelParamType; + typedef itk::Image InternalImageType; + typedef typename InternalImageType::Pointer InternalImagePointer; + typedef typename InternalImageType::IndexType InternalIndexType; + typedef LabelizeParameters LabelParamType; /** Connect inputs */ - void SetInput(const InputImageType * image); - void SetInputPatientMask(MaskImageType * mask, MaskImagePixelType BG); + void SetInput(const ImageType * image); itkSetMacro(PatientMaskBackgroundValue, MaskImagePixelType); itkGetConstMacro(PatientMaskBackgroundValue, MaskImagePixelType); GGO_DefineOption(patientBG, SetPatientMaskBackgroundValue, MaskImagePixelType); + // Output filename (for AFBD) + itkSetMacro(OutputLungFilename, std::string); + itkGetMacro(OutputLungFilename, std::string); + GGO_DefineOption(output, SetOutputLungFilename, std::string); + + itkSetMacro(OutputTracheaFilename, std::string); + itkGetMacro(OutputTracheaFilename, std::string); + GGO_DefineOption(outputTrachea, SetOutputTracheaFilename, std::string); + // Set all options at a time template void SetArgsInfo(ArgsInfoType arg); @@ -126,6 +139,10 @@ namespace clitk { itkGetConstMacro(UpperThreshold, InputImagePixelType); GGO_DefineOption(upper, SetUpperThreshold, InputImagePixelType); + itkSetMacro(NumberOfSlicesToSkipBeforeSearchingSeed, int); + itkGetConstMacro(NumberOfSlicesToSkipBeforeSearchingSeed, int); + GGO_DefineOption(skipslices, SetNumberOfSlicesToSkipBeforeSearchingSeed, int); + itkSetMacro(LowerThreshold, InputImagePixelType); itkGetConstMacro(LowerThreshold, InputImagePixelType); itkSetMacro(UseLowerThreshold, bool); @@ -152,7 +169,7 @@ namespace clitk { void AddSeed(InternalIndexType s); std::vector & GetSeeds() { return m_Seeds; } - GGO_DefineOption_Vector(seed, AddSeed, InternalIndexType, InputImageType::ImageDimension, true); + GGO_DefineOption_Vector(seed, AddSeed, InternalIndexType, ImageType::ImageDimension, true); // Step 3 options ExtractLung itkSetMacro(NumberOfHistogramBins, int); @@ -172,17 +189,38 @@ namespace clitk { itkGetConstMacro(LabelizeParameters3, LabelParamType*); GGO_DefineOption_LabelParam(3, SetLabelizeParameters3, LabelParamType); - // Step 5 options LungSeparation - // itkSetMacro(FinalOpenClose, bool); - // itkGetConstMacro(FinalOpenClose, bool); - // itkBooleanMacro(FinalOpenClose); + // Step 5 final openclose + itkSetMacro(OpenClose, bool); + itkGetConstMacro(OpenClose, bool); + itkBooleanMacro(OpenClose); + GGO_DefineOption_Flag(openclose, SetOpenClose); - // virtual void Update(); + itkSetMacro(OpenCloseRadius, int); + itkGetConstMacro(OpenCloseRadius, int); + GGO_DefineOption(opencloseRadius, SetOpenCloseRadius, int); + + // Step 6 fill holes + itkSetMacro(FillHoles, bool); + itkGetConstMacro(FillHoles, bool); + itkBooleanMacro(FillHoles); + GGO_DefineOption_Flag(doNotFillHoles, SetFillHoles); protected: ExtractLungFilter(); virtual ~ExtractLungFilter() {} - + + // Main members + InputImageConstPointer input; + MaskImageConstPointer patient; + InputImagePointer working_input; + std::string m_OutputLungFilename; + std::string m_OutputTracheaFilename; + typename InternalImageType::Pointer working_image; + typename InternalImageType::Pointer trachea_tmp; + MaskImagePointer trachea; + MaskImagePointer output; + unsigned int m_MaxSeedNumber; + // Global options itkSetMacro(BackgroundValue, MaskImagePixelType); itkSetMacro(ForegroundValue, MaskImagePixelType); @@ -202,6 +240,7 @@ namespace clitk { InputImagePixelType m_ThresholdStepSizeForTrachea; double m_MultiplierForTrachea; std::vector m_Seeds; + int m_NumberOfSlicesToSkipBeforeSearchingSeed; // Step 3 int m_NumberOfHistogramBins; @@ -212,24 +251,23 @@ namespace clitk { LabelParamType* m_LabelizeParameters3; // Step 5 - // bool m_FinalOpenClose; - + bool m_OpenClose; + int m_OpenCloseRadius; + + // Step 6 + bool m_FillHoles; + InputImageSizeType m_FillHolesDirections; + + // Main functions virtual void GenerateOutputInformation(); virtual void GenerateData(); + + // Functions for trachea extraction + bool SearchForTracheaSeed(int skip); + void SearchForTrachea(); + void TracheaRegionGrowing(); + double ComputeTracheaVolume(); - // Steps - void RemoveAir(); - void FindTrachea(); - void ExtractLung(); - void RemoveTrachea(); - void LungSeparation(); - InputImageConstPointer input; - MaskImageConstPointer patient; - InputImagePointer working_input; - typename InternalImageType::Pointer working_image; - typename InternalImageType::Pointer trachea_tmp; - MaskImagePointer trachea; - private: ExtractLungFilter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented