facebookresearch / facebookresearch/segment-anything
Trying to use SAM to segment engineering rock samples, but I need to solve two issues
- Dominant language
- Jupyter Notebook
- Stars
- 54.9k
- Forks
- 6.4k
- PR merge metrics
- No merged PRs in 30d
Description
Hello, I am trying to use SAM to segment engineering rock samples as follows:

Here's a photo that contains a box of rock samples, and what I need to do is segment all the rocks and then choose the ones that is longer than a specific length(as we know the length of the box, we can easily calculate the length of each rock based on its pixel size).
By using SAM SamAutomaticMaskGenerator, I can get the segmented elements of this photo as follows:

However, there're two issues which I think should be solved first so that my final target can be reached:
The first one is the overlapping elements. As SAM may have **overlapping segment elements**, I may count **repeated** rocks. Is it possible to make SAM generate all non-overlapping elements?
The second one is how to separate the rocks from backgrounds. SAM segments everything including photo background, and is it possible so that I can only segment rocks?
I appreciate if anyone could help solve this issue. Thank you !
Contributor guide
Research direction
Start with the SamAutomaticMaskGenerator entry point and the provided rock-sample images. Determine whether the requested non-overlapping masks and rock-only filtering are supported by the current interface, and define the expected mask output for both cases before assessing a change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook
- Domain
- computer-vision, machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100