What is going on with returned data in the following examples? It appears ImageData
returns different types depending on the what data is passed into Image
.
How do I force ImageData
to always return the RGBA {{{0,0,0,0},{255,255,255,255}}}
version of the data?
ImageData[Image[{{{0, 0, 0,0}, {255, 255, 255,255}}}, "Byte"],"Byte"]
{{{0, 0, 0,0}, {255, 255, 255,255}}}
Now if I pass a compressed form of the same image I don't get back the RGBA representation of the image, but the same compressed form.
ImageData[Image[{{0, 255}}, "Byte"], "Byte"]
{{0, 255}}
Is there a way to construct an Image
that insures Mathematica always returns the RGBA form of the data? Basically I am looking for a function in the form of ConvertToRGBA[i_Image] := ...
ImageData[ColorConvert[Image[{{0, 255}}, "Byte"], "RGB"], "Byte"]
? No alpha channel, tho. $\endgroup$Map[(Append[#, 255]) &,ImageData[ColorConvert[Image[{{{0, 0, 0, 0, 0}, {255, 255, 255, 255, 255}}}, "Byte"],"RGB"], "Byte"],2]
$\endgroup$ImageData
returns different types depending on the what data is passed into Image.": No,ImageData
does not return different types depending on the input image --- with the only exception of "Bit" images for whichImageData
gives 0 and 1, not real values 0. and 1. $\endgroup$Image[d,"type]
orImageData[d,"type"]
). In M8.0ImageData[d,"Byte"]
will output RGB {255,255,255}. Sometimes it will output RGBA {255,255,255,255} if their is an Alpha channel, and then occasionally it will output {1.0,1.0,1.0}. I wouldn't be surprised if outputs other formats occasionally also. $\endgroup$