computational-cell-analytics / micro-sam

Segment Anything for Microscopy
https://computational-cell-analytics.github.io/micro-sam/
MIT License
311 stars 35 forks source link

Automatic segmentation settings #628

Open aloboa opened 4 weeks ago

aloboa commented 4 weeks ago

Where could I find documentation on the settings for Automatic segmentation? I find little change in the results when I modify the values. Also, no difference if selecting "with background" or not.

anwai98 commented 4 weeks ago

Hi @aloboa,

Thanks for your interest in micro-sam.

Could you help us with some context of your images and what is your desired task?

In any case, we have some documentation on Annotator Tools and brief explanations on using the automatic segmentation with the 2d, 3d and image series annotator.

constantinpape commented 4 weeks ago

In addition to the points raised by @anwai98 can you also explain which model you're using? Also, it would be very helpful if you can share an example screenshot with the image, the segmentation result and the corresponding paramters.

aloboa commented 4 weeks ago

Context:

We are dealing with SEM images of petrographic thin sections of volcanic rocks. We want to:

  1. Segment everything in the SEM image to use an object-based approach to identify different geologic material materials by stacking images of different sources in a similar way as done with multi-spectral imagery.
  2. Define an efficient interactive labeling method to label the most important structures.

My question here concerns mainly 1, although the current results could also be taken as an initial step for interactive labeling.

Example: input DI17_2.tif DI17_2

Annotator2d Model: vit_b Automatic Segmentation Settings pred_iou_thresh: .88 stability_score_thresh: .95 box_nms_thresh: .70 min_object_size: 100

Results:

The most surprising is the small difference between selecting/unselecting with_background.

Note that having at least an approximation of the area covered by lighter grey and darker grey of what has not been segmented in any of these results ("background"), is important for us. Perhaps I can address this using more traditional methods such as an Otsu threshold.

I would like to run a set of tests with different models and different settings, but I need to understand the settings first.

anwai98 commented 3 weeks ago

Hi @aloboa,

Thanks for sharing the details, I'll try to address the aforementioned discussion point-wise:

  1. Segment everything in the SEM image to use an object-based approach to identify different geologic material materials by stacking images of different sources in a similar way as done with multi-spectral imagery.

I tried performing automatic segmentation using the default Segment Anything model (vit_b), and looks like the model has a tendency of segmenting the darker holes on the surface of volcanic rocks (similar results to the ones you posted).

  1. Define an efficient interactive labeling method to label the most important structures.

I tried annotating a few structures around with boxes and points, I think both work fine to annotate different types of structures in your images. As a minor mention, I would recommend to focus on segmenting one structure as one object at a time, and continue with the next object for segmentation.

My question here concerns mainly 1, although the current results could also be taken as an initial step for interactive labeling.

I would propose the same, you can take the results from the automatic segmentation as a starting point, and use interactive annotation for labelling all other structures you are interested in. Once you have labelled all the relevant structures, you can finetune Segment Anything on your data to attain a better approach to segment everything in SEM images using automatic segmentation.

Re: Annotator2d (with different parameters)

You can adjust the parameters as you like by reducing them from the defaults to capture more objects, however remember that it might also lead to capturing unnecessary artefacts / undesired objects.

One question: are you using the tiling option in micro-sam? (if yes, that's fine. If not, I just tried it, and using tiling-based segmentation option does help you capture more relevant objects with the default parameters. Here's a hint: FAQ -> Usage questions -> Point 3 on it's usage)

Hope this answers your questions!

aloboa commented 3 weeks ago

As you say, reducing the value of stabillity_score_thresh makes it possible to observe differences between with and without background, but the results are the inverse of what I expected:

with_background not selected

image

with_background selected image

One question: are you using the tiling option in micro-sam?

I can't seem to find it, where is this option?

Before I start to run more tests, is there any place where I can read the definitions of the settings?

anwai98 commented 3 weeks ago

Hi @aloboa,

Apologies for not being clear about the feature. When you select / add check to the with_background feature, this means that you are choosing to remove the large background area, and vice-versa while not selected / removed check (i.e. you are choosing to keep the large background area). There is a tooltip to most of the features, you will see the message pop-up when you hover over the menu options.

I can't seem to find it, where is this option?

This feature can be activated using either the napari GUI or the command line. Here's the hint to guide you better for using the tiling-based feature: FAQ -> Usage questions -> Point 3.

Before I start to run more tests, is there any place where I can read the definitions of the settings?

Most settings' menu options have a tooltip (i.e. when you hover over the menu option, you will find a brief description). If you want more detailed information on some specific features, let us know.