core.image Module

This is the module for putting advanced/x-ray specific image processing tools. These should be interesting compositions of existing tools, not just straight wrapping of np/scipy/scikit images.

skbeam.core.image.construct_circ_avg_image(radii, intensities, dims=None, center=None, pixel_size=(1, 1), left=0, right=0)
Constructs a 2D image from circular averaged data

where radii are given in units of pixels. Normally, data will be taken from circular_average and used to re-interpolate into an image.

Parameters
radii1D array of floats

the radii (must be in pixels)

intensities1D array of floats

the intensities for the radii

dims2 tuple of floats, optional

[dy, dx] (row, col) dy, dx are the dimensions in row,col format If the dims are not set, it will assume the dimensions to be (2*maxr+1) where maxr is the maximum radius. Note in the case of rectangular pixels (pixel_size not 1:1) that the `maxr’ value will be different in each dimension

center: 2 tuple of floats, optional

[y0, x0] (row, col) y0, x0 is the center (in row,col format) if not centered, assumes center is (dims[0]-1)/2., (dims[1]-1)/2.

pixel_sizetuple, optional

The size of a pixel (in a real unit, like mm). argument order should be (pixel_height, pixel_width) default is (1, 1)

leftfloat, optional

pixels smaller than the minimum radius are set to this value (set to None for the value at the minimum radius)

rightfloat, optional

pixels larger than the maximum radius are set to this value (set to None for the value at the maximum radius)

Returns
IMGthe interpolated circular averaged image

See also

circular_average

compute circular average of an image Pixels smaller than the minimum radius are set to the value at that minimum radius. Pixels larger than the maximum radius are set to zero.

bin_grid

Bin and integrate an image, given the radial array of pixels Useful for nonlinear spacing (Ewald curvature)

Notes

Some pixels may not be filled if the dimensions chosen are too large.

Run this code again on a list of values equal to 1 to obtain a mask (and set left=0 and right=0).

skbeam.core.image.construct_rphi_avg_image(radii, angles, image, mask=None, center=None, shape=None, pixel_size=(1, 1))

Construct a 2D Cartesian (x,y) image from a polar coordinate image.

Assumes a 2D array of data. If data is missing, use mask.

Parameters
radii1d array of coordinates, ascending order.

The radii values (in units of pixels) These may be non-uniformly spaced.

angles1d array of coordinates, ascending order

The angle values (in units of radians) Domain must be monotonically increasing (or a subset) if we plot the reconstructed image in a typical x-y plane, where x are the columns of the image and y are the rows (img[y,x]), then 0 degrees is the -x direction, and ascending angle goes clockwise in this plane. These may be non-uniformly spaced. Note that if the domain interval exceeds 2*pi, values outside this range are ignored for interpolation. Ex : angles = [0, …, 6.25, 2*np.pi]

The last point modulo 2*pi is 0 which is the same as first point so it is ignored

image2d array the image to interpolate from

rows are radii, columns are angles, ex: img[radii, angles]

mask2d array, optional

the masked data (0 masked, 1 not masked). Defaults to None, which means assume all points are valid.

center2 tuple of floats, optional
shapethe new image shape, in terms of pixel values
Returns
new_img2d np.ndarray

The reconstructed image. Masked regions are filled with np.nan

skbeam.core.image.find_ring_center_acorr_1D(input_image)

Find the pixel-resolution center of a set of concentric rings.

This function uses correlation between the image and it’s mirror to find the approximate center of a single set of concentric rings. It is assumed that there is only one set of rings in the image. For this method to work well the image must have significant mirror-symmetry in both dimensions.

Parameters
input_imagendarray

A single image.

Returns
calibrated_centertuple

Returns the index (row, col) of the pixel that rings are centered on. Accurate to pixel resolution.