|
| 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 |
0 commit comments