ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkVoronoiSegmentationImageFilterBase.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 itkVoronoiSegmentationImageFilterBase_h
19#define itkVoronoiSegmentationImageFilterBase_h
20
23#include "itkImage.h"
24
25namespace itk
26{
55template <typename TInputImage, typename TOutputImage, typename TBinaryPriorImage = Image<unsigned char, 2>>
56class ITK_TEMPLATE_EXPORT VoronoiSegmentationImageFilterBase : public ImageToImageFilter<TInputImage, TOutputImage>
57{
58public:
59 ITK_DISALLOW_COPY_AND_MOVE(VoronoiSegmentationImageFilterBase);
60
66
68 itkNewMacro(Self);
69
71 itkOverrideGetNameOfClassMacro(VoronoiSegmentationImageFilterBase);
72
74 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
75
77 using InputImageType = TInputImage;
78 using InputImagePointer = typename TInputImage::Pointer;
79 using InputImageConstPointer = typename TInputImage::ConstPointer;
80 using IndexType = typename TInputImage::IndexType;
81 using SizeType = typename TInputImage::SizeType;
82 using RegionType = typename TInputImage::RegionType;
83 using PixelType = typename TInputImage::PixelType;
84
85 using OutputImageType = TOutputImage;
86 using OutputPixelType = typename TOutputImage::PixelType;
87
94 using PointIdIterator = typename CellType::PointIdIterator;
99 using EdgeInfo = typename VoronoiDiagram::VoronoiEdge;
100 using PointTypeVector = std::vector<PointType>;
101 using PointTypeDeque = std::deque<PointType>;
102 using BinaryObjectImage = TBinaryPriorImage;
103 using BinaryObjectImagePointer = typename BinaryObjectImage::Pointer;
104 using IndexList = std::vector<IndexType>;
105
109
111 itkSetMacro(NumberOfSeeds, int);
112 itkGetConstMacro(NumberOfSeeds, int);
114
116 itkSetMacro(MinRegion, SizeValueType);
117 itkGetConstMacro(MinRegion, SizeValueType);
119
122 itkSetMacro(Steps, int);
123 itkGetConstMacro(Steps, int);
125
127 itkGetConstMacro(LastStepSeeds, int);
128
130 itkGetConstMacro(NumberOfSeedsToAdded, int);
131
133 itkSetMacro(UseBackgroundInAPrior, bool);
134 itkGetConstMacro(UseBackgroundInAPrior, bool);
136
138 itkSetMacro(OutputBoundary, bool);
139 itkGetConstMacro(OutputBoundary, bool);
141
144 itkSetMacro(InteractiveSegmentation, bool);
145 itkGetConstMacro(InteractiveSegmentation, bool);
146 itkBooleanMacro(InteractiveSegmentation);
148
150 itkSetMacro(MeanDeviation, double);
151 itkGetConstMacro(MeanDeviation, double);
153
155 itkSetMacro(Size, SizeType);
156 itkGetConstMacro(Size, SizeType);
158
161 virtual void
164
166 void
168
170 void
172
174 virtual void
176
177 virtual void
179
183 {
184 return m_WorkingVD;
185 }
186
187#if !defined(ITK_WRAPPING_PARSER) // generates invalid iterator instantiation
188 // with msvc
192 void
193 SetSeeds(int num, SeedsIterator begin)
194 {
195 m_NumberOfSeeds = num;
196 m_WorkingVD->SetSeeds(num, begin);
197 }
198
199
200#endif
201
205 void
207 {
208 m_NumberOfSeeds = seeds.size();
209 auto it = seeds.begin();
210 m_WorkingVD->SetSeeds(m_NumberOfSeeds, it);
211 }
212
213
215 PointType
216 GetSeed(int SeedID)
217 {
218 return m_WorkingVD->GetSeed(SeedID);
219 }
220
222 void
223 DrawDiagram(VDImagePointer result, unsigned char incolor, unsigned char outcolor, unsigned char boundcolor);
224
225 void
227
230 void
232
235 void
237
238protected:
241 void
242 PrintSelf(std::ostream & os, Indent indent) const override;
243
244 void
245 GenerateData() override; // general pipeline function.
246
248 int m_NumberOfSeeds{ 200 };
250 int m_Steps{ 0 };
254
255 std::vector<SizeValueType> m_NumberOfPixels{};
256 std::vector<unsigned char> m_Label{};
257
258 double m_MeanDeviation{ 0.8 };
260 bool m_OutputBoundary{ false }; // if =1 then output the boundaries, if = 0 then
261 // output the object.
263
265
267
268 std::vector<PointType> m_SeedsToAdded{};
269
270 // private methods:
271 // Classify all the voronoi cells as interior , exterior or boundary.
272 virtual void
274
275 // Generate the seeds to be added by dividing the boundary cells.
276 virtual void
278
279 // Compute the statistics of the pixels inside the cell.
280 void
282
283 virtual bool
285 {
286 return true;
287 }
288
289 void
291
292 // Draw a straight line to the output image.
293 void
295
296 // Draw the intermediate Voronoi Diagram structure.
297 void
298 drawVDline(VDImagePointer result, PointType p1, PointType p2, unsigned char color);
299};
300} // namespace itk
301
302#ifndef ITK_MANUAL_INSTANTIATION
303# include "itkVoronoiSegmentationImageFilterBase.hxx"
304#endif
305
306#endif
Base class for all data objects in ITK.
Templated n-dimensional image class.
Definition itkImage.h:89
SmartPointer< Self > Pointer
Definition itkImage.h:96
Control indentation during Print() invocation.
Definition itkIndent.h:50
CellInterface< CellPixelType, CellTraits > CellType
Definition itkMesh.h:222
typename CellType::CellAutoPointer CellAutoPointer
Definition itkMesh.h:233
Implements transparent reference counting.
Implement the Sweep Line Algorithm for the construction of the 2D Voronoi Diagram.
Implements the 2-Dimensional Voronoi Diagram.
typename SeedsType::iterator SeedsIterator
std::vector< PointType > SeedsType
typename std::vector< VoronoiEdge >::iterator VoronoiEdgeIterator
typename MeshTraits::PointType PointType
typename INTvector::iterator NeighborIdIterator
void PrintSelf(std::ostream &os, Indent indent) const override
void drawVDline(VDImagePointer result, PointType p1, PointType p2, unsigned char color)
void DrawDiagram(VDImagePointer result, unsigned char incolor, unsigned char outcolor, unsigned char boundcolor)
void EnlargeOutputRequestedRegion(DataObject *output) override
void GetPixelIndexFromPolygon(PointTypeDeque vertlist, IndexList *PixelPool)
~VoronoiSegmentationImageFilterBase() override=default
void drawLine(PointType p1, PointType p2)
void FillPolygon(PointTypeDeque vertlist, OutputPixelType color=1)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition itkIntTypes.h:86
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition itkSize.h:70