Describe the bug
CropForegroundd works very well for mammography images that contain only the breast and background. However, some mammograms also contain foreground text or markers (e.g., laterality labels, acquisition text, scanner annotations). Since these annotations are non-zero pixels, they are detected as foreground by select_fn, causing the computed bounding box to include them and resulting in a larger crop than desired.
To Reproduce
input:
import numpy as np
from monai.transforms import CropForegroundd
transform = CropForegroundd(
keys=["image"],
source_key="image",
)
output = transform({"image": input_array})
cropped = output["image"]
cropped = np.transpose(cropped, (1, 2, 0))
Output returns same as input with text label.
Expected behavior
Maybe only return the breast region.
Describe the bug
CropForegrounddworks very well for mammography images that contain only the breast and background. However, some mammograms also contain foreground text or markers (e.g., laterality labels, acquisition text, scanner annotations). Since these annotations are non-zero pixels, they are detected as foreground byselect_fn, causing the computed bounding box to include them and resulting in a larger crop than desired.To Reproduce
input:
Output returns same as input with text label.
Expected behavior
Maybe only return the breast region.