Skip to content

hough_circle_gradient: centers could hold 0 in CartesianIndex #67

@AmebaBrain

Description

@AmebaBrain

centers calculation could result in 0 in CartesianIndex. which is invalid value for array referencing in Julia

julia> centers, radii = hough_circle_gradient(img_edges, img_phase, 20:30, vote_threshold=2);

julia> img_demo = Float64.(img_edges); for c in centers img_demo[c] = 2; end
ERROR: BoundsError: attempt to access 312×252 Array{Float64,2} at index [152, 0]
Stacktrace:
 [1] setindex! at ./array.jl:769 [inlined]
 [2] setindex!(::Array{Float64,2}, ::Int64, ::CartesianIndex{2}) at ./multidimensional.jl:460
 [3] top-level scope at ./REPL[40]:1 [inlined]
 [4] top-level scope at ./none:0

julia> centers
96-element Array{CartesianIndex{2},1}:
 CartesianIndex(152, 0)  
                        
 CartesianIndex(0, 40)   

Probably this happens during executing this statement: center=(center-1*one(center))*scale

julia> c = CartesianIndex(1, 2)
CartesianIndex(1, 2)

julia> c = (c - 1*one(c))
CartesianIndex(0, 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions