rotated_rect_mask

laserbeamsize.masks.rotated_rect_mask(image, xc, yc, dx, dy, phi, mask_diameters=3)[source]

Create ISO 11146 rectangular mask for specified beam.

ISO 11146-2 §7.2 states that integration should be carried out over “a rectangular integration area which is centred to the beam centroid, defined by the spatial first order moments, orientated parallel to the principal axes of the power density distribution, and sized three times the beam widths”.

This routine creates a mask with true values for each pixel in the image that should be part of the integration.

The rectangular mask is mask_diameters times the pixel diameters of the ellipse.

The rectangular mask is rotated about (xc, yc) and then drawn using PIL

Parameters:
  • image – the image to work with

  • xc – horizontal center of beam

  • yc – vertical center of beam

  • dx – ellipse diameter for axis closest to horizontal

  • dy – ellipse diameter for axis closest to vertical

  • phi – angle that elliptical beam is rotated [radians]

  • mask_diameters – number of diameters to include

Returns:

masked_image – 2D array with True values inside rectangle