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

Support for Grayscale Images #469

Open
Evidlo opened this issue Apr 8, 2022 · 0 comments
Open

Support for Grayscale Images #469

Evidlo opened this issue Apr 8, 2022 · 0 comments

Comments

@Evidlo
Copy link

Evidlo commented Apr 8, 2022

I'm trying to use DSP.conv to do some simple image filtering on a grayscale image, but it seems like the datatype is not supported:

using TestImages
using ImageView
using DSP

img = float(testimage("cameraman"))

# build kernel
xs = ys = -2:2
kernel_func(x, y) = exp(1 / sqrt(x^2 + y^2))
kernel = [kernel_func(x, y) for x in xs, y in ys]
kernel[size(kernel)  2 .+ 1...] = exp(1)

# convolve
result = conv(kernel, img)

ImageView.imshow(result)
ERROR: LoadError: MethodError: no method matching conv(::Array{Float64,2}, ::Array{ColorTypes.Gray{Float32},2})
Closest candidates are:
  conv(::AbstractArray{T,N}, ::AbstractArray{T,N}) where {T<:Union{Complex{Float32}, Complex{Float64}, Float32, Float64}, N} at /home/evan/.julia/packages/DSP/amvJg/src/dspbase.jl:688
  conv(::AbstractArray{var"#s3445",N} where var"#s3445"<:Union{Complex{Float32}, Complex{Float64}, Float32, Float64}, ::AbstractArray{var"#s3444",N} where var"#s3444"<:Union{Complex{Float32}, Complex{Float64}, Float32, Float64}) where N at /home/evan/.julia/packages/DSP/amvJg/src/dspbase.jl:699
  conv(::AbstractArray{var"#s3445",N} where var"#s3445"<:Number, ::AbstractArray{var"#s3444",N} where var"#s3444"<:Union{Complex{Float32}, Complex{Float64}, Float32, Float64}) where N at /home/evan/.julia/packages/DSP/amvJg/src/dspbase.jl:711
  ...
Stacktrace:
 [1] top-level scope at /home/evan/research/2022_focal_drift/convolution_test.jl:14
 [2] include(::String) at ./client.jl:457
 [3] top-level scope at REPL[79]:1
in expression starting at /home/evan/research/2022_focal_drift/convolution_test.jl:14
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