level_image

Stoner.Image.imagefuncs.level_image(im, poly_vert=1, poly_horiz=1, box=None, poly=None, mode='clip')[source]

Subtract a polynomial background from image.

Keyword Arguments:
  • poly_vert (int) – fit a polynomial in the vertical direction for the image of order given. If 0 do not fit or subtract in the vertical direction

  • poly_horiz (int) – fit a polynomial of order poly_horiz to the image. If 0 given do not subtract

  • box (array, list or tuple of int) – [xmin,xmax,ymin,ymax] define region for fitting. IF None use entire image

  • poly (list or None) – [pvert, phoriz] pvert and phoriz are arrays of polynomial coefficients (highest power first) to subtract in the horizontal and vertical directions. If None function defaults to fitting its own polynomial.

  • mode (str) – Either ‘clip’ or ‘norm’ - specifies how to handle intensitry values that end up being outside of the accepted range for the image.

Returns:

A new copy of the processed images.

Fit and subtract a background to the image. Fits a polynomial of order given in the horizontal and vertical directions and subtracts. If box is defined then level the entire image according to the gradient within the box. The polynomial subtracted is added to the metadata as ‘poly_vert_subtract’ and ‘poly_horiz_subtract’