JuliaImages / JuliaImages/ImageFiltering.jl

imfilter!: TypeError: in Type{...} expression, expected UnionAll

Open
#268 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

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.3 (2023-08-24)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Images, ImageFiltering

julia> img = zeros(RGB24, (170, 287));

julia> imfilter!(img, img, Kernel.gaussian(8.0))
ERROR: TypeError: in Type{...} expression, expected UnionAll, got Type{RGB24}
Stacktrace:
  [1] filtfft(A::OffsetArrays.OffsetMatrix{RGB24, Matrix{RGB24}}, krn::FFTViews.FFTView{Float64, 2, Matrix{Float64}})
    @ ImageFiltering ~/.julia/packages/ImageFiltering/OyzRu/src/imfilter.jl:845
  [2] _imfilter_fft!(r::ComputationalResources.CPU1{ImageFiltering.Algorithm.FFT}, out::Matrix{RGB24}, A::OffsetArrays.OffsetMatrix{RGB24, Matrix{RGB24}}, kernel::Tuple{OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}}, border::NoPad{Pad{2}})
    @ ImageFiltering ~/.julia/packages/ImageFiltering/OyzRu/src/imfilter.jl:820
  [3] imfilter!(r::ComputationalResources.CPU1{ImageFiltering.Algorithm.FFT}, out::Matrix{RGB24}, A::OffsetArrays.OffsetMatrix{RGB24, Matrix{RGB24}}, kernel::Tuple{OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}}, border::NoPad{Pad{2}})
    @ ImageFiltering ~/.julia/packages/ImageFiltering/OyzRu/src/imfilter.jl:807
  [4] imfilter!(r::ComputationalResources.CPU1{ImageFiltering.Algorithm.FFT}, out::Matrix{RGB24}, img::Matrix{RGB24}, kernel::Tuple{OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}}, border::Pad{2})
    @ ImageFiltering ~/.julia/packages/ImageFiltering/OyzRu/src/imfilter.jl:340
  [5] imfilter!(r::ComputationalResources.CPU1{ImageFiltering.Algorithm.FFT}, out::Matrix{RGB24}, img::Matrix{RGB24}, kernel::Tuple{OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}}, border::Pad{0})
    @ ImageFiltering ~/.julia/packages/ImageFiltering/OyzRu/src/imfilter.jl:327
  [6] imfilter!(out::Matrix{RGB24}, img::Matrix{RGB24}, kernel::Tuple{OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}}, border::Pad{0}, alg::ImageFiltering.Algorithm.FFT)
    @ ImageFiltering ~/.julia/packages/ImageFiltering/OyzRu/src/imfilter.jl:236
  [7] imfilter!
    @ ~/.julia/packages/ImageFiltering/OyzRu/src/imfilter.jl:230 [inlined]
  [8] imfilter!
    @ ~/.julia/packages/ImageFiltering/OyzRu/src/imfilter.jl:213 [inlined]
  [9] imfilter!(::Matrix{RGB24}, ::Matrix{RGB24}, ::OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}})
    @ ImageFiltering ~/.julia/packages/ImageFiltering/OyzRu/src/imfilter.jl:205
 [10] top-level scope
    @ REPL[3]:1

Hi, thanks for your work. Is the code above supposed to work? I'm not sure if imfilter! with the same source and destination is allowed. It works for kernels with 7.0 or smaller, but for bigger ones it fails.

julia> size(Kernel.gaussian(7.0))  # Doesn't throw.
(29, 29)

julia> size(Kernel.gaussian(7.01)) # Throws.
(33, 33)

Anyway, if the size is the problem perhaps a better error can be reported.
Thanks!

⌃ [6a3955dd] ImageFiltering v0.7.6

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

Reproduce the RGB24 imfilter! case with Kernel.gaussian(8.0), then inspect src/imfilter.jl around lines 807-845, where the stack trace reports the failure. Compare the behavior with kernels of size 29 and 33 and determine whether aliased source and destination arrays are supported. Done means the case either works correctly or reports a clear, tested error.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.