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:
93 using Self = Segmenter;
94
96 using InputImageType = TInputImage;
97 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
98
107
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
196 void
198 {
199 if (reg == m_LargestPossibleRegion)
200 {
201 return;
202 }
204 this->Modified();
205 }
206
207 ImageRegionType
209 {
211 }
212
213
217
223
227 itkSetMacro(CurrentLabel, IdentifierType);
228 itkGetConstMacro(CurrentLabel, IdentifierType);
230
242 itkSetClampMacro(Threshold, double, 0.0, 1.0);
243 itkGetConstMacro(Threshold, double);
245
250 itkSetMacro(DoBoundaryAnalysis, bool);
251 itkGetConstMacro(DoBoundaryAnalysis, bool);
253
259 itkGetConstMacro(SortEdgeLists, bool);
260 itkSetMacro(SortEdgeLists, bool);
262protected:
266 {
269 // InputPixelType bounds_max; // <-- may not be necc.
271 bool is_on_boundary{ false };
272 flat_region_t() = default;
273 };
274
276 using flat_region_table_t = std::unordered_map<IdentifierType, flat_region_t>;
277
279 {
280 unsigned int size;
281 unsigned int * index;
282 typename InputImageType::OffsetType * direction;
283 };
284
289 using edge_table_t = std::map<IdentifierType, InputPixelType>;
290
291 using edge_table_hash_t = std::unordered_map<IdentifierType, edge_table_t>;
292
294 Segmenter(const Self &) {}
295 ~Segmenter() override;
296 void
297 PrintSelf(std::ostream & os, Indent indent) const override;
298
299 void
301 {}
302
305 virtual void
307
311 void
313
314 void
316
317 void
319
322 void
324
328 void
330
335
338 void
340
345
348 void
350
354
358 void
360
366 static void
369 const ImageRegionType source_region,
370 const ImageRegionType destination_region,
371 InputPixelType threshold);
372
374 static void
376
378 static void
380
382 static void
384
385 static void
387
389 // bool CheckLabeledBoundaries();
390
393 connectivity_t m_Connectivity{};
394
395private:
397 // void PrintFlatRegions(flat_region_table_t &t);
398
403
406 double m_Threshold{};
409};
410} // end namespace watershed
411} // end namespace itk
412
413#ifndef ITK_MANUAL_INSTANTIATION
414# include "itkWatershedSegmenter.hxx"
415#endif
416
417#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)