rafaqz / Rasters.jl

Raster manipulation for the Julia language
MIT License
209 stars 36 forks source link

Feature request: mask dilation or pixel based distance #756

Open alex-s-gardner opened 1 week ago

alex-s-gardner commented 1 week ago

The Images package has a really powerful pixel distance calculation (similar to bwdist in matlab: https://www.mathworks.com/help/images/ref/bwdist.html)... I use it all the time in my work and suspect other would appreciate it as well..

Right now I do this:

Images.distance_transform(feature_transform(BitMatrix)) 

which return the pixel distance matrix.

I'm wondering if we should just stick with this or if there is a good reason to provide better integration between Rasters and Images such that users could do things like:

raster_mask_dialated = Rasters.dialate(raster_mask, 2)
raster_distance_from_mask = Rasters.pixeldist(raster_mask)

Not sure what the philosophy here is.

rafaqz commented 6 days ago

Why not add those functions to Images.jl for any array?

What's the advantage of Rasters defining them?

alex-s-gardner commented 6 days ago

This functions (capabilities) are in Images and can be preformed on any array.

I guess I was simply thinking that helper functions within Rasters would improve user experience as it's a bit of a lift to learn a new package to do what I would consider a common operation of mask dilation. But I also understand that it might not makes sense, as it adds complexity to Rasters and another dependency.. maybe it also goes against the ethos of compostability.

rafaqz commented 6 days ago

Yeah if it already works fine, it just needs documentation so people know they can do it. And maybe better syntax in Images.jl.

The case for adding it here is where it doesn't return a Raster, but should

alex-s-gardner commented 6 days ago

Going to leave this open to motivate the generation of an example.. and maybe improved Images.jl syntax

rafaqz commented 5 days ago

Yes maybe we can get a longer list of Images.jl things that should work here and put them in docs and testing, then push any syntax changes we want back to Images.jl