arttumiettinen / pi2

C++ library and command-line software for processing and analysis of terabyte-scale volume images locally or on a computing cluster.
GNU General Public License v3.0
48 stars 13 forks source link

Feature request: separate erosion and dilation operations #3

Closed schlepuetz closed 2 years ago

schlepuetz commented 2 years ago

Dear Arttu,

I have a few applications where it would be helpful to be able to apply simple erosion and dilation operations with a given kernel (round, rectangular, specified radius) to the images. The opening and closing filters must presumably already do some of this work internally (erosion followed by dilation, and vice versa)?

At the moment, I am working around this in a rather stupid and resource-consuming way: I calculate the distance map of the foreground (or inverted foreground) and then apply a threshold equal to the radius of the structuring element. So that works, but it's definitely not efficient ;-)

Nothing urgent at all, and maybe out of scope for you. So this is just meant as a gentle question whether such a feature would make sense for the package (which works really well!)?

Many thanks! Cheers, Christian

arttumiettinen commented 2 years ago

Hi Christian,

Good to hear that you have been able to benefit from the software. Your distance map approach might be surprisingly performant for larger structuring elements, as dmap algorithms have been studied and optimized a lot during the last 30 years.

The opening and closing operations use minfilter and maxfilter commands under the hood, i.e. opening = minfilter followed by maxfilter. Could these work for you?

Best, Arttu

schlepuetz commented 2 years ago

Hi Arttu,

OK, I have to ashamedly admit that this is a classical case of the user not reading the documentation carefully enough ;-) My apologies!

Of course, minfilter and maxfilter is exactly what I was looking for. I thought I really diligently went through all of the available commands, but I suppose that intuitively, I just had expected minfilter and maxfilter to be something different and hence did not look carefully enough.

I will keep an eye on the performance of minfilter/maxfilter vs. thresholding a distance map for larger kernels, that is quite interesting.

Many thanks for the help! Best, Christian