ITK  6.0.0
Insight Toolkit
itkWatershedImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkWatershedImageFilter_h
19#define itkWatershedImageFilter_h
20
21
26
27namespace itk
28{
148template <typename TInputImage>
149class ITK_TEMPLATE_EXPORT WatershedImageFilter
150 : public ImageToImageFilter<TInputImage, Image<IdentifierType, TInputImage::ImageDimension>>
151{
152public:
153 ITK_DISALLOW_COPY_AND_MOVE(WatershedImageFilter);
154
157
159 using InputImageType = TInputImage;
160
162 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
163
166
171
174
176 using ScalarType = typename InputImageType::PixelType;
177
180
182 itkOverrideGetNameOfClassMacro(WatershedImageFilter);
183
185 itkNewMacro(Self);
186
188 void
189 GenerateData() override;
190
193 using Superclass::SetInput;
194 void
195 SetInput(const InputImageType * input) override
196 {
197 // if the input is changed, we'll need to clear the cached tree
198 // when we execute
199 if (input != this->GetInput(0))
200 {
201 m_InputChanged = true;
202 }
205 // processObject is not const-correct so a const_cast is needed here
206 this->ProcessObject::SetNthInput(0, const_cast<InputImageType *>(input));
207 m_Segmenter->SetInputImage(const_cast<InputImageType *>(input));
208 }
209
210 void
211 SetInput(unsigned int i, const TInputImage * image) override
212 {
213 if (i != 0)
214 {
215 itkExceptionMacro("Filter has only one input.");
216 }
217 else
218 {
219 this->SetInput(image);
220 }
221 }
222
225 void
227
228 itkGetConstMacro(Threshold, double);
229
232 void
233 SetLevel(double);
234
235 itkGetConstMacro(Level, double);
236
240 {
241 m_Segmenter->Update();
242 return m_Segmenter->GetOutputImage();
243 }
249 {
250 return m_TreeGenerator->GetOutputSegmentTree();
251 }
252
253 // Override since the filter produces all of its output
254 void
256
257#ifdef ITK_USE_CONCEPT_CHECKING
258 // Begin concept checking
259 itkConceptMacro(InputEqualityComparableCheck, (Concept::EqualityComparable<ScalarType>));
260 itkConceptMacro(InputAdditiveOperatorsCheck, (Concept::AdditiveOperators<ScalarType>));
262 itkConceptMacro(InputLessThanComparableCheck, (Concept::LessThanComparable<ScalarType>));
263 // End concept checking
264#endif
265
266protected:
268 ~WatershedImageFilter() override = default;
269 void
270 PrintSelf(std::ostream & os, Indent indent) const override;
271
274 void
275 PrepareOutputs() override;
276
277private:
281 double m_Threshold{ 0.0 };
282
287 double m_Level{ 0.0 };
288
294
296
298
299 unsigned long m_ObserverTag{};
300
301 bool m_LevelChanged{};
302 bool m_ThresholdChanged{};
303 bool m_InputChanged{};
304
305 TimeStamp m_GenerateDataMTime{};
306};
307} // end namespace itk
308
309#ifndef ITK_MANUAL_INSTANTIATION
310# include "itkWatershedImageFilter.hxx"
311#endif
312
313#endif
Base class for all data objects in ITK.
Base class for filters that take an image as input and produce an image as output.
Templated n-dimensional image class.
Definition: itkImage.h:89
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
virtual void Update()
Bring this filter up-to-date.
virtual void SetNthInput(DataObjectPointerArraySizeType idx, DataObject *input)
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:61
A low-level image analysis algorithm that automatically produces a hierarchy of segmented,...
typename InputImageType::IndexType IndexType
void SetInput(const InputImageType *input) override
watershed::SegmentTreeGenerator< ScalarType >::SegmentTreeType * GetSegmentTree()
void GenerateData() override
void PrintSelf(std::ostream &os, Indent indent) const override
typename InputImageType::PixelType ScalarType
typename InputImageType::SizeType SizeType
void SetInput(unsigned int i, const TInputImage *image) override
void PrepareOutputs() override
void EnlargeOutputRequestedRegion(DataObject *data) override
~WatershedImageFilter() override=default
watershed::Segmenter< InputImageType >::OutputImageType * GetBasicSegmentation()
typename InputImageType::RegionType RegionType
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....