Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watershed bugs #18

Open
haesleinhuepf opened this issue Jul 26, 2020 · 8 comments
Open

Watershed bugs #18

haesleinhuepf opened this issue Jul 26, 2020 · 8 comments

Comments

@haesleinhuepf
Copy link
Member

Dear future-self,

the current Watershed-implementation is not very good. It has two issues:

  • It cuts the binary objects in to many places
  • It removes the outer rows of pixel.

Both could be fixed by taking over some improvements in ParametricWatershed in CLIJx. After some testing period there, we should copy it over.
https://github.com/clij/clijx/blob/master/src/main/java/net/haesleinhuepf/clijx/plugins/ParametricWatershed.java#L34-L49

Cheers,
past-self

@psobolewskiPhD
Copy link

I can concur here.
Using CLIJ2_watershed gave rather strange results in the case of thresholded images of Hoechst stained nuclei (I've attached a representative image, a merged tile scan, as .TIF in the zip.)
It often cuts symmetric, but oval shapes at an angle. see:
CLIJ_WS_1
But misses seemingly obvious objects to cut:
CLIJ_WS_2
Process>Binary>Watershed cuts the left object in half as expected.
And then there are a few objects like this, where I have no idea what is going on:
CLIJ_WS_3
(Nota bene, the Process>Binary>Watershed also cuts this object in half for some reason, but just once.)
CLIJ2_parametricWatershed is better behaved, although it's not entirely clear to me how to choose sigma. My objects are on avg. around 40 px in diameter, so radii largely in the 15-30 px range.
Naively, I first tried 30 px and then 15 px and got no cuts.
Smaller sigma got me close to the Process>Binary>Watershed
1 px brings back the odd cuts of intact objects, while still missing cuts as above.
3 px eliminates the clearly spurious cuts, but still misses a couple that seem rather obvious to me, that are cut byt Process>Binary>Watershed.
5 px produces the same results as 3 px
at 10 px start to see cuts missed.

2021040_H33342_L929_24w_A3_tilescan.lif - A3 Region1_Merged.tif.zip

@haesleinhuepf
Copy link
Member Author

haesleinhuepf commented May 22, 2021

Hey @psobolewskiPhD ,

I'd recommend using the approaches by MorpholibJ, SimpleITK and ImageJ1. All are available as CLIJ extensions and can thus be called as other CLIJ functions from Macro:
https://clij.github.io/clij2-docs/reference_morphoLibJClassicWatershed
https://clij.github.io/clij2-docs/reference_morphoLibJMarkerControlledWatershed
https://clij.github.io/clij2-docs/reference_simpleITKMorphologicalWatershed
https://clij.github.io/clij2-docs/reference_imageJWatershed

See the installation instructions for the extensions:
https://clij.github.io/assistant/installation#extensions

@psobolewskiPhD
Copy link

I already switched to
Ext.CLIJx_imageJWatershed(opened, WS);
Based on the code example from @mycroscopy via Twitter.
The results are—for me—better.

Briefly checking out the other options (copy pasta coding), they don't "work"—I guess they need greyscale as input and I'm already thresholding, etc.?
Also, perhaps the CLIJ docs could link to the morphoLib docs where appropriate?

@haesleinhuepf
Copy link
Member Author

haesleinhuepf commented May 23, 2021

Briefly checking out the other options (copy pasta coding), they don't "work"—I guess they need greyscale as input and I'm already thresholding, etc.?

Can you please precisely write what you tried and what didn't work? It's otherwise very hard to answer that. If it's related to other operations and not watershed, please open a new github issue or image.sc thread, post example code and data. I will then give my best to assist you 🙂

@psobolewskiPhD
Copy link

Oh, sorry for expressing myself poorly.
I wasn't able to get my code to work with those as "drop ins" for the
Ext.CLIJx_imageJWatershed(opened, WS);
(which works perfectly, so for me the issue—bizarre watershed results from CLIJ—is solved.

Regarding the other options, it's not that the commands/extensions don't work, but that I don't understand the proper usage, just from the CLIJ docs. E.g.
Ext.CLIJx_morphoLibJClassicWatershed(Image gradient_input, Image binary_restriction_input, Image destination, Number h_min, Number h_max);
My input is a binary obtained by thresholding & binary open, so I think it's just not the proper input to that morphoLib process. I need to spend some time with the morphoLib docs at some point to figure out if changing anything/everything is worth it. (and frankly, your Otsu-Voronoi extension may just be the best options anyways.)

@haesleinhuepf
Copy link
Member Author

haesleinhuepf commented May 24, 2021

I don't understand the proper usage

I see. I just added a mini tutorial. It will be automatically linked from the documentation after it's rebuilt.
https://clij.github.io/clij2-docs/md/morpholibj_classic_watershed/

I will also add links to the MorphoLibJ documentation. Thanks for the suggestion!

Let me know if there remains something unclear.

@psobolewskiPhD
Copy link

The tutorial is amazing—going well above the call of duty! You really didn't have to do that!
The MorphoLib documentation is quite good, so I would have (probably) figured out something myself; I just haven't had time.

@haesleinhuepf
Copy link
Member Author

No big deal, it was made with imagejmacromarkdown ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants