def convert_mask_to_locations(mask):
""" Return the converted Cartesian mask as sampling locations.
Parameters
----------
mask: np.ndarray, {0,1}
2D matrix, not necessarly a square matrix.
Returns
-------
samples_locations: np.ndarray
list of the samples between [-0.5, 0.5[.
"""
row, col = np.where(mask == 1)
row = row.astype("float") / mask.shape[0] - 0.5
col = col.astype("float") / mask.shape[1] - 0.5
return np.c_[row, col]
评论列表
文章目录