Macro script for Watershed Segmentation

Hi Everyone,

Since I need to proceed a series of 250 images for the same procedure, I am having difficulty with Watershed Segmentation. Doing the procedure for an image and recording by Macro, it just showed me a command of “run(“Watershed Segmentation”);” only, and a new window pop-up that I need to click “Start Watershed” to run it. Therefore, when putting just only the command of <run(“Watershed Segmentation”)> into Macro script, it can’t get done.

Is there any one ever done the Macro script with Watershed segmentation, or is there any expert who can get it done can help? I’m very much appreciated cause I am a pretty new ImageJ user.
Thank you very much.

Regards,
Vu T.

@vutruong

So… there are multiple options for watershed… but for the built-in version of watershed (Process > Binary > Watershed), I think the call is run("Watershed");. At least that is what it says when I use the Macro Recorder

Does this help?

eta

Hi Etarena,

I plan to use Watershed Segmentation, which is a plugin available from here https://imagej.nih.gov/ij/plugins/watershed.html

Thank you.

Vu T.

@vutruong

I am not sure how compatible that particular plugin is regarding scripting… so there are other plugins that you can consider:

  • The built-in version of watershed (Process > Binary > Watershed), calling run("Watershed");
  • MorphoLibJ library options:
    ** Classic Watershed - plugin implementing the original watershed algorithm by Pierre Soille and Luc M. Vincent (1990)
    ** Distance Transform Watershed - two plugins (2D and 3D) that work on binary images and allow to separate touching objects by combining the distance transform and watershed methods.
    ** Marker Controlled Watershed - - a plugin to perform watershed by flooding from specific seed points or markers by Meyer and Beucher (1990)
    ** Morphological Segmentation - a plugin with a graphical user interface to segment 2D/3D images based on morphological operations and the watershed algorithm.

Is there a reason you need to use that particular plugin - Watershed Algorithm? These other options are more-recently developed, and the developers are active here on the forum should you need help.

Just something to consider if you can make the switch…

eta

4 Likes

Hi Ellen,

Actually I want to calculate volume of my objects. However, I don’t know why using other segmentation doesn’t really separate my objects, and they will give me the results of total volume.

Except doing Watershed Segmentation, they will provide me a volume list of my objects.

Honestly I don’t really understand all the algorithms for Segmentation and trying to reach out the appropriate tool to analyze my data.

I wanna upload my raw file so you can have more idea. But it cant be uploaded, even I converted to tiff images or so. Is there any advice?

Thank you tons for your advice so far.

Vu T.``

@vutruong

Check out those links above… those tools are compatible with volumetric datasets.

Try again now to upload your images here on the Forum… I raised your trust level - so might have been a ‘new user’ issue before?

eta

Hi Ellen,

Yes, I tried all of them. They mostly gives me a total volume of 1 object but separates into individual ones. What I did was that applied the segmentation and analyzed by 3D object counter.
But if I use Watershed Segmentation with default setting, they will give me a volume list of objects…

I uploaded the image. Can you take a look? Thank you very much.

Vu T.

@vutruong

I’m not sure the uploading of your image worked correctly… it is a single slice RGB image. This is not correct - right?

What in your image do you consider an ‘object’? It is so pixelated… I am not sure how you can definitively define an object within… Can you post the original datasets you acquired?

eta

Hi @vutruong, I have the same problem as yours that I need to do watershed before using the 3D object counter. But the Watershed in Process-Binary also just gave me one object. Could you tell me how did you successfully split the objects and use the 3D object counter?

Hi Wenbin,

I found out that for my images, after doing Watershed and 3D Object Counter, the result just showed me a volume of 1 object detected. All probably meant that all my objects are connected. I expected to separate the black spots in the images to be individual ones, however, it seems not to be possible in my system.

Hi Ellen,

Sorry I didn’t realize your message. Thanks for your help and concerns.
Vu T.