### fft2d Crate Overview Source: https://docs.rs/fft2d This snippet provides a high-level overview of the fft2d crate and its primary module. ```APIDOC ## Crate fft2d ### Summary Fourier transform for 2D data such as images. ### Modules #### slice Fourier transform for 2D data such as images. ``` -------------------------------- ### FFT2D Functions Source: https://docs.rs/fft2d/0.1.1/fft2d/all.html This section details the available functions for performing 2D Fast Fourier Transforms and their inverse operations, as well as functions for shifting the zero-frequency component. ```APIDOC ## FFT2D Functions ### Description Provides functions for 2D Fast Fourier Transforms (FFT) and their inverse (IFFT), along with utilities for shifting the FFT output. ### Functions - **`slice::fft_2d`**: Computes the 2D Fast Fourier Transform of a slice. - **`slice::ifft_2d`**: Computes the 2D Inverse Fast Fourier Transform of a slice. - **`slice::fftshift`**: Shifts the zero-frequency component to the center of the spectrum. - **`slice::ifftshift`**: Shifts the zero-frequency component from the center to the corners. ``` -------------------------------- ### fft2d Functions Source: https://docs.rs/fft2d/0.1.1/fft2d/slice/index.html Core functions for performing 2D Fourier transforms and frequency shifting. ```APIDOC ## Functions ### fft_2d Compute the 2D Fourier transform of an image buffer. ### ifft_2d Compute the inverse 2D Fourier transform to get back an image buffer. ### fftshift Shift the 4 quadrants of a Fourier transform to have all the low frequencies at the center of the image. ### ifftshift Inverse operation of the quadrants shift performed by fftshift. ``` -------------------------------- ### Inverse 2D Fourier Transform Source: https://docs.rs/fft2d/0.1.1/fft2d/slice/fn.ifft_2d.html Computes the inverse 2D Fourier transform to reconstruct an image buffer. Note that the output is transposed and not normalized. Normalization by 1 / sqrt(width * height) is recommended if this is used as a pair with FFT. For efficiency, if used as a pair of FFT followed by inverse FFT, normalize only once by 1 / (width * height) at the end. ```APIDOC ## Function ifft_2d ### Description Compute the inverse 2D Fourier transform to get back an image buffer. After the inverse 2D FFT has been applied, the image buffer contains the transposed of the inverse Fourier transform since one transposition is needed to process the columns of the buffer. The transformation is not normalized. To normalize the output, you should multiply it by 1 / sqrt( width * height ). If this is used as a pair of FFT followed by inverse FFT, is is more efficient to normalize only once by 1 / (width * height) at the end. Remark: an allocation the size of the image buffer is performed for the transposition, as well as scratch buffers while performing the rows and columns FFTs. ### Signature ```rust pub fn ifft_2d(width: usize, height: usize, img_buffer: &mut [Complex]) ``` ### Parameters #### Path Parameters - **width** (usize) - Required - The width of the image buffer. - **height** (usize) - Required - The height of the image buffer. - **img_buffer** (&mut [Complex]) - Required - A mutable slice representing the image buffer containing complex numbers. ### Response #### Success Response (void) This function modifies the `img_buffer` in place. ### Remarks - The output buffer is transposed. - The transformation is not normalized. Normalize by `1 / sqrt(width * height)` for a single inverse transform, or `1 / (width * height)` if used as a pair with FFT. - Allocations are made for transposition and scratch buffers. ``` -------------------------------- ### Compute 2D Fourier Transform Source: https://docs.rs/fft2d/0.1.1/fft2d/slice/fn.fft_2d.html Computes the 2D Fourier transform of an image buffer stored in row-major order. Note that the output is transposed and requires manual normalization. ```rust pub fn fft_2d(width: usize, height: usize, img_buffer: &mut [Complex]) ``` -------------------------------- ### Compute Inverse 2D Fourier Transform Source: https://docs.rs/fft2d/0.1.1/fft2d/slice/fn.ifft_2d.html Use this function to compute the inverse 2D Fourier transform of an image buffer. Note that the transformation is not normalized and requires a transposition, which involves an allocation. For paired FFT/iFFT operations, normalize once at the end by 1 / (width * height). ```rust pub fn ifft_2d(width: usize, height: usize, img_buffer: &mut [Complex]) ``` -------------------------------- ### Function: ifftshift Source: https://docs.rs/fft2d/0.1.1/fft2d/slice/fn.ifftshift.html Documentation for the ifftshift function used to perform the inverse quadrant shift on a 2D matrix. ```APIDOC ## Function: ifftshift ### Description Performs the inverse operation of the quadrants shift performed by fftshift. This operation differs from fftshift when one dimension of the input matrix has an odd length. ### Signature `pub fn ifftshift(width: usize, height: usize, matrix: &[T]) -> Vec` ### Parameters - **width** (usize) - Required - The width of the input matrix. - **height** (usize) - Required - The height of the input matrix. - **matrix** (&[T]) - Required - A slice containing the elements of the matrix to be shifted. ### Returns - **Vec** - A new vector containing the shifted elements. ``` -------------------------------- ### fftshift function signature Source: https://docs.rs/fft2d/0.1.1/fft2d/slice/fn.fftshift.html Defines the function signature for shifting Fourier transform quadrants in a 2D matrix. ```rust pub fn fftshift( width: usize, height: usize, matrix: &[T], ) -> Vec ``` -------------------------------- ### fft_2d Function Source: https://docs.rs/fft2d/0.1.1/fft2d/slice/fn.fft_2d.html Computes the 2D Fourier transform of an image buffer. The image buffer is assumed to be in row-major order. The function performs an in-place transformation. Note that the output buffer contains the transpose of the Fourier transform due to internal processing. Normalization and efficiency considerations for inverse transforms are also discussed. ```APIDOC ## fft_2d ### Description Computes the 2D Fourier transform of an image buffer. The image buffer is considered to be stored in row major order. After the 2D FFT has been applied, the buffer contains the transposed of the Fourier transform since one transposition is needed to process the columns of the image buffer. The transformation is not normalized. To normalize the output, you should multiply it by 1 / sqrt( width * height ). If the transformed buffer is intended to be processed and then converted back into an image with an inverse Fourier transform, it is more efficient to multiply at the end by 1 / (width * height). Remark: an allocation the size of the image buffer is performed for the transposition, as well as scratch buffers while performing the rows and columns FFTs. ### Method `pub fn` ### Endpoint `fft2d::fft_2d` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **width** (usize) - Required - The width of the image buffer. - **height** (usize) - Required - The height of the image buffer. - **img_buffer** (&mut [Complex]) - Required - A mutable slice representing the image data, where each element is a Complex number with f64 components. ### Request Example ```json { "width": 100, "height": 100, "img_buffer": [ {"re": 1.0, "im": 0.0}, // ... more complex numbers representing image data ] } ``` ### Response #### Success Response (200) This function modifies the `img_buffer` in place and does not return a value. #### Response Example None (in-place modification) ``` -------------------------------- ### fftshift Function Source: https://docs.rs/fft2d/0.1.1/fft2d/slice/fn.fftshift.html Shifts the 4 quadrants of a Fourier transform to center the low frequencies. ```APIDOC ## Function fftshift ### Description Shift the 4 quadrants of a Fourier transform to have all the low frequencies at the center of the image. ### Signature `pub fn fftshift(width: usize, height: usize, matrix: &[T]) -> Vec` ### Parameters - **width** (usize) - Required - The width of the input matrix. - **height** (usize) - Required - The height of the input matrix. - **matrix** (&[T]) - Required - A slice containing the input data to be shifted. ### Returns - **Vec** - A new vector containing the shifted data. ``` -------------------------------- ### ifftshift Function Signature Source: https://docs.rs/fft2d/0.1.1/fft2d/slice/fn.ifftshift.html The inverse operation of the quadrants shift performed by fftshift. It differs from fftshift when a dimension has an odd length. Requires the width, height, and a slice of elements of type T, where T must be Copy and Default. ```rust pub fn ifftshift( width: usize, height: usize, matrix: &[T], ) -> Vec ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.