Project-MONAI / Project-MONAI/MONAI
CropForegroundd on ROI with text
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.7k
- Forks
- 1.6k
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 20
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the CropForegroundd transform entry point and reproduce the provided NumPy example with the mammogram containing text or markers. Determine how select_fn produces the foreground bounding box and clarify the intended rule for excluding annotations while retaining the breast region. Done means the behavior is covered by a regression test and the crop no longer expands to include the unwanted text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100