laserbeamsize.background Module

Routines for removing background for beam analysis.

Full documentation is available at <https://laserbeamsize.readthedocs.io>

Two functions are used to find the mean and standard deviation of images. corner_background() uses just the corner pixels and iso_background() uses all un-illuminated pixels:

>>> import imageio.v3 as iio
>>> import laserbeamsize as lbs
>>>
>>> file = "https://github.com/scottprahl/laserbeamsize/raw/master/docs/t-hene.pgm"
>>> image = iio.imread(file)
>>>
>>> mean, stdev = lbs.corner_background(image)
>>> print("The corner pixels have an average         %.1f ± %.1f)" % (mean, stdev))
>>> mean, stdev = lbs.iso_background(image)
>>> print("The un-illuminated pixels have an average %.1f ± %.1f)" % (mean, stdev))

In addition to these functions, there are a variety of subtraction functions to remove the background. The most useful is subtract_iso_background() which will return an image with the average of the un-illuminated pixels subtracted:

>>> import imageio.v3 as iio
>>> import laserbeamsize as lbs
>>>
>>> file = "https://github.com/scottprahl/laserbeamsize/raw/master/docs/t-hene.pgm"
>>> image = iio.imread(file)
>>>
>>> clean_image = subtract_iso_background(image)

Functions

corner_background(image[, corner_fraction])

Return the mean and stdev of background in corners of image.

iso_background(image[, corner_fraction, nT])

Return the background for unilluminated pixels in an image.

subtract_background_image(original, background)

Subtract a background image from the image with beam.

subtract_constant(original, background[, ...])

Return image with a constant value subtracted.

subtract_corner_background(image[, ...])

Return image with background subtracted.

subtract_iso_background(image[, ...])

Return image with ISO 11146 background subtracted.

subtract_tilted_background(image[, ...])

Return image with tilted planar background subtracted.