IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
FFToperations.h
Go to the documentation of this file.
1/**
2 * \file IMP/em2d/FFToperations.h
3 * \brief Operations involving FFT
4 * Copyright 2007-2026 IMP Inventors. All rights reserved.
5*/
6
7#ifndef IMPEM2D_FF_TOPERATIONS_H
8#define IMPEM2D_FF_TOPERATIONS_H
9
10#include <IMP/em2d/em2d_config.h>
11#include "IMP/em2d/Matrix.h"
12#include <IMP/log_macros.h>
13
14IMPEM2D_BEGIN_NAMESPACE
15
16//! Get the smallest size >= n that can be transformed efficiently by FFT
17/** This is the smallest number >= n whose only prime factors are 2, 3 and 5
18 (the same as cv::getOptimalDFTSize).
19 */
20IMPEM2DEXPORT int get_optimal_dft_size(int n);
21
22/**
23 * Transforms a matrix as is given by FFT functions, into a image
24 * interpretation. Works the opposite way too.
25 * @param m The matrix to flip. The it is changed in situ
26 */
28
29//! Autocorrelation without preprocessing
30/**
31 \param[in] M matrix containing the dft
32 \param[out] corr the matrix to store the autocorrelation. Must have the
33 proper dimensions when passed
34 \deprecated_at{2.26} This function is not used in IMP, and will be removed.
35*/
36IMPEM2D_DEPRECATED_FUNCTION_DECL(2.26)
38 DoubleMatrix &corr);
39
40//! Computes the autocorrelation matrix
41/** @param m The input matrix
42 @param corr The result matrix containing the autocorrelation
43 */
44IMPEM2DEXPORT void get_autocorrelation2d(const DoubleMatrix &m,
45 DoubleMatrix &corr);
46
47//! Correlation matrix between two 2D matrices using FFT
48/**
49 \param[in] A first matrix
50 \param[in] B second matrix
51 \param[out] corr matrix of results
52*/
53IMPEM2DEXPORT void get_correlation2d(const DoubleMatrix &A,
54 const DoubleMatrix &B,
55 DoubleMatrix &corr);
56
57//! Correlation without preprocessing
58/** Returns the correlation matrix between two 2D matrices using FFT
59 \param[in] M1 matrix containing the dft of the first matrix
60 \param[in] M2 matrix containing the dft of the second matrix
61 \param[out] corr matrix of results (It MUST have the right size in advance)
62*/
64 const DoubleMatrix &M2,
65 DoubleMatrix &corr);
66
67/**
68 * Get the FFT of a matrix using padding with other matrix that can be
69 * computed with FFT in an optimal way. i.e. with a size that makes the
70 * FFT algorithm work faster
71 * @param m The input matrix
72 * @param M The output matrix with the FFT
73 * @note The output matrix can have (and frequently will have) different
74 * dimensions than the input matrix
75 */
76IMPEM2DEXPORT void get_fft_using_optimal_size(const DoubleMatrix &m,
77 DoubleMatrix &M);
78
79//! Computes the fft of a matrix and returns the real and imaginary matrices
80/** @param m The input matrix
81 @param real The matrix with the real part of the FFT matrix
82 @param imag The imaginary part of the FFT matrix
83 \deprecated_at{2.26} This function is not used in IMP, and will be removed.
84 */
85IMPEM2D_DEPRECATED_FUNCTION_DECL(2.26)
86IMPEM2DEXPORT void get_spectrum(const DoubleMatrix &m, DoubleMatrix &real,
87 DoubleMatrix &imag);
88
89IMPEM2D_END_NAMESPACE
90
91#endif /* IMPEM2D_FF_TOPERATIONS_H */
Matrices used to store image data Copyright 2007-2026 IMP Inventors. All rights reserved.
Logging and error reporting support.
void do_matrix_to_image_flip(DoubleMatrix &m)
void get_correlation2d(const DoubleMatrix &A, const DoubleMatrix &B, DoubleMatrix &corr)
Correlation matrix between two 2D matrices using FFT.
int get_optimal_dft_size(int n)
Get the smallest size >= n that can be transformed efficiently by FFT.
void get_correlation2d_no_preprocessing(const DoubleMatrix &M1, const DoubleMatrix &M2, DoubleMatrix &corr)
Correlation without preprocessing.
Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > DoubleMatrix
Matrix of doubles, used to store the data of an image.
Definition Matrix.h:28
void get_autocorrelation2d(const DoubleMatrix &m, DoubleMatrix &corr)
Computes the autocorrelation matrix.
void get_autocorrelation2d_no_preprocessing(const DoubleMatrix &M, DoubleMatrix &corr)
Autocorrelation without preprocessing.
void get_fft_using_optimal_size(const DoubleMatrix &m, DoubleMatrix &M)
void get_spectrum(const DoubleMatrix &m, DoubleMatrix &real, DoubleMatrix &imag)
Computes the fft of a matrix and returns the real and imaginary matrices.