convert(Array{RGB{Float64}}, A)
(To me this seems to be explained in the docs; if not, please submit
improvements.)
--Tim
On Saturday, February 21, 2015 07:03:45 AM DumpsterDoofus wrote:
> I tried using `convert` elementwise over a `reinterpret`ed array:
>
> A = ones(Float64, 3, 1000, 1000);
> B = reinterpret(HSV{Float64}, A);
> C = [convert(RGB, B[i,j]) for i in 1:1000, j in 1:1000];
> imwrite(C, "image.PNG")
>
> However, this doesn't work, because the array comprehension doesn't appear
> to be aware that the resulting array is of type Array{RGB{Float64}, 2}, and
> instead gives Array{Any, 2} (although all elements are of type
> RGB{Float64}), which then gives an error at the `imwrite` step because of a
> type mismatch. It is also fairly slow. I also tried the following:
> D = convert(RGB, B)
> but this is invalid syntax.
>
> Is there a straightforward way to do the conversion?