I have a grayscale image and I’d like to be able to draw a colored polygon on it with ImageDraw but am running into an error. Here is a MWE:
using TestImages, ImageDraw, Colors
img = testimage("cameraman")
draw(img,Polygon([(1,1),(30,1),(50,1),(30,30)]),colorant"indianred")
I suspect this is because the image is grayscale but the polygon is colored. If this is the case, is there a way around this that doesn’t involve converting the grayscale image to another colorspace?
error is
MethodError: no method matching draw!(::Array{Gray{FixedPointNumbers.Normed{UInt8,8}},2}, ::Polygon, ::RGB{FixedPointNumbers.Normed{UInt8,8}})
Closest candidates are:
draw!(::AbstractArray{T<:Colorant,2}, ::Polygon, !Matched::T<:Colorant) where T<:Colorant at C:\Users\C7045\.julia\packages\ImageDraw\OAT7P\src\paths.jl:32
draw!(::AbstractArray{T<:Colorant,2}, ::Drawable) where T<:Colorant at C:\Users\C7045\.julia\packages\ImageDraw\OAT7P\src\core.jl:137
draw!(::AbstractArray{T<:Colorant,2}, !Matched::Point, !Matched::T<:Colorant) where T<:Colorant at C:\Users\C7045\.julia\packages\ImageDraw\OAT7P\src\core.jl:176