Xmipp
v3.23.11-Nereus
|
Index <--> Frequency, Continuous <--> Discrete | |
template<typename T > | |
void | FFT_idx2digfreq (T &v, const Matrix1D< int > &idx, Matrix1D< double > &freq) |
template<typename T > | |
void | digfreq2FFT_idx (T &v, const Matrix1D< double > &freq, Matrix1D< int > &idx) |
void | digfreq2contfreq (const Matrix1D< double > &digfreq, Matrix1D< double > &contfreq, double pixel_size) |
void | contfreq2digfreq (const Matrix1D< double > &contfreq, Matrix1D< double > &digfreq, double pixel_size) |
#define | FFT_IDX2DIGFREQ(idx, size, freq) |
#define | FFT_IDX2DIGFREQ_DOUBLE(idx, size, freq) |
#define | FFT_IDX2DIGFREQ_FAST(idx, size, size_2, isize, freq) freq = ( ((idx) <= (size_2)) ? (idx) : -(size) + (idx) ) * (isize); |
#define | DIGFREQ2FFT_IDX(freq, size, idx) |
#define | DIGFREQ2FFT_IDX_DOUBLE(freq, size, idx) |
Format conversions | |
void | Whole2Half (const MultidimArray< std::complex< double > > &in, MultidimArray< std::complex< double > > &out) |
void | Half2Whole (const MultidimArray< std::complex< double > > &in, MultidimArray< std::complex< double > > &out, size_t oridim) |
void | Complex2RealImag (const MultidimArray< std::complex< double > > &in, MultidimArray< double > &real, MultidimArray< double > &imag) |
void | RealImag2Complex (const MultidimArray< double > &real, const MultidimArray< double > &imag, MultidimArray< std::complex< double > > &out) |
Fourier Transforms | |
The theoretical relationship between the Fourier transform of a discrete signal and the Fourier transform of the continuous signal is X(e^jw)=1/T*X_c(jw/T) Xmipp is not computing X(e^jw) but samples from it so that X(e^jw)=N*X_XMIPP[k] where N is the length of the signal being transformed and X_XMIPP[k] is the k-th sample. The following program illustrates how the continuous, discrete and Xmipp Fourier transform relate #include <data/matrix1d.h> #include <data/xmipp_fft.h> if (w==0) return 2*N1+1; else return sin(w*(N1+0.5))/sin(0.5*w); } double continuousTransform(double W, double T1) { if (W==0) return 2*T1; else return 2*sin(W*T1)/W; } int main() { try { MultidimArray<double> x(65); x.setXmippOrigin(); double T=0.5; double T1=6; int N1=(int)CEIL(T1/T); // Fill x with a pulse from -N1 to N1 (-T1 to T1 in continuous) // Compute the Fourier transform MultidimArray<double> Xmag; FourierTransform(x,X); FFT_magnitude(X,Xmag); // Compute the frequency axes digfreq*=2*PI; contfreq=digfreq/T; // Show all Fourier transforms if (digfreq(i)>=0) << std::endl; } } catch (XmippError XE) { std::cout << XE << std::endl; } return 0; } | |
void | FourierTransform (const MultidimArray< double > &in, MultidimArray< std::complex< double > > &out) |
void | InverseFourierTransform (const MultidimArray< std::complex< double > > &in, MultidimArray< double > &out) |
void | FourierTransformHalf (const MultidimArray< double > &in, MultidimArray< std::complex< double > > &out) |
void | InverseFourierTransformHalf (const MultidimArray< std::complex< double > > &in, MultidimArray< double > &out, int oridim) |
Operations with the Fourier Transforms | |
void | centerFFT2 (MultidimArray< double > &v) |
template<typename T > | |
void | CenterFFT (MultidimArray< T > &v, bool forward) |
void | ShiftFFT (MultidimArray< std::complex< double > > &v, double xshift) |
void | ShiftFFT (MultidimArray< std::complex< double > > &v, double xshift, double yshift) |
void | ShiftFFT (MultidimArray< std::complex< double > > &v, double xshift, double yshift, double zshift) |
void | CenterOriginFFT (MultidimArray< std::complex< double > > &v, bool forward) |
template<typename T > | |
void | xmipp2PSD (const MultidimArray< T > &input, MultidimArray< T > &output, bool takeLog=true) |
void | xmipp2CTF (const MultidimArray< double > &input, MultidimArray< double > &output) |
#define | SWAP_ARRAY(a, b, n) memcpy(buffer, a, n); memcpy(a, b, n); memcpy(b, buffer, n); |
#define DIGFREQ2FFT_IDX | ( | freq, | |
size, | |||
idx | |||
) |
Frequency to index (int)
Given a frequency and a size of the FFT, this macro returns the corresponding integer index
Definition at line 61 of file xmipp_fft.h.
#define DIGFREQ2FFT_IDX_DOUBLE | ( | freq, | |
size, | |||
idx | |||
) |
Frequency to index (double)
Given a frequency and a size of the FFT, this macro returns the corresponding double index
Definition at line 70 of file xmipp_fft.h.
#define FFT_IDX2DIGFREQ | ( | idx, | |
size, | |||
freq | |||
) |
Index to frequency
Given an index and a size of the FFT, this function returns the corresponding digital frequency (-1/2 to 1/2)
Definition at line 46 of file xmipp_fft.h.
#define FFT_IDX2DIGFREQ_DOUBLE | ( | idx, | |
size, | |||
freq | |||
) |
Definition at line 50 of file xmipp_fft.h.
#define FFT_IDX2DIGFREQ_FAST | ( | idx, | |
size, | |||
size_2, | |||
isize, | |||
freq | |||
) | freq = ( ((idx) <= (size_2)) ? (idx) : -(size) + (idx) ) * (isize); |
Definition at line 54 of file xmipp_fft.h.
Faster version of CenterFFT (now just for even images)
Definition at line 278 of file xmipp_fft.h.
void CenterFFT | ( | MultidimArray< T > & | v, |
bool | forward | ||
) |
CenterFFT Relation with Matlab fftshift: forward true is equals to fftshift and forward false equals to ifftshift
Definition at line 291 of file xmipp_fft.h.
void centerFFT2 | ( | MultidimArray< double > & | v | ) |
Center FFT for 2D arrays. The function is optimized for the particular case of 2D.
Definition at line 276 of file xmipp_fft.cpp.
void CenterOriginFFT | ( | MultidimArray< std::complex< double > > & | v, |
bool | forward | ||
) |
Place the origin of the FFT at the center of the vector and back
Changes the real and the fourier space origin
Definition at line 386 of file xmipp_fft.cpp.
void Complex2RealImag | ( | const MultidimArray< std::complex< double > > & | in, |
MultidimArray< double > & | real, | ||
MultidimArray< double > & | imag | ||
) |
Conversion from complex -> real,imag
Convert complex -> real,imag Fourier transforms 2D. –
Definition at line 103 of file xmipp_fft.cpp.
|
inline |
Continuous to Digital frequency
The pixel size must be given in Amstrongs. The digital frequency is between [-1/2,1/2]
Definition at line 139 of file xmipp_fft.h.
|
inline |
Digital to Continuous frequency
The pixel size must be given in Amstrongs. The digital frequency is between [-1/2,1/2]
Definition at line 125 of file xmipp_fft.h.
void digfreq2FFT_idx | ( | T & | v, |
const Matrix1D< double > & | freq, | ||
Matrix1D< int > & | idx | ||
) |
Frequency to index
This function can be used with vectors of any size (1,2,3). The Digital spectrum is lim:confirm bd ited between -1/2 and 1/2. If the vector has got more than 3 coordinates, then an exception is thrown
Definition at line 106 of file xmipp_fft.h.
void FFT_idx2digfreq | ( | T & | v, |
const Matrix1D< int > & | idx, | ||
Matrix1D< double > & | freq | ||
) |
Index to frequency
This function can be used with vectors of any size (1,2,3). The Digital spectrum is limited between -1/2 and 1/2. If the vector has got more than 3 coordinates, then an exception is thrown
Definition at line 80 of file xmipp_fft.h.
void FourierTransform | ( | const MultidimArray< double > & | in, |
MultidimArray< std::complex< double > > & | out | ||
) |
Direct Fourier Transform
Direct Fourier Transform nD ----------------------------------------—
Definition at line 124 of file xmipp_fft.cpp.
void FourierTransformHalf | ( | const MultidimArray< double > & | in, |
MultidimArray< std::complex< double > > & | out | ||
) |
Direct Fourier Transform, output half of (centro-symmetric) transform
Direct Fourier Transform 1D / 2D, output half of (centro-symmetric) transform -—
Definition at line 187 of file xmipp_fft.cpp.
void Half2Whole | ( | const MultidimArray< std::complex< double > > & | in, |
MultidimArray< std::complex< double > > & | out, | ||
size_t | oridim | ||
) |
Conversion from half -> whole
Convert half -> whole of (centro-symmetric) Fourier transforms 2D. –
Definition at line 66 of file xmipp_fft.cpp.
void InverseFourierTransform | ( | const MultidimArray< std::complex< double > > & | in, |
MultidimArray< double > & | out | ||
) |
Inverse Fourier Transform
Inverse Fourier Transform nD. --------------------------------------—
Definition at line 155 of file xmipp_fft.cpp.
void InverseFourierTransformHalf | ( | const MultidimArray< std::complex< double > > & | in, |
MultidimArray< double > & | out, | ||
int | oridim | ||
) |
Inverse Fourier Transform 1D, input half of (centro-symmetric) transform
Inverse Fourier Transform 1D / 2D, input half of (centro-symmetric) transform -—
Definition at line 197 of file xmipp_fft.cpp.
void RealImag2Complex | ( | const MultidimArray< double > & | real, |
const MultidimArray< double > & | imag, | ||
MultidimArray< std::complex< double > > & | out | ||
) |
Conversion from real,imag -> complex
Convert real,imag -> complex Fourier transforms 3D. –
Definition at line 114 of file xmipp_fft.cpp.
void ShiftFFT | ( | MultidimArray< std::complex< double > > & | v, |
double | xshift | ||
) |
FFT shift 1D
Calculates the Fourier Transform of the shifted real-space vector by phase shifts in Fourier space
Definition at line 311 of file xmipp_fft.cpp.
void ShiftFFT | ( | MultidimArray< std::complex< double > > & | v, |
double | xshift, | ||
double | yshift | ||
) |
FFT shift 2D
Calculates the Fourier Transform of the shifted real-space vector by phase shifts in Fourier space
Definition at line 331 of file xmipp_fft.cpp.
void ShiftFFT | ( | MultidimArray< std::complex< double > > & | v, |
double | xshift, | ||
double | yshift, | ||
double | zshift | ||
) |
FFT shift 3D
Calculates the Fourier Transform of the shifted real-space vector by phase shifts in Fourier space
Definition at line 352 of file xmipp_fft.cpp.
void Whole2Half | ( | const MultidimArray< std::complex< double > > & | in, |
MultidimArray< std::complex< double > > & | out | ||
) |
Conversion from whole -> half
Convert whole -> half of (centro-symmetric) Fourier transforms 1D. –
Definition at line 34 of file xmipp_fft.cpp.
void xmipp2CTF | ( | const MultidimArray< double > & | input, |
MultidimArray< double > & | output | ||
) |
Xmipp image -> Xmipp CTF. The log10 is taken, outliers rejected and the image is reorganized.
Definition at line 472 of file xmipp_fft.cpp.
void xmipp2PSD | ( | const MultidimArray< T > & | input, |
MultidimArray< T > & | output, | ||
bool | takeLog = true |
||
) |
Xmipp image -> Xmipp PSD. The log10 is taken, outliers rejected and the image is reorganized.
Definition at line 443 of file xmipp_fft.cpp.