-
Notifications
You must be signed in to change notification settings - Fork 20
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
A mathematical morphology framework for Imglib2. #2
Conversation
Derived from the Rectangle Shape, but that can be non-square. Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Shape implementation for neighborhoods that are lines parallel to one of the image axis. Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
as defined by Jones and Soilles. Periodic lines: Definition, cascades, and application to granulometries. Pattern Recognition Letters (1996) vol. 17 (10) pp. 1057-1063 Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Morphological operations greatly benefit from structuring elements decomposition. This class provides utility methods that generates classical structuring elements as a List<Shape>. Whenever possible, the list is made of a decomposition to speed up morphological operations. Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
With a JUnit test. Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
From my perspective, this PR is awesome and should be merged ASAP. It is well structured, provides many new features and lots of corresponding unit tests. Since the @tpietzsch Do you agree? |
Thanks @ctrueden! But arrgh you edited your comment! |
Wrong button sorry. |
I just wanted to clarify that I didn't see any problems with the PR. I was afraid that my previous wording somehow implied that I did. That said, I did not scrutinize the code in great detail. I thought probably @tpietzsch would be the best person to approve the design. |
I reviewed the code today. Looks great. I will comment in detail tomorrow |
@tinevez Fantastic work! I have no problem to merge this as-is. I have gone through the code pretty thoroughly and I have some suggestions for improving it, respectively consolidating with existing stuff.
Here, you try to use
Finally, a general remark: Maybe the concept of Shape not having a dimensionality was a bit misguided. At the hackathon, with Christian Dietz I already discussed the distinction between Region and Shape, and that maybe this distinction should go away and every Region can besides being an actual Region also be a "Region-Template", so more or less what shape is intented to be. A bit of awkwardness would go away (such as the need for |
also some comments from my side: In tinevez@9488d66 for example, you pass the number of threads for multi-threading. It would be nicer if you could pass a Additionally, in tinevez@9488d66, the name of the threads are still "Erode XY", even if the concept is more general. Maybe you want to change the names of the created threads? Concerning the "package" names/location of neighborhoods (@tpietzsch, @tinevez): |
Hi all Thank you very much for the time you spent reviewing this. I hope that 1. Static inner classes
Will do *2. *RectangleShape and CenteredRectangleShape should be unified and
Will do. *3. *Neighborhoods should all move to a common place. It makes no sense to
Agreed. I will do this *before *merge if this is fine.
Will do.
Will do. *6. *In Dilation and Erosion: Note, that it is not necessary to use
Yes, there is two cases for despair here. The second operation needs to access the pixels beyond the source image.
Boarf is it that useful? Please tell me.
*10. *Fix thread names in MorphologyUtils.copy() and copy2(). (I would
Will do.
I am in favor of unifying Region and Shape, and give a dimensionality in Ok, so thank you again, I now have my TODO list done. And I will summarize |
TODO before merge:
|
@dietzc : About the This is the reason why I stick to |
Have a closer look at the method you are mentoining. This method doesn't use the number of threads at all (just to determine the number of tasks). The About number of threads: actually you only need this to determine an "optimal" number of tasks. The number of total threads is controlled by the |
Signed-off-by: Jean-Yves Tinevez <jeanyves.tinevez@gmail.com>
Signed-off-by: Jean-Yves Tinevez <jeanyves.tinevez@gmail.com>
Signed-off-by: Jean-Yves Tinevez <jeanyves.tinevez@gmail.com>
…ngleShape. Signed-off-by: Jean-Yves Tinevez <jeanyves.tinevez@gmail.com>
Signed-off-by: Jean-Yves Tinevez <jeanyves.tinevez@gmail.com>
Signed-off-by: Jean-Yves Tinevez <jeanyves.tinevez@gmail.com>
Signed-off-by: Jean-Yves Tinevez <jeanyves.tinevez@gmail.com>
It fails as soon as your machine is significantly multi-tasking, I think. It is also too greedy, if you know you want to perform two simultaneous tasks: the first task will take 4/4 processors, and the second task will claim only 1 (since that value is never less than 1), for a total of 5/4 processors allocated to the tasks. It seems crystal clear that we need a way for calling code to explicitly control the multithreading details. At bare minimum, we need the power to say "use X threads", but that alone is still not ideal. The advice in the javadoc is: "This value may change during a particular invocation of the virtual machine. Applications that are sensitive to the number of available processors should therefore occasionally poll this property and adjust their resource usage appropriately." That approach would mitigate the greedy problem mentioned above. But my intuition is still that it is too limited in scope. |
Sure, but which part should be handled by the |
I guess it depends how obsessive we want to be about optimizing performance. I have not thought about this problem seriously for hours, so my perspective may be naive. But my current intuition is that it would be ideal to be able to adjust the number of workers for a task after that task has already been launched. Otherwise, when one task completes, its freed threads (freed processors, really) will become underutilized. If we don't want to worry about that for now, and only want to worry about an API that launches tasks with good numbers of threads, then the |
@tpietzsch Apart from the discussion on multithreading, it's up to you: |
I would love to see the ability to set the |
@dietzc Could we discuss this in details elsewhere? |
Skype tomorrow? |
@dietzc I need to prepare my rant. Can I confirm later? |
Sure. |
@tinevez and me agreed that we should merge if this PR if everything beside the multi-threading is fine. I will open a PR with my suggestions afterwards and we can have a dedicated discussion in this PR then. @tpietzsch sounds good? |
@tpietzsch done. |
A mathematical morphology framework for Imglib2.
@tinevez Thanks a lot! This is really cool stuff. |
great. should we release imglib2, imglib2-algorithm & imglib2-roi? |
Thanks to you all, it was a fantastic trip. |
@dietzc done. pretty much everything imglib2 was released. current versions are listed in pom-imglib2 5.2.1 (or rather in its parent pom-imagej 5.12.3) |
Thank you! One beer on me. |
This PR supersedes #1.
This PR ships a small mathematical morphology framework for Imglib2.
Rather than documenting what it does and how to use it, I put documentation and benchmarks on Imglib2 wiki.
Though mathematical morphology extends far beyond what is contained in this PR, I wish to subject it to the team scrutiny early.
For instance, this PR contains several calls to deprecated classes, I did not know how to workaround.