Images.jl
Images.jl copied to clipboard
Where/If to add these functions?
I noticed in JuliaImages doc that the function find_boundaries
is not listed for Julia. I would like to implement it(If not already implemented in Julia).
Also, for it's purpose I would like to implement something similar to generate_binary_structures
from scipy
https://github.com/scipy/scipy/blob/f2ec91c4908f9d67b5445fbfacce7f47518b35d1/scipy/ndimage/morphology.py#L122.
And, numpy.indices
from https://github.com/numpy/numpy/blob/ccfbcc1cd9a4035a467f2e982a565ab27de25b6b/numpy/core/numeric.py#L1800-L1868
So, I am not sure if these functions exists somewhere in Julia and if there is a need, then where should they be added?
I'm not sure about the other two, but for something like numpy.indices
, we would generally use Julia's CartesianIndices
:
julia> CartesianIndices((2,3))
2×3 CartesianIndices{2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}:
CartesianIndex(1, 1) CartesianIndex(1, 2) CartesianIndex(1, 3)
CartesianIndex(2, 1) CartesianIndex(2, 2) CartesianIndex(2, 3)
Note that this returns a slightly different structure than numpy.indices
, as CartesianIndices gives you paired (x, y) indices rather than separate arrays of x and y indices.
It would be fine to add. Of course we have edge-detection, but it's not really intended for labeled images. I would probably add it to connected.jl
in Images.jl.
As far as connectivity structures goes, check out the docstring and implementation of label_components
. This is very old code and hard for a newbiew to understand (it could use some refreshing), but the gist is that we can compile specialized methods for each given connectivity pattern---the stencil function only checks the ones that have been flagged as true
. If this is important and desirable, we should consider a more serious revamp of this code to allow it to be generalized.
Speaking of labeled components and connectivity, I think that for people transitioning from MatLab, equivalents to bwperim, regionprops, and imfill would be highly desirable.
@timholy I tried implementing the find_boundaries
function and this seems to be the result:
Original Image:
Produced Image:
I used the algorithm where a pixel will be considered a boundary if it's adjacent labels(based on the value of connectivity
used in label_components
) are not all same.
Also we can use this to mark the original image with boundaries with a user given colour.
So, should I apply this or is there a better way to do it?
Sounds good to me! I can review it when you push the code.
https://github.com/JuliaImages/ImageMorphology.jl/releases/tag/v0.3.1 now has the isboundary
function. Can this issue be closed?