JuliaImages / JuliaImages/ImageFiltering.jl

Force imfilter to use Algorithm.FIR doesn't work

Open
#178 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
104
Forks
52
PR merge metrics
No merged PRs in 30d

Description

Hello,

I was trying to force imfilter to use either Algorithm.FIR or Algorithm.FFT and wasn't able to do so. Can anyone help or tell me what I'm doing wrong? Is it not possible to use a factored kernel?

Relevant docs: https://juliaimages.org/latest/function_reference/#Linear-filtering-1

Minimal example:

using ImageFiltering


img = rand(50,50)
alg = Algorithm.FIR
factor = ImageFiltering.centered(ones(13))
factored_ker = kernelfactors((factor, factor))

# works
imfilter(img, factored_ker, "symmetric")

# breaks
imfilter(img, factored_ker, "symmetric", alg)
ERROR: MethodError: no method matching imfilter!(::Array{Float64,2}, ::Array{Float64,2}, ::Tuple{ImageFiltering.KernelFactors.ReshapedOneD{Float64,2,0,OffsetArrays.OffsetArray{Float64,1,Array{Float64,1}}},ImageFiltering.KernelFactors.ReshapedOneD{Float64,2,1,OffsetArrays.OffsetArray{Float64,1,Array{Float64,1}}}}, ::Pad{0}, ::Type{ImageFiltering.Algorithm.FIR})
Closest candidates are:
  imfilter!(::AbstractArray, ::AbstractArray, ::Union{ImageFiltering.Kernel.Laplacian, Union{ImageFiltering.KernelFactors.IIRFilter{T}, AbstractArray{T,N} where N, ImageFiltering.KernelFactors.ReshapedOneD{T,N,Npre,V} where V<:(AbstractArray{T,1} where T) where Npre where N, ImageFiltering.KernelFactors.ReshapedOneD{T,N,Npre,V} where V<:ImageFiltering.KernelFactors.IIRFilter where Npre where N} where T}, ::Any...) at /Users/MrTrololord/.julia/packages/ImageFiltering/jhBno/src/imfilter.jl:581
  imfilter!(::AbstractArray, ::AbstractArray, ::Tuple, ::AbstractString, ::Any...) at /Users/MrTrololord/.julia/packages/ImageFiltering/jhBno/src/imfilter.jl:597
  imfilter!(::AbstractArray, ::AbstractArray, ::Tuple, ::ImageFiltering.AbstractBorder) at /Users/MrTrololord/.julia/packages/ImageFiltering/jhBno/src/imfilter.jl:606
  ...
Stacktrace:
 [1] imfilter at /Users/MrTrololord/.julia/packages/ImageFiltering/jhBno/src/imfilter.jl:27 [inlined]
 [2] imfilter(::Type{Float64}, ::Array{Float64,2}, ::Tuple{ImageFiltering.KernelFactors.ReshapedOneD{Float64,2,0,OffsetArrays.OffsetArray{Float64,1,Array{Float64,1}}},ImageFiltering.KernelFactors.ReshapedOneD{Float64,2,1,OffsetArrays.OffsetArray{Float64,1,Array{Float64,1}}}}, ::String, ::Type) at /Users/MrTrololord/.julia/packages/ImageFiltering/jhBno/src/imfilter.jl:22
 [3] imfilter(::Array{Float64,2}, ::Tuple{ImageFiltering.KernelFactors.ReshapedOneD{Float64,2,0,OffsetArrays.OffsetArray{Float64,1,Array{Float64,1}}},ImageFiltering.KernelFactors.ReshapedOneD{Float64,2,1,OffsetArrays.OffsetArray{Float64,1,Array{Float64,1}}}}, ::String, ::Type) at /Users/MrTrololord/.julia/packages/ImageFiltering/jhBno/src/imfilter.jl:5
 [4] top-level scope at REPL[11]:1
 [5] eval(::Module, ::Any) at ./boot.jl:330
 [6] eval_user_input(::Any, ::REPL.REPLBackend) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:86
 [7] run_backend(::REPL.REPLBackend) at /Users/MrTrololord/.julia/packages/Revise/XFtoQ/src/Revise.jl:1162
 [8] top-level scope at none:0

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal Julia example and the imfilter! method candidates shown in src/imfilter.jl around lines 581, 597, and 606. Check how factored kernels are dispatched when Algorithm.FIR or Algorithm.FFT is supplied, then run the example to verify the behavior. Done means the requested algorithm works with the factored kernel or the limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
computer-vision
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.