ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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
168 using RegionType = typename InputImageType::RegionType;
169 using SizeType = typename InputImageType::SizeType;
170 using IndexType = typename InputImageType::IndexType;
171
174
176 using ScalarType = typename InputImageType::PixelType;
177
180
182 itkOverrideGetNameOfClassMacro(WatershedImageFilter);
183
185 itkNewMacro(Self);
186
188 void
189 GenerateData() override;
190
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 }
204
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 }
244
245
249 {
250 return m_TreeGenerator->GetOutputSegmentTree();
251 }
252
253 // Override since the filter produces all of its output
254 void
256
257 itkConceptMacro(InputEqualityComparableCheck, (Concept::EqualityComparable<ScalarType>));
258 itkConceptMacro(InputAdditiveOperatorsCheck, (Concept::AdditiveOperators<ScalarType>));
260 itkConceptMacro(InputLessThanComparableCheck, (Concept::LessThanComparable<ScalarType>));
261
262protected:
264 ~WatershedImageFilter() override = default;
265 void
266 PrintSelf(std::ostream & os, Indent indent) const override;
267
270 void
271 PrepareOutputs() override;
272
273private:
277 double m_Threshold{ 0.0 };
278
283 double m_Level{ 0.0 };
284
290
292
294
295 unsigned long m_ObserverTag{};
296
300
302};
303} // end namespace itk
304
305#ifndef ITK_MANUAL_INSTANTIATION
306# include "itkWatershedImageFilter.hxx"
307#endif
308
309#endif
Base class for all data objects in ITK.
virtual void SetInput(const InputImageType *input)
const InputImageType * GetInput() const
Templated n-dimensional image class.
Definition itkImage.h:89
Control indentation during Print() invocation.
Definition itkIndent.h:50
virtual void SetNthInput(DataObjectPointerArraySizeType idx, DataObject *input)
Implements transparent reference counting.
Generate a unique, increasing time value.
typename InputImageType::IndexType IndexType
void SetInput(const InputImageType *input) override
watershed::SegmentTreeGenerator< ScalarType >::SegmentTreeType * GetSegmentTree()
watershed::SegmentTreeGenerator< ScalarType >::Pointer m_TreeGenerator
void GenerateData() override
void PrintSelf(std::ostream &os, Indent indent) const override
ImageToImageFilter< InputImageType, OutputImageType > Superclass
typename InputImageType::PixelType ScalarType
watershed::Relabeler< ScalarType, Self::ImageDimension >::Pointer m_Relabeler
void SetInput(unsigned int i, const TInputImage *image) override
void PrepareOutputs() override
watershed::Segmenter< InputImageType >::Pointer m_Segmenter
void EnlargeOutputRequestedRegion(DataObject *data) override
~WatershedImageFilter() override=default
Image< IdentifierType, Self::ImageDimension > OutputImageType
watershed::Segmenter< InputImageType >::OutputImageType * GetBasicSegmentation()
typename InputImageType::RegionType RegionType
Image< IdentifierType, Self::ImageDimension > OutputImageType
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....