1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef __clitkLocallyAdaptiveThresholdConnectedImageFilter_h
19 #define __clitkLocallyAdaptiveThresholdConnectedImageFilter_h
21 #include "itkImageToImageFilter.h"
25 /** \class LocallyAdaptiveThresholdConnectedImageFilter
26 * \brief Label pixels that are connected to a seed and lie within a neighborhood
28 * LocallyAdaptiveThresholdConnectedImageFilter labels pixels with ReplaceValue that
29 * are connected to an initial Seed AND whose neighbors all lie within a
30 * Lower and Upper threshold range.
32 * \ingroup RegionGrowingSegmentation
34 template <class TInputImage, class TOutputImage>
35 class ITK_EXPORT LocallyAdaptiveThresholdConnectedImageFilter:
36 public itk::ImageToImageFilter<TInputImage,TOutputImage>
39 /** Standard class typedefs. */
40 typedef LocallyAdaptiveThresholdConnectedImageFilter Self;
41 typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass;
42 typedef itk::SmartPointer<Self> Pointer;
43 typedef itk::SmartPointer<const Self> ConstPointer;
45 /** Method for creation through the object factory. */
48 /** Run-time type information (and related methods). */
49 itkTypeMacro(LocallyAdaptiveThresholdConnectedImageFilter,
52 typedef TInputImage InputImageType;
53 typedef typename InputImageType::Pointer InputImagePointer;
54 typedef typename InputImageType::RegionType InputImageRegionType;
55 typedef typename InputImageType::PixelType InputImagePixelType;
56 typedef typename InputImageType::IndexType IndexType;
57 typedef typename InputImageType::SizeType InputImageSizeType;
59 typedef TOutputImage OutputImageType;
60 typedef typename OutputImageType::Pointer OutputImagePointer;
61 typedef typename OutputImageType::RegionType OutputImageRegionType;
62 typedef typename OutputImageType::PixelType OutputImagePixelType;
64 void PrintSelf ( std::ostream& os, itk::Indent indent ) const;
66 /** Clear the seeds */
69 /** Set seed point. */
70 void SetSeed(const IndexType & seed);
72 /** Add a seed point */
73 void AddSeed ( const IndexType & seed );
75 // Set/Get the lower threshold. The default is 0.
76 itkSetMacro(Lower, InputImagePixelType);
77 itkGetConstMacro(Lower, InputImagePixelType);
79 // Set/Get the upper threshold. The default is the largest possible value for the InputPixelType.
80 itkSetMacro(Upper, InputImagePixelType);
81 itkGetConstMacro(Upper, InputImagePixelType);
83 /** Set/Get value to replace thresholded pixels. Pixels that lie *
84 * within Lower and Upper (inclusive) will be replaced with this
85 * value. The default is 1. */
86 itkSetMacro(ReplaceValue, OutputImagePixelType);
87 itkGetConstMacro(ReplaceValue, OutputImagePixelType);
89 /** Set the radius of the neighborhood used for a mask. */
90 itkSetMacro(Radius, InputImageSizeType);
92 /** Get the radius of the neighborhood used to compute the median */
93 itkGetConstReferenceMacro(Radius, InputImageSizeType);
95 /** ImageDimension constants */
96 itkStaticConstMacro(InputImageDimension, unsigned int,
97 TInputImage::ImageDimension);
98 itkStaticConstMacro(OutputImageDimension, unsigned int,
99 TOutputImage::ImageDimension);
101 #ifdef ITK_USE_CONCEPT_CHECKING
102 /** Begin concept checking */
103 itkConceptMacro(InputEqualityComparableCheck,
104 (itk::Concept::EqualityComparable<InputImagePixelType>));
105 itkConceptMacro(OutputEqualityComparableCheck,
106 (itk::Concept::EqualityComparable<OutputImagePixelType>));
107 itkConceptMacro(SameDimensionCheck,
108 (itk::Concept::SameDimension<InputImageDimension, OutputImageDimension>));
109 itkConceptMacro(InputOStreamWritableCheck,
110 (itk::Concept::OStreamWritable<InputImagePixelType>));
111 itkConceptMacro(OutputOStreamWritableCheck,
112 (itk::Concept::OStreamWritable<OutputImagePixelType>));
113 /** End concept checking */
117 itkBooleanMacro(LowerBorderIsGiven);
118 itkSetMacro( LowerBorderIsGiven, bool);
119 itkGetConstReferenceMacro( LowerBorderIsGiven, bool);
120 itkBooleanMacro(UpperBorderIsGiven);
121 itkSetMacro( UpperBorderIsGiven, bool);
122 itkGetConstReferenceMacro( UpperBorderIsGiven, bool);
123 itkSetMacro( Multiplier, double);
124 itkGetConstMacro( Multiplier, double);
125 itkBooleanMacro(MaximumSDIsGiven);
126 itkSetMacro( MaximumSDIsGiven, bool);
127 itkGetConstReferenceMacro( MaximumSDIsGiven, bool);
128 itkSetMacro( MaximumSD, double);
129 itkGetConstMacro( MaximumSD, double);
132 LocallyAdaptiveThresholdConnectedImageFilter();
133 ~LocallyAdaptiveThresholdConnectedImageFilter(){};
134 std::vector<IndexType> m_Seeds;
135 InputImagePixelType m_Lower;
136 InputImagePixelType m_Upper;
137 OutputImagePixelType m_ReplaceValue;
138 InputImageSizeType m_Radius;
141 bool m_LowerBorderIsGiven;
142 bool m_UpperBorderIsGiven;
143 bool m_MaximumSDIsGiven;
147 // Override since the filter needs all the data for the algorithm
148 void GenerateInputRequestedRegion();
150 // Override since the filter produces the entire dataset
151 void EnlargeOutputRequestedRegion(itk::DataObject *output);
155 LocallyAdaptiveThresholdConnectedImageFilter(const Self&); //purposely not implemented
156 void operator=(const Self&); //purposely not implemented
160 } // end namespace clitk
162 #ifndef ITK_MANUAL_INSTANTIATION
163 #include "clitkLocallyAdaptiveThresholdConnectedImageFilter.txx"