in ez_wsi_dicomweb/dicom_slide.py [0:0]
def get_image_bytes_samples_per_pixel(image_bytes: np.ndarray) -> int:
"""Returns the number of samples per pixel in the image.
Args:
image_bytes: Uncompressed image bytes (e.g., 8 bit RGB)
Raises:
ez_wsi_errors.GcsImageError: If the image is not 2D or 3D.
"""
if len(image_bytes.shape) == 2:
return 1
elif len(image_bytes.shape) == 3:
return image_bytes.shape[2]
raise ez_wsi_errors.GcsImageError(
f'Invalid image shape: {image_bytes.shape}. Image must be 2D or 3D.'
)