Convert color image to gray scale
Hello guys,
I'm trying to convert a color image to a gray scale using these commands:
mean(temp.data, 1)
and the output error is:
ERROR: MethodError:converthas no method matching convert(::Type{ColorTypes.RGB{Float32}}, ::Int64) This may have arisen from a call to the constructor ColorTypes.RGB{Float32}(...), since type constructors fall back to convert methods. Closest candidates are: ColorTypes.RGB{T<:Union{AbstractFloat,FixedPointNumbers.FixedPoint{T<:Integer,f}}}(::Any, ::Any, ::Any) call{T}(::Type{T}, ::Any) convert{C<:ColorTypes.Colorant{T,N}}(::Type{C<:ColorTypes.Colorant{T,N}}, ::ColorTypes.Colorant{T,N}) ... in fill! at multidimensional.jl:557 in mean at statistics.jl:31
And if I use this command:
convert(Image{Gray}, temp)
I get this output:
ERROR: UndefVarError: Gray not defined
do you have anay idea how can I solve the problem?
Thanks
julia> using TestImages, Colors
julia> img = testimage("mandrill")
RGB Images.Image with:
data: 512x512 Array{ColorTypes.RGB{FixedPointNumbers.UFixed{UInt8,8}},2}
properties:
colorspace: sRGB
spatialorder: x y
julia> imgg = convert(Image{Gray}, img)
Gray Images.Image with:
data: 512x512 Array{ColorTypes.Gray{FixedPointNumbers.UFixed{UInt8,8}},2}
properties:
colorspace: sRGB
spatialorder: x y
I see there's a stray property, but note
julia> colorspace(imgg)
"Gray"
gives the right answer. (Dispatch wins over dictionary properties.) Obviously I/someone should clean this up, though.
That works fine. Thanks a lot for your help!!!!!
Closed by #577
This is currently failing for me on MacOs HighSierra,
I see the following error, after: imgg = convert(Image{Gray},img)
ERROR: TypeError: Type{...} expression: expected UnionAll, got Type{Gtk.GtkImage}
That was the old syntax. New syntax is documented at http://juliaimages.github.io/latest/. Just use imgg = Gray.(img).
What documentation are you following? It would be good to correct posted documents that are out of date.