![]() |
![]() |
Gwyddion Data Processing Library Reference Manual | ![]() |
|
---|---|---|---|---|
#include <libprocess/gwyprocess.h> gint gwy_fft_find_nice_size (gint size); void gwy_data_line_fft (GwyDataLine *rsrc, GwyDataLine *isrc, GwyDataLine *rdest, GwyDataLine *idest, GwyWindowingType windowing, GwyTransformDirection direction, GwyInterpolationType interpolation, gboolean preserverms, gint level); void gwy_data_line_part_fft (GwyDataLine *rsrc, GwyDataLine *isrc, GwyDataLine *rdest, GwyDataLine *idest, gint from, gint len, GwyWindowingType windowing, GwyTransformDirection direction, GwyInterpolationType interpolation, gboolean preserverms, gint level); void gwy_data_line_fft_raw (GwyDataLine *rsrc, GwyDataLine *isrc, GwyDataLine *rdest, GwyDataLine *idest, GwyTransformDirection direction); void gwy_data_field_1dfft (GwyDataField *rin, GwyDataField *iin, GwyDataField *rout, GwyDataField *iout, GwyOrientation orientation, GwyWindowingType windowing, GwyTransformDirection direction, GwyInterpolationType interpolation, gboolean preserverms, gint level); void gwy_data_field_area_1dfft (GwyDataField *rin, GwyDataField *iin, GwyDataField *rout, GwyDataField *iout, gint col, gint row, gint width, gint height, GwyOrientation orientation, GwyWindowingType windowing, GwyTransformDirection direction, GwyInterpolationType interpolation, gboolean preserverms, gint level); void gwy_data_field_1dfft_raw (GwyDataField *rin, GwyDataField *iin, GwyDataField *rout, GwyDataField *iout, GwyOrientation orientation, GwyTransformDirection direction); void gwy_data_field_2dfft (GwyDataField *rin, GwyDataField *iin, GwyDataField *rout, GwyDataField *iout, GwyWindowingType windowing, GwyTransformDirection direction, GwyInterpolationType interpolation, gboolean preserverms, gint level); void gwy_data_field_area_2dfft (GwyDataField *rin, GwyDataField *iin, GwyDataField *rout, GwyDataField *iout, gint col, gint row, gint width, gint height, GwyWindowingType windowing, GwyTransformDirection direction, GwyInterpolationType interpolation, gboolean preserverms, gint level); void gwy_data_field_2dfft_raw (GwyDataField *rin, GwyDataField *iin, GwyDataField *rout, GwyDataField *iout, GwyTransformDirection direction); void gwy_data_field_2dfft_humanize (GwyDataField *data_field); void gwy_data_field_cwt (GwyDataField *data_field, GwyInterpolationType interpolation, gdouble scale, Gwy2DCWTWaveletType wtype); void gwy_data_field_fft_filter_1d (GwyDataField *data_field, GwyDataField *result_field, GwyDataLine *weights, GwyOrientation orientation, GwyInterpolationType interpolation);
There are two main groups of FFT functions.
High-level functions such as gwy_data_field_2dfft()
, gwy_data_line_fft()
can perform windowing, leveling and other pre- and postprocessing. They
also automatically resample data to a size supported by the current FFT
backend. This makes them suitable for calculation of spectral densities
and other statistical characteristics.
Low-level functions have raw
appended to their name:
gwy_data_field_2dfft_raw()
, gwy_data_line_fft_raw()
. They expect data
of a size returned by gwy_fft_find_nice_size()
and perform no other
operations on the data beside the transform itself. This makes them
suitable for applications where both forward and inverse transform is
performed.
Both types of functions wrap a Fourier transform backend which can be
currently either gwy_fft_simple()
, available always, or
FFTW3, available when Gwyddion was
compiled with it.
gint gwy_fft_find_nice_size (gint size);
Finds a nice-for-FFT array size.
The `nice' means three properties are guaranteed: it is greater than or
equal to size
; it can be directly used with current FFT backend without
scaling (simplefft only
handles sizes that can be factored into certain small prime factors); and
the transform is fast (this is important for FFTW backend which can handle
all array sizes, but performance may suffer).
size : |
Array size. Currently it must not be larger than a hard-coded maximum (64800) which should be large enough for all normal uses. |
Returns : | A nice FFT array size. |
void gwy_data_line_fft (GwyDataLine *rsrc, GwyDataLine *isrc, GwyDataLine *rdest, GwyDataLine *idest, GwyWindowingType windowing, GwyTransformDirection direction, GwyInterpolationType interpolation, gboolean preserverms, gint level);
Calculates Fast Fourier Transform of a data line.
A windowing or data leveling can be applied if requested.
rsrc : |
Real input data line. |
isrc : |
Imaginary input data line. |
rdest : |
Real output data line. It will be resized to the size of the input data line. |
idest : |
Imaginary output data line. It will be resized to the size of the input data line. |
windowing : |
Windowing mode. |
direction : |
FFT direction. |
interpolation : |
Interpolation type. |
preserverms : |
TRUE to preserve RMS value while windowing.
|
level : |
0 to perform no leveling, 1 to subtract mean value, 2 to subtract line (the number can be interpreted as the first polynomial degree to keep, but only the enumerated three values are available). |
void gwy_data_line_part_fft (GwyDataLine *rsrc, GwyDataLine *isrc, GwyDataLine *rdest, GwyDataLine *idest, gint from, gint len, GwyWindowingType windowing, GwyTransformDirection direction, GwyInterpolationType interpolation, gboolean preserverms, gint level);
Calculates Fast Fourier Transform of a part of a data line.
A windowing or data leveling can be applied if requested.
rsrc : |
Real input data line. |
isrc : |
Imaginary input data line. Since 2.7 it can be NULL for
real-to-complex transforms.
|
rdest : |
Real output data line, it will be resized to len .
|
idest : |
Imaginary output data line, it will be resized to len .
|
from : |
The index in input lines to start from (inclusive). |
len : |
Lenght of data line part, it must be at least 4. |
windowing : |
Windowing mode. |
direction : |
FFT direction. |
interpolation : |
Interpolation type. |
preserverms : |
TRUE to preserve RMS value while windowing.
|
level : |
0 to perform no leveling, 1 to subtract mean value, 2 to subtract line (the number can be interpreted as the first polynomial degree to keep, but only the enumerated three values are available). |
void gwy_data_line_fft_raw (GwyDataLine *rsrc, GwyDataLine *isrc, GwyDataLine *rdest, GwyDataLine *idest, GwyTransformDirection direction);
Calculates Fast Fourier Transform of a data line.
The resolutions of rsrc
and isrc
have to be from the set
of sizes returned by gwy_fft_find_nice_size()
. No leveling, windowing nor
scaling is performed.
rsrc : |
Real input data line. |
isrc : |
Imaginary input data line. Since 2.7 it can be NULL for
real-to-complex transform.
|
rdest : |
Real output data line. It will be resized to the size of the input data line. |
idest : |
Imaginary output data line. It will be resized to the size of the input data line. |
direction : |
FFT direction. |
Since 2.1
void gwy_data_field_1dfft (GwyDataField *rin, GwyDataField *iin, GwyDataField *rout, GwyDataField *iout, GwyOrientation orientation, GwyWindowingType windowing, GwyTransformDirection direction, GwyInterpolationType interpolation, gboolean preserverms, gint level);
Transforms all rows or columns in a data field with Fast Fourier Transform.
If requested a windowing and/or leveling is applied to preprocess data to obtain reasonable results.
rin : |
Real input data field. |
iin : |
Imaginary input data field. It can be NULL for real-to-complex
transform which can be somewhat faster than complex-to-complex
transform.
|
rout : |
Real output data field, it will be resized to area size. |
iout : |
Imaginary output data field, it will be resized to area size. |
orientation : |
Orientation: pass GWY_ORIENTATION_HORIZONTAL to
transform rows, GWY_ORIENTATION_VERTICAL to transform
columns.
|
windowing : |
Windowing type. |
direction : |
FFT direction. |
interpolation : |
Interpolation type. |
preserverms : |
TRUE to preserve RMS while windowing.
|
level : |
0 to perform no leveling, 1 to subtract mean value, 2 to subtract line (the number can be interpreted as the first polynomial degree to keep, but only the enumerated three values are available). |
void gwy_data_field_area_1dfft (GwyDataField *rin, GwyDataField *iin, GwyDataField *rout, GwyDataField *iout, gint col, gint row, gint width, gint height, GwyOrientation orientation, GwyWindowingType windowing, GwyTransformDirection direction, GwyInterpolationType interpolation, gboolean preserverms, gint level);
Transforms all rows or columns in a rectangular part of a data field with Fast Fourier Transform.
If requested a windowing and/or leveling is applied to preprocess data to obtain reasonable results.
rin : |
Real input data field. |
iin : |
Imaginary input data field. It can be NULL for real-to-complex
transform which can be somewhat faster than complex-to-complex
transform.
|
rout : |
Real output data field, it will be resized to area size. |
iout : |
Imaginary output data field, it will be resized to area size. |
col : |
Upper-left column coordinate. |
row : |
Upper-left row coordinate. |
width : |
Area width (number of columns), must be at least 4 for horizontal transforms. |
height : |
Area height (number of rows), must be at least 4 for vertical transforms. |
orientation : |
Orientation: pass GWY_ORIENTATION_HORIZONTAL to
transform rows, GWY_ORIENTATION_VERTICAL to transform
columns.
|
windowing : |
Windowing type. |
direction : |
FFT direction. |
interpolation : |
Interpolation type. |
preserverms : |
TRUE to preserve RMS while windowing.
|
level : |
0 to perform no leveling, 1 to subtract mean value, 2 to subtract lines (the number can be interpreted as the first polynomial degree to keep, but only the enumerated three values are available). |
void gwy_data_field_1dfft_raw (GwyDataField *rin, GwyDataField *iin, GwyDataField *rout, GwyDataField *iout, GwyOrientation orientation, GwyTransformDirection direction);
Transforms all rows or columns in a data field with Fast Fourier Transform.
The resolution of rin
and iin
in the transformed direction has to be from
the set of sizes returned by gwy_fft_find_nice_size()
. No leveling,
windowing nor scaling is performed.
rin : |
Real input data field. |
iin : |
Imaginary input data field. It can be NULL for real-to-complex
transform.
|
rout : |
Real output data field, it will be resized to rin size.
|
iout : |
Imaginary output data field, it will be resized to rin size.
|
orientation : |
Orientation: pass GWY_ORIENTATION_HORIZONTAL to
transform rows, GWY_ORIENTATION_VERTICAL to transform
columns.
|
direction : |
FFT direction. |
Since 2.1
void gwy_data_field_2dfft (GwyDataField *rin, GwyDataField *iin, GwyDataField *rout, GwyDataField *iout, GwyWindowingType windowing, GwyTransformDirection direction, GwyInterpolationType interpolation, gboolean preserverms, gint level);
Calculates 2D Fast Fourier Transform of a rectangular a data field.
If requested a windowing and/or leveling is applied to preprocess data to obtain reasonable results.
rin : |
Real input data field. |
iin : |
Imaginary input data field. It can be NULL for real-to-complex
transform which can be somewhat faster than complex-to-complex
transform.
|
rout : |
Real output data field, it will be resized to area size. |
iout : |
Imaginary output data field, it will be resized to area size. |
windowing : |
Windowing type. |
direction : |
FFT direction. |
interpolation : |
Interpolation type. |
preserverms : |
TRUE to preserve RMS while windowing.
|
level : |
0 to perform no leveling, 1 to subtract mean value, 2 to subtract plane (the number can be interpreted as the first polynomial degree to keep, but only the enumerated three values are available). |
void gwy_data_field_area_2dfft (GwyDataField *rin, GwyDataField *iin, GwyDataField *rout, GwyDataField *iout, gint col, gint row, gint width, gint height, GwyWindowingType windowing, GwyTransformDirection direction, GwyInterpolationType interpolation, gboolean preserverms, gint level);
Calculates 2D Fast Fourier Transform of a rectangular area of a data field.
If requested a windowing and/or leveling is applied to preprocess data to obtain reasonable results.
rin : |
Real input data field. |
iin : |
Imaginary input data field. It can be NULL for real-to-complex
transform which can be somewhat faster than complex-to-complex
transform.
|
rout : |
Real output data field, it will be resized to area size. |
iout : |
Imaginary output data field, it will be resized to area size. |
col : |
Upper-left column coordinate. |
row : |
Upper-left row coordinate. |
width : |
Area width (number of columns), must be at least 4. |
height : |
Area height (number of rows), must be at least 4. |
windowing : |
Windowing type. |
direction : |
FFT direction. |
interpolation : |
Interpolation type. |
preserverms : |
TRUE to preserve RMS while windowing.
|
level : |
0 to perform no leveling, 1 to subtract mean value, 2 to subtract plane (the number can be interpreted as the first polynomial degree to keep, but only the enumerated three values are available). |
void gwy_data_field_2dfft_raw (GwyDataField *rin, GwyDataField *iin, GwyDataField *rout, GwyDataField *iout, GwyTransformDirection direction);
Calculates 2D Fast Fourier Transform of a data field.
The resolutions of rin
and iin
have to be from the set
of sizes returned by gwy_fft_find_nice_size()
. No leveling, windowing nor
scaling is performed.
rin : |
Real input data field. |
iin : |
Imaginary input data field. It can be NULL for real-to-complex
transform.
|
rout : |
Real output data field, it will be resized to rin size.
|
iout : |
Imaginary output data field, it will be resized to rin size.
|
direction : |
FFT direction. |
Since 2.1
void gwy_data_field_2dfft_humanize (GwyDataField *data_field);
Rearranges 2D FFT output to a human-friendly form.
Top-left, top-right, bottom-left and bottom-right sub-squares are swapped to obtain a humanized 2D FFT output with (0,0) in the center.
data_field : |
A data field. |
void gwy_data_field_cwt (GwyDataField *data_field, GwyInterpolationType interpolation, gdouble scale, Gwy2DCWTWaveletType wtype);
Computes a continuous wavelet transform (CWT) at given scale and using given wavelet.
data_field : |
A data field. |
interpolation : |
Interpolation type. |
scale : |
Wavelet scale. |
wtype : |
Wavelet type. |
void gwy_data_field_fft_filter_1d (GwyDataField *data_field, GwyDataField *result_field, GwyDataLine *weights, GwyOrientation orientation, GwyInterpolationType interpolation);
Performs 1D FFT filtering of a data field.
data_field : |
A data field to filter. |
result_field : |
A data field to store the result to. It will be resampled
to data_field 's size.
|
weights : |
Filter weights for the lower half of the spectrum (the other half is symmetric). Its size can be arbitrary, it will be interpolated. |
orientation : |
Filter direction. |
interpolation : |
The interpolation to use for resampling. |