ijpb / MorphoLibJ

Collection of mathematical morphology methods and plugins for ImageJ
http://imagej.net/MorphoLibJ
GNU Lesser General Public License v3.0
98 stars 49 forks source link

Question about "Extended Maxima" #47

Closed tischi closed 2 years ago

tischi commented 3 years ago

@dlegland triggered by the discussion on the forum (https://forum.image.sc/t/call4help-3d-dense-nuclei-segmentation-challenge/23462/21) I had a look at MLJ.

I am confused about this function: https://github.com/ijpb/MorphoLibJ/blob/26470aa8aef8203af303b8c0e60d1257753e5d87/src/main/java/inra/ijpb/morphology/MinimaAndMaxima3D.java#L299

And this (corresponding?) menu entry: Plugins › MorphoLibJ › Minima and Maxima › Extended Min & Max 3D

Reading the name ("Extended Min & Max 3D") of the menu entry I would expect that it takes all regional maxima and extends them, including all connected pixels with v > (v_regional_max - dynamic).

However, what it seems to do is to (also?) filter out some maxima, i.e. I am getting less maxima using the "Extended" vs. the "Regional" algorithm. Is that correct? If so, according to which criteria does the "Extended" version filter maxima?

dlegland commented 3 years ago

Hi,

I would expect that it takes all regional maxima and extends them, This is not really how it works. In facts, some pixels/voxels may belong to a regional minima/maxima, without being included in an extended minima/maxima.

One way to consider things is to imagine the (morphological) reconstruction of the image, constrained by the same image minus the value of the dynamic. Then, a minima with a small dynamic will disappear after the reconstruction.

So the criterium to remove minima/maxima is the value of the dynamic value uused to remove them. Hope this makes things more clear? Maybe I will eed to update the manual also!!!

best, David

tischi commented 3 years ago

Thanks! So this is in fact something like the tolerance/h-maxima/prominence? I think it would be very helpful to have a (1D) example of the workflow, including how the images look before and after the reconstruction a.s.o. Do you think this is doable? Otherwise pretty hard to understand even for professional bioimage analysts ;-)

dlegland commented 3 years ago

I have started an illustration in 1D case. You can find it here: https://github.com/ijpb/MorphoLibJ/blob/master/doc/MorphoLibJ-manual/images/reconstruction/extendedMaxima.png

I have the book of Soille under the eyes, the workflow is as follow:

  1. start from function f (-> the dark curve)
  2. consider function f-h, where h is the contrast or dynamic (-> the dashed curve)
  3. perform morphological reconstruction by dilation of (f-h) under f (-> the blue region)
  4. compute the regional maxima of the reconstruction (-> the dark blocks)

On the example, a value of two units was used for the dynamic. Note that the position of the maxima may change for larger value of dynamic. For example, using a dynamic of 1 unit results in same number of maxima, but smaller. Using a value of 3 units will make the left-most maxima disappear.

It is possible to value the maxima depending on the dynamic value that make them disappear, but this is not (yet?) implemented in MLJ.

tischi commented 3 years ago

@dlegland This is great! Thank you very much! I think one has all the functions to do this in MLJ, right? So I could write a macro with line profiles in ImageJ to reproduce this, isn't it?

dlegland commented 3 years ago

you're welcome! Figure should be included in manual as well, but I'm currently fighting with LaTeX...

Otherwise yes, you can reproduce with macro. The critical point is the reconstruction, but it is easily scriptable.

best! David