Skip to content

Commit e15a60e

Browse files
authored
Merge branch 'master' into wrap_shrink_expand_zeros
2 parents 9469396 + da95ef3 commit e15a60e

File tree

6 files changed

+179
-2
lines changed

6 files changed

+179
-2
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
* http://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+
19+
#ifndef itkIsotropicWaveletsUtilities_h
20+
#define itkIsotropicWaveletsUtilities_h
21+
22+
#include "itkRieszUtilities.h"
23+
#include "itkWaveletUtilities.h"
24+
25+
namespace itk
26+
{
27+
/**
28+
* Utility class for wrappings purposes.
29+
*
30+
* The static functions call the free function versions from
31+
* itkRieszUtilities.h and itkWaveletUtilities.h
32+
*
33+
* From python, it can be used as:
34+
* itk.IsotropicWaveletsUtilities.Factorial(2)
35+
*/
36+
struct IsotropicWaveletsUtilities
37+
{
38+
using IndexPairType = itk::utils::IndexPairType;
39+
40+
/// Factorial
41+
static long
42+
Factorial(const long n);
43+
44+
/**
45+
* Compute number of components p(N, d), where N = Order, d = Dimension.
46+
* p(N,d) = (N + d - 1)!/( (d-1)! N! )
47+
*
48+
* @param order N of the Riesz transform
49+
* @param dimension d of the image
50+
*
51+
* @return NumberOfComponents given the order for the ImageDimension.
52+
*/
53+
static unsigned int
54+
ComputeNumberOfComponents(const unsigned int & order, const unsigned int & dimension);
55+
56+
/** Get the (Level,Band) from a linear index output.
57+
* The index corresponding to the low-pass image is the last one, corresponding to the
58+
* IndexPairType(this->GetLevels(), 0).
59+
*
60+
* In a steerable pyramid: TotalOutputs = 1 + Levels * Bands
61+
*
62+
* The outputs are ordered, if n is the \c linearIndex:
63+
*
64+
* n:0 ---> level:0 band:1,
65+
* n:1 ---> l:0, b:2, etc. until b == bands.
66+
* n:bands-1 ---> l:0, b=bands
67+
*
68+
* If there is more than one level:
69+
*
70+
* n:bands ---> l:1, b=1
71+
*
72+
* if only one level:
73+
*
74+
* n:bands ---> l:0, b=0
75+
*
76+
* Independently of the numbers of levels or bands, the last index is always the low pass:
77+
*
78+
* nLowPass ---> l:Levels, b=0
79+
*
80+
* Note that bands and levels are always >= 1. The level/bands returned here corresponds to an index.
81+
*/
82+
static IndexPairType
83+
IndexToLevelBandSteerablePyramid(unsigned int linearIndex, unsigned int levels, unsigned int bands);
84+
85+
/** Compute max number of levels depending on the size of the image.
86+
* Return J: $ J = \text{min_element}\{J_0,\ldots, J_d\} $;
87+
* where each $J_i$ is the number of integer divisions that can be done with the $i$ size and the scale factor.
88+
* returns 1 if any size is not divisible by the scale factor.
89+
* Size<2> version.
90+
*/
91+
static unsigned int
92+
ComputeMaxNumberOfLevels(const Size<2> & inputSize, const unsigned int & scaleFactor);
93+
/** Compute max number of levels depending on the size of the image.
94+
* Return J: $ J = \text{min_element}\{J_0,\ldots, J_d\} $;
95+
* where each $J_i$ is the number of integer divisions that can be done with the $i$ size and the scale factor.
96+
* returns 1 if any size is not divisible by the scale factor.
97+
* Size<3> version.
98+
*/
99+
static unsigned int
100+
ComputeMaxNumberOfLevels(const Size<3> & inputSize, const unsigned int & scaleFactor);
101+
};
102+
} // end namespace itk
103+
#endif

include/itkWaveletUtilities.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,27 @@ namespace utils
3434
using IndexPairType = std::pair<unsigned int, unsigned int>;
3535

