slmsuite.holography.toolbox.window_extent#

window_extent(window, padding_frac=0, padding_pix=0)[source]#

Find a square that covers the active region of the 2D boolean mask window.

Parameters:
  • window (numpy.ndarray<bool> (height, width)) – Boolean mask.

  • padding_frac (float) – If this default window has width w and height h, padding_frac proportionally changes these dimensions all sides. For instance, padding_frac=.5 would modify the dimensions to be w = 1.5w and h = 1.5h.

  • padding_pix (float) – Additional padding to add, in pixels. This is applied after padding_frac.

Returns:

window_extent – A rectangle that centered on the active region of window in the format (x, w, y, h) where (x, y) is the upper left coordinate, and (w, h) define the extent. This result is clipped to be within shape of the window.

Return type:

(int, int, int, int)