ImageFiltering.jl
ImageFiltering.jl copied to clipboard
ERROR: ... lacks the proper padding sizes for an array with 2 dimensions
I'm not entirely sure what is happening here. I'm trying to filter an image before resizing it, as recommended by the Images.jl docs. Running:
reduction_factor = new_len/minimum(size(im)[1:2])
im = imfilter(im, KernelFactors.gaussian(0.75*reduction_factor))
Results in:
ERROR: ArgumentError: ImageFiltering.Pad{1}(:replicate, (2,), (2,)) lacks the proper padding sizes for an array with 2 dimensions
Stacktrace:
[1] padindices(::Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}, ::ImageFiltering.Pad{1}) at /home/sabae/.julia/v0.6/ImageFiltering/src/border.jl:240
[2] padarray at /home/sabae/.julia/v0.6/ImageFiltering/src/border.jl:657 [inlined]
[3] imfilter! at /home/sabae/.julia/v0.6/ImageFiltering/src/imfilter.jl:702 [inlined]
[4] imfilter!(::Array{ColorTypes.RGB{Float64},2}, ::Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}, ::Tuple{OffsetArrays.OffsetArray{Float64,1,Array{Float64,1}}}, ::ImageFiltering.Pad
{0}, ::ImageFiltering.Algorithm.FIR) at /home/sabae/.julia/v0.6/ImageFiltering/src/imfilter.jl:613
[5] imfilter!(::Array{ColorTypes.RGB{Float64},2}, ::Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}, ::Tuple{OffsetArrays.OffsetArray{Float64,1,Array{Float64,1}}}, ::ImageFiltering.Pad
{0}) at /home/sabae/.julia/v0.6/ImageFiltering/src/imfilter.jl:607
[6] imfilter(::Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}, ::OffsetArrays.OffsetArray{Float64,1,Array{Float64,1}}) at /home/sabae/.julia/v0.6/ImageFiltering/src/imfilter.jl:5
Trying out different padding arguments doesn't lead to much success except for the Inner() scheme, which is what I'm using for now (since I'm resizing from thousands of pixels on a side down to hundreds, so these boundary conditions don't matter much to me)
Looks like a documentation problem. Try
img = imfilter(img, Kernel.gaussian(0.75*reduction_factor))
or
kern = KernelFactors.gaussian(0.75*reduction_factor)
img = imfilter(img, kernelfactors((kern,kern)))
note that arg to kernelfactors is a tuple.
Perhaps one could exploit dispatch to generate a better error message.
Confirmed that those both work.
Let's aim for a better error message.