Previous topic

util.garray

Next topic

util.gio

This Page

util.gimage

Miscellaneous functions related to images and image processing.

glimpse.util.gimage.ImageToArray(img, array=None, transpose=True)

Load image data into a 2D numpy array.

Parameters:
  • img (PIL.Image) – Image to read.
  • array (ndarray) – Output array. If unspecified, one will be generated automatically.
  • transpose (bool) – Whether image data should be transposed before returning.
Returns:

Array containing image data. Note that this may be non-contiguous.

Return type:

ndarray

glimpse.util.gimage.PowerSpectrum(image, width=None)

Get the 1-D power spectrum (squared-amplitude at each frequency) for a given input image. This is computed from the 2-D power spectrum via a rotational average.

Parameters:
  • image (2D ndarray) – Image data.
  • width (int) – Width of image to use for FFT (i.e., image width plus padding). By default, this is the width of the image.
Returns:

Array whose rows contain the value, sum, and count of bins in the power histogram.

glimpse.util.gimage.PowerSpectrum2d(image)

Compute the 2-D power spectrum for an image.

Parameters:image (2D ndarray) – Image data.
Returns:Squared amplitude from FFT of image.
Return type:2D ndarray
glimpse.util.gimage.ShowImage(img, fname=None)

Display an image to the user.

glimpse.util.gimage.ShowImageOnLinux(img, fname=None)

Display an image to the user under Linux.