ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkImageRandomNonRepeatingConstIteratorWithIndex.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 itkImageRandomNonRepeatingConstIteratorWithIndex_h
19#define itkImageRandomNonRepeatingConstIteratorWithIndex_h
20
22#include <algorithm>
23#include <iostream>
25
26namespace itk
27{
41{
42public:
45 double m_Value;
46
48 {
49 m_Priority = 0;
50 m_Index = 0;
51 m_Value = 0.0;
52 }
53
54 bool
55 operator<(const NodeOfPermutation & b) const
56 {
57 if (m_Priority == b.m_Priority)
58 {
59 return m_Value < b.m_Value;
60 }
61
62 return m_Priority < b.m_Priority;
63 }
64};
65
71{
72public:
77
85
88 {
89 delete[] m_Permutation;
90 m_Size = it.m_Size;
93 return *this;
94 }
95
96 void
98 {
99 if (i > m_Size)
100 {
101 std::ostringstream ostrm;
102 ostrm << "Error: RandomPermuation does not have " << i << " elements" << std::endl;
103 throw std::runtime_error(ostrm.str());
104 }
105
106 m_Permutation[i].m_Priority = priority;
107 }
108
109 void
110 Shuffle() const
111 {
112 for (SizeValueType i = 0; i < m_Size; ++i)
113 {
114 m_Permutation[i].m_Value = m_Generator->GetVariateWithClosedRange(1.0);
115 m_Permutation[i].m_Index = i;
116 }
117 std::sort(m_Permutation, m_Permutation + m_Size);
118 }
119
122 {
123 return m_Permutation[i].m_Index;
124 }
125
127
129 void
131 {
132 m_Generator->Initialize();
133 }
134
135 void
136 ReinitializeSeed(unsigned int seed) const
137 {
138 m_Generator->SetSeed(seed);
139 }
140};
141
213template <typename TImage>
215{
216public:
220
222 using typename Superclass::IndexType;
223 using typename Superclass::SizeType;
224 using typename Superclass::OffsetType;
225 using typename Superclass::RegionType;
226 using typename Superclass::ImageType;
227 using typename Superclass::PixelContainer;
229 using typename Superclass::InternalPixelType;
230 using typename Superclass::PixelType;
231 using typename Superclass::AccessorType;
232 using typename Superclass::IndexValueType;
233 using typename Superclass::OffsetValueType;
234 using typename Superclass::SizeValueType;
235
240
244
257
259 Self &
260 operator=(const Self & it);
261
263 void
265 {
267 this->UpdatePosition();
268 }
269
270
272 void
278
279
281 bool
282 IsAtBegin() const
283 {
284 return (m_NumberOfSamplesDone == 0L);
285 }
286
288 bool
289 IsAtEnd() const
290 {
292 }
293
295 static constexpr unsigned int ImageDimension = TImage::ImageDimension;
296
299
305 void
306 SetPriorityImage(const PriorityImageType * priorityImage);
307
310 Self &
312 {
314 this->UpdatePosition();
315 return *this;
316 }
317
318
321 Self &
323 {
325 this->UpdatePosition();
326 return *this;
327 }
328
329
331 void
340
341
344 {
346 }
347
349 void
351
354 void
356
357private:
359 void
361
366};
367} // end namespace itk
368
369#ifndef ITK_MANUAL_INSTANTIATION
370# include "itkImageRandomNonRepeatingConstIteratorWithIndex.hxx"
371#endif
372
373#endif
typename OffsetType::OffsetValueType OffsetValueType
Self & operator=(const Self &it)
typename SizeType::SizeValueType SizeValueType
typename IndexType::IndexValueType IndexValueType
typename PixelContainer::Pointer PixelContainerPointer
typename TImage::InternalPixelType InternalPixelType
typename TImage::PixelContainer PixelContainer
void SetPriorityImage(const PriorityImageType *priorityImage)
ImageRandomNonRepeatingConstIteratorWithIndex(const ImageType *ptr, const RegionType &region)
ImageRandomNonRepeatingConstIteratorWithIndex(const ImageConstIteratorWithIndex< TImage > &it)
Templated n-dimensional image class.
Definition itkImage.h:89
A node to be used when computing permutations.
bool operator<(const NodeOfPermutation &b) const
Produce a random permutation of a collection.
RandomPermutation & operator=(const RandomPermutation &it)
void SetPriority(SizeValueType i, SizeValueType priority) const
typename Statistics::MersenneTwisterRandomVariateGenerator::Pointer GeneratorPointer
static Pointer New()
Method for creation through the object factory.
AddImageFilter Self
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition itkIntTypes.h:86