Skip to content

vlt.image.spatialFFT

  SPATIALFFT - Computes a 1D spatial frequency profile from a 2D image.

    [SF, SF_AMP] = vlt.image.spatialFFT(IMAGE, METERS_PER_PIXEL)
    [SF, SF_AMP] = vlt.image.spatialFFT(IMAGE, METERS_PER_PIXEL, 'mask', MASK)

    Calculates a 1D, orientation-independent spatial frequency profile from a
    2D image. This is achieved by taking the 2D Fourier Transform of the image
    and then performing a radial average of the resulting amplitude spectrum.

    Inputs:
      IMAGE           - A 2D matrix (e.g., an image) of double-precision values.
                        Any NaN values in the image will be replaced by 0
                        before the FFT, which preserves the DC component.
      METERS_PER_PIXEL- A scalar value indicating the physical size of each
                        pixel in meters. This is used to correctly scale the
                        frequency axis.

    Name-Value Pairs:
      'mask'          - A logical or numeric matrix of the same size as IMAGE.
                        Pixels where the mask is `false` or 0 are set to 0
                        and excluded from the analysis.

    Outputs:
      spatialFrequency    - A 1D vector representing the spatial frequency axis
                            in units of cycles per meter.
      spatialFrequencyAmp - A 1D vector containing the corresponding mean
                            amplitude for each spatial frequency.

    Example:
      % Create a sample image with a known frequency
      [x, ~] = meshgrid(1:256);
      img = sin(2 * pi * 10 * x / 256); % 10 cycles in 256 pixels
      m_per_pix = 1e-3; % 1 mm per pixel
      [sf, amp] = vlt.image.spatialFFT(img, m_per_pix);
      figure;
      plot(sf, amp, 'o-');
      xlabel('Spatial Frequency (cycles/meter)');
      ylabel('Amplitude');
      title('1D Spatial frequency Profile');