COSIE.image_preprocessing.generate_pxl_location_from_mask
- generate_pxl_location_from_mask(mask_image)[source]
Extract pixel and spatial coordinates of 16×16 superpixels whose top-left pixels fall within the white (255) region of a binary mask.
Parameters
- mask_imagenp.ndarray
A 2D binary mask array. Pixels with value 255 are considered valid, i.e., within the tissue or region of interest (ROI).
Returns
- filtered_coordinatesnp.ndarray of shape (N, 2)
Pixel coordinates (in image space) of valid 16×16 superpixels. Each coordinate represents the top-left corner of a 16×16 block.
- spatial_locationnp.ndarray of shape (N, 2)
Spatial locations obtained by dividing pixel coordinates by 16. Typically used for spatial indexing or grid-based embedding.