SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
SEFramework
FFT
FFTHelper.h
Go to the documentation of this file.
1
18
#ifndef _SEFRAMEWORK_FFT_FFTHELPER_H
19
#define _SEFRAMEWORK_FFT_FFTHELPER_H
20
21
#include "
SEFramework/Image/Image.h
"
22
#include <cassert>
23
#include <vector>
24
25
namespace
SourceXtractor
{
26
43
template
<
typename
T,
template
<
typename
>
class
Img>
44
static
void
copyImageToFFTWorkArea
(
Img<T>
&
origin
,
std::vector<T>
&
buffer
) {
45
int
width =
origin
.getWidth();
46
int
height =
origin
.getHeight();
47
int
pad
= 2 * (width / 2 + 1) - width;
48
int
stride
= width +
pad
;
49
assert
(
buffer
.size() ==
static_cast<
size_t
>
(height * (width +
pad
)));
50
for
(
int
y
= 0;
y
< height; ++
y
) {
51
for
(
int
x
= 0;
x
< width; ++
x
) {
52
buffer
[
x
+
y
*
stride
] =
origin
.getValue(
x
,
y
);
53
}
54
}
55
}
56
86
template
<
typename
T,
template
<
typename
>
class
Img>
87
static
void
copyFFTWorkAreaToImage
(
std::vector<T>
&
buffer
,
Img<T>
&
dest
,
int
rpad
= 0,
int
lpad
= 0,
int
tpad
= 0,
int
bpad
= 0,
88
bool
normalize =
true
) {
89
const
int
width =
dest
.getWidth();
90
const
int
height =
dest
.getHeight();
91
const
int
padded_width
= width +
rpad
+
lpad
;
92
const
int
padded_height
= height +
tpad
+
bpad
;
93
const
int
fftw_pad
= 2 * (
padded_width
/ 2 + 1) -
padded_width
;
94
const
int
stride
=
padded_width
+
fftw_pad
;
95
const
int
total_size
= normalize ?
padded_width
*
padded_height
: 1;
96
assert
(
buffer
.size() ==
static_cast<
size_t
>
(
padded_height
* (
padded_width
+
fftw_pad
)));
97
for
(
int
y
= 0;
y
< height; ++
y
) {
98
for
(
int
x
= 0;
x
< width; ++
x
) {
99
dest
.setValue(
x
,
y
,
buffer
[
x
+
lpad
+ (
y
+
tpad
) *
stride
] /
total_size
);
100
}
101
}
102
}
103
104
}
// namespace SourceXtractor
105
106
#endif
// _SEFRAMEWORK_FFT_FFTHELPER_H
Image.h
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition
MoffatModelFittingTask.cpp:94
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition
MoffatModelFittingTask.cpp:94
std::function
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::copyFFTWorkAreaToImage
static void copyFFTWorkAreaToImage(std::vector< T > &buffer, Img< T > &dest, int rpad=0, int lpad=0, int tpad=0, int bpad=0, bool normalize=true)
Definition
FFTHelper.h:87
SourceXtractor::copyImageToFFTWorkArea
static void copyImageToFFTWorkArea(Img< T > &origin, std::vector< T > &buffer)
Definition
FFTHelper.h:44
Generated by
1.10.0