ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkRieszUtilities.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 itkRieszUtilities_h
19#define itkRieszUtilities_h
20
21#include <algorithm>
22#include <functional>
23#include <set>
24#include <vector>
25
26#include "itkMacro.h"
27
28#include "IsotropicWaveletsExport.h"
29
30namespace itk
31{
32namespace utils
33{
35IsotropicWavelets_EXPORT long
36Factorial(long n);
37
47IsotropicWavelets_EXPORT unsigned int
48ComputeNumberOfComponents(const unsigned int & order, const unsigned int & dimension);
49
61template <typename TIndicesArrayType, unsigned int VImageDimension>
62ITK_TEMPLATE_EXPORT void
63ComputeUniqueIndices(TIndicesArrayType subIndex,
64 std::set<TIndicesArrayType, std::greater<TIndicesArrayType>> & uniqueIndices,
65 unsigned int init = 0)
66{
67 auto subIndiceSize = static_cast<unsigned int>(subIndex.size());
68
69 if (init == subIndiceSize - 1)
70 {
71 return;
72 }
73
74 // If OK, store it.
75 if (std::distance(subIndex.begin(),
76 std::max_element(subIndex.begin(), subIndex.end(), std::greater<unsigned int>())) <=
77 VImageDimension - 1)
78 {
79 TIndicesArrayType subIndiceCopy = subIndex;
80 std::sort(subIndiceCopy.rbegin(), subIndiceCopy.rend());
81 uniqueIndices.insert(subIndiceCopy);
82 }
83 else
84 {
85 // Process remaining index positions in this branch.
87 return;
88 }
89
90 unsigned int first = --subIndex[init];
91 ++subIndex[init + 1];
92 // Stop
93 if (first == 0)
94 {
95 return;
96 }
97 // Process modified subIndex.
99 // Process modified init.
101}
102
106template <typename TIndicesArrayType>
107ITK_TEMPLATE_EXPORT std::set<TIndicesArrayType, std::greater<TIndicesArrayType>>
108ComputeAllPermutations(const std::set<TIndicesArrayType, std::greater<TIndicesArrayType>> & uniqueIndices)
109{
110 using SetType = std::set<TIndicesArrayType, std::greater<TIndicesArrayType>>;
111 SetType out;
112 for (auto it = uniqueIndices.begin(); it != uniqueIndices.end(); ++it)
113 {
114 out.insert(*it);
115 TIndicesArrayType permutation = *it;
116 while (std::prev_permutation(permutation.begin(), permutation.end()))
117 {
118 out.insert(permutation);
119 }
120 }
121 return out;
122}
123
130template <typename TIndicesArrayType, unsigned int VImageDimension>
131ITK_TEMPLATE_EXPORT std::set<TIndicesArrayType, std::greater<TIndicesArrayType>>
132 ComputeAllPossibleIndices(const unsigned int & order)
133{
134 using SetType = std::set<TIndicesArrayType, std::greater<TIndicesArrayType>>;
135 SetType uniqueIndices;
136 TIndicesArrayType index(VImageDimension);
137 index[0] = order;
140}
141
142template <typename TIndicesArrayType, unsigned int VImageDimension>
143ITK_TEMPLATE_EXPORT bool
144LessOrEqualIndiceComparisson(const TIndicesArrayType & rhs, const TIndicesArrayType & lhs)
145{
146 for (unsigned int i = 0; i < VImageDimension; ++i)
147 {
148 if (rhs[i] > lhs[i])
149 {
150 return false;
151 }
152 }
153 return true;
154}
155} // end namespace utils
156} // end namespace itk
157
158#endif
IsotropicWavelets_EXPORT long Factorial(long n)
Factorial.
IsotropicWavelets_EXPORT unsigned int ComputeNumberOfComponents(const unsigned int &order, const unsigned int &dimension)
ITK_TEMPLATE_EXPORT std::set< TIndicesArrayType, std::greater< TIndicesArrayType > > ComputeAllPossibleIndices(const unsigned int &order)
ITK_TEMPLATE_EXPORT void ComputeUniqueIndices(TIndicesArrayType subIndex, std::set< TIndicesArrayType, std::greater< TIndicesArrayType > > &uniqueIndices, unsigned int init=0)
ITK_TEMPLATE_EXPORT std::set< TIndicesArrayType, std::greater< TIndicesArrayType > > ComputeAllPermutations(const std::set< TIndicesArrayType, std::greater< TIndicesArrayType > > &uniqueIndices)
ITK_TEMPLATE_EXPORT bool LessOrEqualIndiceComparisson(const TIndicesArrayType &rhs, const TIndicesArrayType &lhs)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....