Check for element type inside a module (Images)

I am trying to check the type of the elements of an image that is passed to a function which is inside a module.

Consider I define img as follows:

using Images
img = colorview(Gray, array);

Then inside the function in my module:

import Images
eltype(img) in [Gray{Float64}, Gray{Float32}, Gray{Float16} ]

But I get an error that Gray is not defined.

I have two questions:

  1. How can I import an element type into my module?
    (I am not writing using Images in my module)

  2. How can I check if the element type is Gray?
    (I do not care about number type Gray{Any type here is fine})

  1. using Images: Gray

  2. eltype(img) <: Gray

2 Likes