JuliaImages / ImageFiltering.jl

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

mapwindow doesn't work with 4D arrays #105

Closed ChantalJuntao closed 5 years ago

ChantalJuntao commented 5 years ago
A = rand(5,5,5)
mapwindow(mean, A, [1,1,3])

seems to work fine

A = rand(5,5,5,5)
mapwindow(mean, A, [1,1,1,3])

returns the following error

ERROR: MethodError: no method matching ntuple(::getfield(ImageFiltering.MapWindow, Symbol("##25#26")), ::Type{Val{4}})Closest candidates are:
  ntuple(::F, ::Integer) where F at tuple.jl:136
  ntuple(::Any, ::Val{0}) at tuple.jl:158
  ntuple(::Any, ::Val{1}) at tuple.jl:159
  ...
Stacktrace:
 [1] docopy! at /home/chantal/.julia/packages/ImageFiltering/8fmJ4/src/mapwindow.jl:294 [inlined]
 [2] copy_win!(::Array{Float64,4}, ::Array{Float64,4}, ::CartesianIndex{4}, ::Pad{0}, ::CartesianIndex{4}) at /home/chantal/.julia/packages/ImageFiltering/8fmJ4/src/mapwindow.jl:287
 [3] make_buffer_values_realistic!(::Array{Float64,4}, ::Array{Float64,4}, ::NTuple{4,UnitRange{Int64}}, ::Pad{0}, ::NTuple{4,Base.OneTo{Int64}}) at /home/chantal/.julia/packages/ImageFiltering/8fmJ4/src/mapwindow.jl:240
 [4] compute_output_eltype(::typeof(mean), ::Array{Float64,4}, ::NTuple{4,UnitRange{Int64}}, ::Pad{0}, ::NTuple{4,Base.OneTo{Int64}}) at /home/chantal/.julia/packages/ImageFiltering/8fmJ4/src/mapwindow.jl:228
 [5] allocate_output(::Function, ::Array{Float64,4}, ::NTuple{4,UnitRange{Int64}}, ::Pad{0}, ::NTuple{4,Base.OneTo{Int64}}) at /home/chantal/.julia/packages/ImageFiltering/8fmJ4/src/mapwindow.jl:214
 [6] _mapwindow(::Function, ::Array{Float64,4}, ::NTuple{4,UnitRange{Int64}}, ::Pad{0}, ::NTuple{4,Base.OneTo{Int64}}) at /home/chantal/.julia/packages/ImageFiltering/8fmJ4/src/mapwindow.jl:77
 [7] #mapwindow#1(::String, ::NTuple{4,Base.OneTo{Int64}}, ::Symbol, ::Function, ::Function, ::Array{Float64,4}, ::Array{Int64,1}) at /home/chantal/.julia/packages/ImageFiltering/8fmJ4/src/mapwindow.jl:59
 [8] mapwindow(::Function, ::Array{Float64,4}, ::Array{Int64,1}) at /home/chantal/.julia/packages/ImageFiltering/8fmJ4/src/mapwindow.jl:56
 [9] top-level scope at none:0
jw3126 commented 5 years ago

Thanks for reporting! The fix would be to change Val{N} to Val{N}() in this line: https://github.com/JuliaImages/ImageFiltering.jl/blob/master/src/mapwindow.jl#L294 I you want to give it a shot, a PR would be very welcome!

timholy commented 5 years ago

Fixed by #107