Image Processing
Centroiders
Functions for centroiding images.
- aotools.image_processing.centroiders.brightest_pixel(img, threshold, **kwargs)[source]
 Centroids using brightest Pixel Algorithm (A. G. Basden et al, MNRAS, 2011)
Finds the nPxlsth brightest pixel, subtracts that value from frame, sets anything below 0 to 0, and finally takes centroid.
- Parameters:
 img (ndarray) – 2d or greater rank array of imgs to centroid
threshold (float) – Fraction of pixels to use for centroid
- Returns:
 Array of centroid values
- Return type:
 ndarray
- aotools.image_processing.centroiders.centre_of_gravity(img, threshold=0, min_threshold=0, **kwargs)[source]
 Centroids an image, or an array of images. Centroids over the last 2 dimensions. Sets all values under “threshold*max_value” to zero before centroiding Origin at 0,0 index of img.
- Parameters:
 img (ndarray) – ([n, ]y, x) 2d or greater rank array of imgs to centroid
threshold (float) – Percentage of max value under which pixels set to 0
- Returns:
 Array of centroid values (2[, n])
- Return type:
 ndarray
- aotools.image_processing.centroiders.correlation_centroid(im, ref, threshold=0.0, padding=1)[source]
 Correlation Centroider, currently only works for 3d im shape. Performs a simple thresholded COM on the correlation.
- Parameters:
 im – sub-aperture images (t, y, x)
ref – reference image (y, x)
threshold – fractional threshold for COM (0=all pixels, 1=brightest pixel)
padding – factor to zero-pad arrays in Fourier transforms
- Returns:
 centroids of im (2, t), given in order x, y
- Return type:
 ndarray
- aotools.image_processing.centroiders.cross_correlate(x, y, padding=1)[source]
 2D convolution using FFT, use to generate cross-correlations.
- Parameters:
 x (array) – subap image
y (array) – reference image
padding (int) – Factor to zero-pad arrays in Fourier transforms
- Returns:
 cross-correlation of x and y
- Return type:
 ndarray
- aotools.image_processing.centroiders.quadCell(img, **kwargs)[source]
 Centroider to be used for 2x2 images.
- Parameters:
 img – 2d or greater rank array, where centroiding performed over last 2 dimensions
- Returns:
 Array of centroid values
- Return type:
 ndarray
Contrast
Functions for calculating the contrast of an image.
- aotools.image_processing.contrast.image_contrast(image)[source]
 Calculates the ‘Michelson’ contrast.
- Uses a method by Michelson (Michelson, A. (1927). Studies in Optics. U. of Chicago Press.), to calculate the contrast ratio of an image. Uses the formula:
 (img_max - img_min)/(img_max + img_min)
- Parameters:
 image (ndarray) – Image array
- Returns:
 Contrast value
- Return type:
 
- aotools.image_processing.contrast.rms_contrast(image)[source]
 Calculates the RMS contrast - basically the standard deviation of the image
- Parameters:
 image (ndarray) – Image array
- Returns:
 Contrast value
- Return type:
 
PSF Analysis
Functions for analysing PSFs.
- aotools.image_processing.psf.azimuthal_average(data)[source]
 Measure the azimuthal average of a 2d array
- Parameters:
 data (ndarray) – A 2-d array of data
- Returns:
 A 1-d vector of the azimuthal average
- Return type:
 ndarray
- aotools.image_processing.psf.encircled_energy(data, fraction=0.5, center=None, eeDiameter=True)[source]
 Return the encircled energy diameter for a given fraction (default is ee50d). Can also return the encircled energy function. Translated and extended from YAO.
- Parameters:
 data – 2-d array
fraction – energy fraction for diameter calculation default = 0.5
center – default = center of image
eeDiameter – toggle option for return. If False returns two vectors: (x, ee(x)) Default = True
- Returns:
 Encircled energy diameter or 2 vectors: diameters and encircled energies