ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkPocketFFTCommon.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 itkPocketFFTCommon_h
19#define itkPocketFFTCommon_h
20
21#include "pocketfft_hdronly.h"
22
23namespace itk
24{
29{
30
33template <typename TSize>
34inline pocketfft::shape_t
35MakeShape(const TSize & itkSize, const unsigned int dimension)
36{
37 pocketfft::shape_t shape(dimension);
38 for (unsigned int i = 0; i < dimension; ++i)
39 {
40 shape[dimension - 1 - i] = itkSize[i];
41 }
42 return shape;
43}
44
46template <typename TSize>
47inline pocketfft::stride_t
48MakeStride(const TSize & itkSize, const unsigned int dimension, const size_t pixelBytes)
49{
50 pocketfft::stride_t stride(dimension);
51 ptrdiff_t byteStride = static_cast<ptrdiff_t>(pixelBytes);
52 for (unsigned int i = 0; i < dimension; ++i)
53 {
54 stride[dimension - 1 - i] = byteStride;
55 byteStride *= static_cast<ptrdiff_t>(itkSize[i]);
56 }
57 return stride;
58}
59
62inline pocketfft::shape_t
63MakeAxes(const unsigned int dimension)
64{
65 pocketfft::shape_t axes(dimension);
66 for (unsigned int i = 0; i < dimension; ++i)
67 {
68 axes[i] = i;
69 }
70 return axes;
71}
72
74template <typename TValue>
75inline void
76Transform1D(std::complex<TValue> * data, const size_t lineLength, const bool forward, const TValue scale)
77{
78 const pocketfft::shape_t shape{ lineLength };
79 const pocketfft::stride_t stride{ static_cast<ptrdiff_t>(sizeof(std::complex<TValue>)) };
80 pocketfft::c2c(shape, stride, stride, { 0 }, forward, data, data, scale);
81}
82
83} // namespace PocketFFTCommon
84} // namespace itk
85
86#endif
Helpers shared by the PocketFFT image filters.
pocketfft::stride_t MakeStride(const TSize &itkSize, const unsigned int dimension, const vcl_size_t pixelBytes)
pocketfft::shape_t MakeShape(const TSize &itkSize, const unsigned int dimension)
pocketfft::shape_t MakeAxes(const unsigned int dimension)
void Transform1D(std::complex< TValue > *data, const vcl_size_t lineLength, const bool forward, const TValue scale)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....