Loading image and convert it to AFArray. (Arrayfire and image processing)

Hi There,

I want to perform image processing with julia using ArrayFire, basically i want to load an image and perform a couple of operations such as applying a bilateral filter and white balance using my GPU.

I installed julia and add Arrayfire to it but still i don’t understand how to convert an image into an AFArray format to perform the bilateral filter.

this is my code:

using ArrayFire
using TestImages, Images, ImageMagick, ImageView
img = testimage("cameraman")
img_a = AFArray(img)

but gives me the following error:

MethodError: no method matching af_type(::Type{Gray{Normed{UInt8,8}}})
Closest candidates are:
af_type(!Matched::Type{Float32}) at /home/latrobe/.julia/packages/ArrayFire/nkN6J/src/util.jl:137
af_type(!Matched::Type{Complex{Float32}}) at /home/latrobe/.julia/packages/ArrayFire/nkN6J/src/util.jl:138
af_type(!Matched::Type{Float64}) at /home/latrobe/.julia/packages/ArrayFire/nkN6J/src/util.jl:139

Stacktrace:
[1] convert_array(::Array{Gray{Normed{UInt8,8}},2}) at /home/latrobe/.julia/packages/ArrayFire/nkN6J/src/util.jl:205
[2] AFArray(::Array{Gray{Normed{UInt8,8}},2}) at /home/latrobe/.julia/packages/ArrayFire/nkN6J/src/array.jl:34
[3] top-level scope at In[12]:4

Please note that arrayfire is working in c and i added all the packages listed on the code already.

Can anyone give me an idea how to solve this issue?

Sorry if the question is too basic but i spend several hours to figure it out unsuccessfully.

thanks in advance.

Regards.

I don’t know anything about ArrayFire, but if it’s struggling with Gray{N0f8} then try

img_a = AFArray(float.(img))

Is anyone still following this topic? I got the same error as reported by Fergaletto above, and when following the recommendation by Tim to try loading as float, I still get a similar error:

ERROR: MethodError: no method matching af_type(::Type{RGB{Float32}})
Closest candidates are:
  af_type(::Type{Float32}) at C:\Users\paulyk\.juliapro\JuliaPro_v1.4.1-1\packages\ArrayFire\wYxcd\src\util.jl:137
  af_type(::Type{Complex{Float32}}) at C:\Users\paulyk\.juliapro\JuliaPro_v1.4.1-1\packages\ArrayFire\wYxcd\src\util.jl:138
  af_type(::Type{Float64}) at C:\Users\paulyk\.juliapro\JuliaPro_v1.4.1-1\packages\ArrayFire\wYxcd\src\util.jl:139
  ...
Stacktrace:
 [1] convert_array(::Array{RGB{Float32},2}) at C:\Users\paulyk\.juliapro\JuliaPro_v1.4.1-1\packages\ArrayFire\wYxcd\src\util.jl:205
 [2] AFArray(::Array{RGB{Float32},2}) at C:\Users\paulyk\.juliapro\JuliaPro_v1.4.1-1\packages\ArrayFire\wYxcd\src\array.jl:34
 [3] top-level scope at none:0