Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
spelufo opened this issue Sep 20, 2023 · 0 comments
Open

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

spelufo opened this issue Sep 20, 2023 · 0 comments

Comments

@spelufo
Copy link

spelufo commented Sep 20, 2023

               _
   _       _ _(_)_     |  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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant