Save a matrix as an image
Show older comments
Hello
I am trying to save a matrix as an image, and so far have been trying to use the imwrite function. The matrix is 768x768x2580 Uint 8. Each time I try to save it, I get a different error, no matter which file format I try to save it as. This seems to be something to do with the size of the matrix, though I am not sure.Is there any advice about how to save this matrix as an image?
The matrix describes voxel intensity across a visual stimuli.
Thanks,
Phoebe
1 Comment
What formats did you try? The documentation for imwrite clearly lists all of the supported file formats, and none of them seem to support voxels. I have never heard of any standard 2D-image file formats that store voxel data, can you give a reference for one that does?
Answers (1)
The Problem
A matrix of size 768x768x2580 is not supported by imwrite, as the documentation clearly states:
A — Image data to write matrix
Image data to write, specified as a full (nonsparse) matrix.
- For grayscale images, A can be m-by-n.
- For indexed images, A can be m-by-n. Specify the associated colormap in the map input argument.
- For truecolor images, A must be m-by-n-by-3. imwrite does not support writing RGB images to GIF files.
For TIFF files, A can be an m-by-n-by-4 array containing color data that uses the CMYK color space.
For multiframe GIF files, A can be an m-by-n-by-1-by-p array containing grayscale or indexed images, where p is the number of frames to write. RGB images are not supported in this case.
The Solution
Perhaps you might like to try using these instead:
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!