JuliaImages / ImageFiltering.jl

Julia implementations of multidimensional array convolution and nonlinear stencil operations
Other
99 stars 49 forks source link

mapwindow no longer works with Int window #58

Closed bjarthur closed 6 years ago

bjarthur commented 6 years ago
julia> mapwindow(median, rand(10), -1:1)
10-element Array{Float64,1}:
 0.0333407
 0.11721  
 0.206572 
 0.227984 
 0.227984 
 0.158748 
 0.158748 
 0.258269 
 0.258269 
 0.203693 

julia> mapwindow(median, rand(10), 3)
ERROR: MethodError: Cannot `convert` an object of type Array{Int64,1} to an object of type CartesianIndex
This may have arisen from a call to the constructor CartesianIndex(...),
since type constructors fall back to convert methods.
Stacktrace:
 [1] make_buffer_values_realistic! at /home/arthurb/.julia/v0.6/ImageFiltering/src/mapwindow.jl:238 [inlined]
 [2] compute_output_eltype(::Base.#median, ::Array{Float64,1}, ::UnitRange{Int64}, ::ImageFiltering.Pad{0}, ::Tuple{Base.OneTo{Int64}}) at /home/arthurb/.julia/v0.6/ImageFiltering/src/mapwindow.jl:227
 [3] allocate_output at /home/arthurb/.julia/v0.6/ImageFiltering/src/mapwindow.jl:213 [inlined]
 [4] _mapwindow at /home/arthurb/.julia/v0.6/ImageFiltering/src/mapwindow.jl:76 [inlined]
 [5] #mapwindow#1(::Symbol, ::Function, ::Function, ::Array{Float64,1}, ::Int64, ::String, ::Tuple{Base.OneTo{Int64}}) at /home/arthurb/.julia/v0.6/ImageFiltering/src/mapwindow.jl:58
 [6] mapwindow(::Function, ::Array{Float64,1}, ::Int64) at /home/arthurb/.julia/v0.6/ImageFiltering/src/mapwindow.jl:55
bjarthur commented 6 years ago

actually, this works:

julia> mapwindow(median, rand(10), (3,))
10-element Array{Float64,1}:
 0.907521 
 0.255418 
 0.249157 
 0.249157 
 0.211903 
 0.211903 
 0.153337 
 0.158342 
 0.153337 
 0.0688542

so technically the mapwindow docstring is accurate. however, just specifying 3 used to work. some might perceive this as a breaking change that should have a deprecation.

jw3126 commented 6 years ago

Thanks for reporting this. Its a bug and I will fix it!