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::watershed
27{
86template <typename TInputImage>
87class ITK_TEMPLATE_EXPORT Segmenter : public ProcessObject
88{
89public:
91 using Self = Segmenter;
92
94 using InputImageType = TInputImage;
95 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
96
105
112 itkNewMacro(Self);
113 itkOverrideGetNameOfClassMacro(Segmenter);
115
121
123 static constexpr IdentifierType NULL_LABEL = 0;
124
126 static constexpr short NULL_FLOW = -1;
127
134
135 void
137 {
138 this->ProcessObject::SetNthInput(0, img);
139 }
140
143 OutputImageType *
148
149 void
151 {
152 this->ProcessObject::SetNthOutput(0, img);
153 }
154
157 SegmentTableType *
162
163 void
168
171 BoundaryType *
176
177 void
179 {
180 this->ProcessObject::SetNthOutput(2, b);
181 }
182
184 void
185 GenerateData() override;
186
194 void
196 {
197 if (reg == m_LargestPossibleRegion)
198 {
199 return;
200 }
202 this->Modified();
203 }
204
205 ImageRegionType
207 {
209 }
210
211
215
221
225 itkSetMacro(CurrentLabel, IdentifierType);
226 itkGetConstMacro(CurrentLabel, IdentifierType);
228
240 itkSetClampMacro(Threshold, double, 0.0, 1.0);
241 itkGetConstMacro(Threshold, double);
243
248 itkSetMacro(DoBoundaryAnalysis, bool);
249 itkGetConstMacro(DoBoundaryAnalysis, bool);
251
257 itkGetConstMacro(SortEdgeLists, bool);
258 itkSetMacro(SortEdgeLists, bool);
260protected:
264 {
267 // InputPixelType bounds_max; // <-- may not be necc.
269 bool is_on_boundary{ false };
270 flat_region_t() = default;
271 };
272
274 using flat_region_table_t = std::unordered_map<IdentifierType, flat_region_t>;
275
277 {
278 unsigned int size;
279 unsigned int * index;
280 typename InputImageType::OffsetType * direction;
281 };
282
287 using edge_table_t = std::map<IdentifierType, InputPixelType>;
288
289 using edge_table_hash_t = std::unordered_map<IdentifierType, edge_table_t>;
290
292 Segmenter(const Self &) {}
293 ~Segmenter() override;
294 void
295 PrintSelf(std::ostream & os, Indent indent) const override;
296
297 void
299 {}
300
303 virtual void
305
309 void
311
312 void
314
315 void
317
320 void
322
326 void
328
333
336 void
338
343
346 void
348
352
356 void
358
364 static void
367 const ImageRegionType source_region,
368 const ImageRegionType destination_region,
369 InputPixelType threshold);
370
372 static void
374
376 static void
378
380 static void
382
383 static void
385
387 // bool CheckLabeledBoundaries();
388
391 connectivity_t m_Connectivity{};
392
393private:
395 // void PrintFlatRegions(flat_region_table_t &t);
396
401
404 double m_Threshold{};
407};
408} // namespace itk::watershed
409
410#ifndef ITK_MANUAL_INSTANTIATION
411# include "itkWatershedSegmenter.hxx"
412#endif
413
414#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
SizeValueType IdentifierType
Definition itkIntTypes.h:90
TTarget itkDynamicCastInDebugMode(TSource x)