3636
/** Get the (Level,Band) from a linear index output.
37-
* The index corresponding to the low-pass image is the last one, corresponding to the IndexPairType(this->GetLevels(),
38-
* 0). In a steerable pyramid: TotalOutputs = 1 + Levels * Bands The outputs are ordered, if n is the \c linearIndex:
37+
* The index corresponding to the low-pass image is the last one, corresponding to the
38+
* IndexPairType(this->GetLevels(), 0).
39+
*
40+
* In a steerable pyramid: TotalOutputs = 1 + Levels * Bands
41+
*
42+
* The outputs are ordered, if n is the \c linearIndex:
43+
*
3944
* n:0 ---> level:0 band:1,
4045
* n:1 ---> l:0, b:2, etc. until b == bands.
4146
* n:bands-1 ---> l:0, b=bands
47+
*
4248
* If there is more than one level:
49+
*
4350
* n:bands ---> l:1, b=1
51+
*
4452
* if only one level:
53+
*
4554
* n:bands ---> l:0, b=0
55+
*
4656
* Independently of the numbers of levels or bands, the last index is always the low pass:
57+
*
4758
* nLowPass ---> l:Levels, b=0
4859
*
4960
* Note that bands and levels are always >= 1. The level/bands returned here corresponds to an index.

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
set(IsotropicWavelets_SRCS
22
itkRieszUtilities.cxx
33
itkWaveletUtilities.cxx
4+
# For wrappings purposes
5+
itkIsotropicWaveletsUtilities.cxx
46
)
57
### generating libraries
68
itk_module_add_library( IsotropicWavelets ${IsotropicWavelets_SRCS})
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
* http://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+
19+
#include "itkIsotropicWaveletsUtilities.h"
20+
21+
namespace itk
22+
{
23+
long
24+
IsotropicWaveletsUtilities::Factorial(const long n)
25+
{
26+
return itk::utils::Factorial(n);
27+
}
28+
29+
unsigned int
30+
IsotropicWaveletsUtilities::ComputeNumberOfComponents(const unsigned int & order, const unsigned int & dimension)
31+
{
32+
return itk::utils::ComputeNumberOfComponents(order, dimension);
33+
}
34+
35+
IsotropicWaveletsUtilities::IndexPairType
36+
IsotropicWaveletsUtilities::IndexToLevelBandSteerablePyramid(unsigned int linearIndex,
37+
unsigned int levels,
38+
unsigned int bands)
39+
{
40+
return itk::utils::IndexToLevelBandSteerablePyramid(linearIndex, levels, bands);
41+
}
42+
43+
44+
unsigned int
45+
IsotropicWaveletsUtilities::ComputeMaxNumberOfLevels(const Size<2> & inputSize, const unsigned int & scaleFactor)
46+
{
47+
return itk::utils::ComputeMaxNumberOfLevels<2>(inputSize, scaleFactor);
48+
}
49+
50+
unsigned int
51+
IsotropicWaveletsUtilities::ComputeMaxNumberOfLevels(const Size<3> & inputSize, const unsigned int & scaleFactor)
52+
{
53+
return itk::utils::ComputeMaxNumberOfLevels<3>(inputSize, scaleFactor);
54+
}
55+
56+
} // end namespace itk
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
itk_wrap_class("itk::IsotropicWaveletsUtilities")
2+
itk_wrap_template("IsotropicWaveletsUtilities" "")
3+
itk_end_wrap_class()

wrapping/test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ itk_python_expression_add_test(NAME itkExpandWithZerosImageFilter
4040
EXPRESSION "instance = itk.ExpandWithZerosImageFilter.New()")
4141
itk_python_expression_add_test(NAME itkShrinkDecimateImageFilter
4242
EXPRESSION "instance = itk.ShrinkDecimateImageFilter.New()")
43+
itk_python_expression_add_test(NAME itkIsotropicWaveletsUtilitiesPythonTest
44+
EXPRESSION "itk.IsotropicWaveletsUtilities.Factorial(2)")

0 commit comments

Comments
 (0)