Suppose I have an m -by- n -by- 3 Uint8 array that represents an image where RGB color space is assumed. I would like to export it as a 24-bit pixel PNG image using the Images package. How can i do this?
I naively tried applying imwrite to a randomly generated source array as follows:
imwrite(rand(Uint8,300,300,3),"test.png")
However, this gave an error: "Mapinfo does not have a mapinfo method ...".
Similarly using
imwrite(rand(Float32,300,300,3),"test.png")
gave an error stating that it cannot output the color space, and instead I should use the AbstractImage type. Thus, the Images package is presumably inconvenient, assuming that the m -by- n -by- 3 array is automatically an RGB image (the Images documentation leads to complications due to the existence of 3D and 4D image types as a reason that this is not automatically output )
How can I export a numeric array as an image? Can this be done directly or do I need to create a wrapper for the array?
source share