Skip to content

vlt.image.prevailing_orientation

  PREVAILING_ORIENTATION - determine the prevailing orientation (strongest oriented sinwave signal) of an image

  [THETA,IM_OUT] = PREVAILING_ORIENTATION(IM)

  Performs a 2D fourier transform on the image IM and identifies the prevailing image
  orientation by finding the peak non-DC sinusoidal component. 

  THETA is the orientation in radians.

  This function will likely work poorly on data that is not a simple sinusoid or that lacks
  a dominant sinusoid.

  If 2 output arguments are specified, a rotated version of the image is returned
  using IMROTATE and bilinear interpolation.

  Developer's note: this function takes the peak in the 2-d fourier space as evidence of
  the phase. This results in a small error for some low spatial frequencies. The function
  could be improved.

  See also: FFT2, IMROTATE 

  Example:
    [x,y] = meshgrid([-100:100],[-100:100]);
    im = sin(0.3*x+0.1*y);
    [theta,im_out] = vlt.image.prevailing_orientation(im);
    figure;
    subplot(2,2,1);
    imagesc(im);
    subplot(2,2,2);
    imagesc(im_out);