scipy / scipy

SciPy library main repository
https://scipy.org
BSD 3-Clause "New" or "Revised" License
12.9k stars 5.13k forks source link

ENH: Add mode='valid' to morphology operators such as ndimage.grey_dilation, ndimage.grey_erosion etc. #20126

Open LucasRr opened 6 months ago

LucasRr commented 6 months ago

Mathematical morphology operators such as ndimage.grey_dilation, ndimage.grey_erosion only offer to pad the input with different modes {‘reflect’,’constant’,’nearest’,’mirror’, ‘wrap’}. It would be nice to be able to do have a valid mode that doesn't do any padding, like in signal.convolve.

At the moment the only way to do a valid dilation is to do a padded dilation, and to crop the output to only keep the valid samples. However this is prone to errors, and this is highly inefficient when the structure size is relatively large compared to the input.

This issue is somewhat related to this other existing issue for ndimage.convolve.

omid-Tajalizadeh commented 4 months ago

I also have the same problem. Can Scipy or someone please mitigate this issue or propose a solution? #17431