slmsuite.holography.toolbox.unpad
- unpad(matrix, shape)[source]
Helper function to unpad data. The padding is assumed to be centered. This is used to get higher resolution upon Fourier transform.
- Parameters
matrix (numpy.ndarray OR (int, int)) – Data to unpad. If this is a shape in
numpy
(h, w)
form, returns the four slicing integers used to unpad that shape[pad_b:pad_t, pad_l:pad_r]
.shape ((int, int) OR None) – The desired shape of the
matrix
innumpy
(h, w)
form. IfNone
, thematrix
is returned unchanged.
- Returns
Either the unpadded
matrix
or the four slicing integers used to unpad such a matrix, depending what is passed asmatrix
.- Return type
numpy.ndarray OR (int, int, int, int)