ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkWatershedSegmenter.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 itkWatershedSegmenter_h
19#define itkWatershedSegmenter_h
20
21
24#include "itkEquivalencyTable.h"
25
26namespace itk
27{
28namespace watershed
29{
88template <typename TInputImage>
89class ITK_TEMPLATE_EXPORT Segmenter : public ProcessObject
90{
91public:
92
94 using Self = Segmenter;
95
97 using InputImageType = TInputImage;
98 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
99
108
114 itkNewMacro(Self);
115 itkOverrideGetNameOfClassMacro(Segmenter);
117
123
125 static constexpr IdentifierType NULL_LABEL = 0;
126
128 static constexpr short NULL_FLOW = -1;
129
136
137 void
139 {
140 this->ProcessObject::SetNthInput(0, img);
141 }
142
145 OutputImageType *
150
151 void
153 {
154 this->ProcessObject::SetNthOutput(0, img);
155 }
156
159 SegmentTableType *
164
165 void
170
173 BoundaryType *
178
179 void
181 {
182 this->ProcessObject::SetNthOutput(2, b);
183 }
184
186 void
187 GenerateData() override;
188
195 void
197 {
198 if (reg == m_LargestPossibleRegion)
199 {
200 return;
201 }
203 this->Modified();
204 }
205
206
207 ImageRegionType
209 {
211 }
212
216
222
225 itkSetMacro(CurrentLabel, IdentifierType);
226 itkGetConstMacro(CurrentLabel, IdentifierType);
228
239 itkSetClampMacro(Threshold, double, 0.0, 1.0);
240 itkGetConstMacro(Threshold, double);
242
246 itkSetMacro(DoBoundaryAnalysis, bool);
247 itkGetConstMacro(DoBoundaryAnalysis, bool);
249
254 itkGetConstMacro(SortEdgeLists, bool);
255 itkSetMacro(SortEdgeLists, bool);
257
258protected:
262 {
265 // InputPixelType bounds_max; // <-- may not be necc.
267 bool is_on_boundary{ false };
268 flat_region_t() = default;
269 };
270
272 using flat_region_table_t = std::unordered_map<IdentifierType, flat_region_t>;
273
275 {
276 unsigned int size;
277 unsigned int * index;
278 typename InputImageType::OffsetType * direction;
279 };
280
285 using edge_table_t = std::map<IdentifierType, InputPixelType>;
286
287 using edge_table_hash_t = std::unordered_map<IdentifierType, edge_table_t>;
288
290 Segmenter(const Self &) {}
291 ~Segmenter() override;
292 void
293 PrintSelf(std::ostream & os, Indent indent) const override;
294
295 void
297 {}
298
301 virtual void
303
307 void
309
310 void
312
313 void
315
318 void
320
324 void
326
331
334 void
336
341
344 void
346
350
354 void
356
362 static void
365 const ImageRegionType source_region,
366 const ImageRegionType destination_region,
367 InputPixelType threshold);
368
370 static void
372
374 static void
376
378 static void
380
381 static void
383
385 // bool CheckLabeledBoundaries();
386
389 connectivity_t m_Connectivity{};
390
391private:
393 // void PrintFlatRegions(flat_region_table_t &t);
394
399
402 double m_Threshold{};
405};
406} // end namespace watershed
407} // end namespace itk
408
409#ifndef ITK_MANUAL_INSTANTIATION
410# include "itkWatershedSegmenter.hxx"
411#endif
412
413#endif
SmartPointer< Self > Pointer
SmartPointer< Self > Pointer
Templated n-dimensional image class.
Definition itkImage.h:89
ImageRegion< VImageDimension > RegionType
TPixel PixelType
Definition itkImage.h:108
SmartPointer< Self > Pointer
Definition itkImage.h:96
Control indentation during Print() invocation.
Definition itkIndent.h:50
virtual void Modified() const
DataObject * GetOutput(const DataObjectIdentifierType &key)
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
virtual void SetNthInput(DataObjectPointerArraySizeType idx, DataObject *input)
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
virtual void SetNthOutput(DataObjectPointerArraySizeType idx, DataObject *output)
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx)
Make a DataObject of the correct type to used as the specified output.
Implements transparent reference counting.
static void MinMax(InputImageTypePointer img, ImageRegionType region, InputPixelType &min, InputPixelType &max)
void DescendFlatRegions(flat_region_table_t &, ImageRegionType)
void PrintSelf(std::ostream &os, Indent indent) const override
SegmentTableType * GetSegmentTable()
void GradientDescent(InputImageTypePointer, ImageRegionType)
std::unordered_map< IdentifierType, edge_table_t > edge_table_hash_t
Image< IdentifierType, Self::ImageDimension > OutputImageType
Boundary< InputPixelType, Self::ImageDimension > BoundaryType
void SetBoundary(BoundaryType *b)
ImageRegionType GetLargestPossibleRegion() const
static void SetInputImageValues(InputImageTypePointer img, const ImageRegionType region, InputPixelType value)
void SetInputImage(InputImageType *img)
void SetLargestPossibleRegion(ImageRegionType reg)
void LabelMinima(InputImageTypePointer, ImageRegionType, flat_region_table_t &, InputPixelType)
static void Threshold(InputImageTypePointer destination, InputImageTypePointer source, const ImageRegionType source_region, const ImageRegionType destination_region, InputPixelType threshold)
void UpdateOutputInformation() override
Update the information describing the output data.
static void SetOutputImageValues(OutputImageTypePointer img, const ImageRegionType region, IdentifierType value)
void UpdateSegmentTable(InputImageTypePointer, ImageRegionType)
std::unordered_map< IdentifierType, flat_region_t > flat_region_table_t
void BuildRetainingWall(InputImageTypePointer, ImageRegionType, InputPixelType)
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
Make a DataObject of the correct type to used as the specified output.
virtual void GenerateConnectivity()
static void RelabelImage(OutputImageTypePointer, ImageRegionType, EquivalencyTable::Pointer)
void GenerateOutputRequestedRegion(DataObject *output) override
typename BoundaryType::FlatHashValueType BoundaryFlatHashValueType
void CollectBoundaryInformation(flat_region_table_t &)
void AnalyzeBoundaryFlow(InputImageTypePointer, flat_region_table_t &, InputPixelType)
void SetSegmentTable(SegmentTableType *s)
void GenerateInputRequestedRegion() override
ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
static void MergeFlatRegions(flat_region_table_t &, EquivalencyTable::Pointer)
void SetOutputImage(OutputImageType *img)
void GenerateData() override
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
SizeValueType IdentifierType
Definition itkIntTypes.h:90
TTarget itkDynamicCastInDebugMode(TSource x)