Project-MONAI / Project-MONAI/MetricsReloaded
MorphologyOps.foreground_component() ignores connectivity parameter, always uses 1-connectivity
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 104
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
Problem Description
The MorphologyOps class in 1 accepts a connectivity parameter during initialization, but the foreground_component() method 2 completely ignores this parameter and always uses scipy's default 1-connectivity (4-connectivity for 2D, 6-connectivity for 3D).
Current Behavior
def foreground_component(self):
return ndimage.label(self.binary_map) # No structure parameter specified
When scipy.ndimage.label() is called without the structure parameter, it defaults to:
structure = _morphology.generate_binary_structure(input.ndim, 1) # 1-connectivity
Expected Behavior
The method should respect the connectivity parameter passed during class initialization, similar to how other methods in the class use self.connectivity.
Evidence of Inconsistency
-
Class initialization accepts connectivity: 1
-
Other methods use connectivity: Other methods in the codebase properly use the connectivity parameter, as seen in 3
-
Real usage expects different connectivity: In practice, the class is instantiated with different connectivity values, such as
neigh=6in 4
Proposed Solution
Modify the foreground_component() method to use the stored connectivity parameter:
def foreground_component(self):
structure = generate_binary_structure(self.binary_map.ndim, self.connectivity)
return ndimage.label(self.binary_map, structure=structure)
Impact
This inconsistency may lead to unexpected results in connected component analysis, especially for users who expect the specified connectivity to be applied consistently across all morphological operations.
Contributor guide
No contributing guide indexed for this repository
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 MorphologyOps.foreground_component() and compare it with initialization and the other methods that use self.connectivity. Done means connected-component labeling respects the configured connectivity, including usages such as neigh=6.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100