We have 8*8*96 matrix and we want to convert this matrix into an image. How to convert it?

1 次查看(过去 30 天)
imwrite(newcolor,'output','bmp'); %we used this function but it went wrong
Error using writebmp (line 27)
Invalid dimensions for X.
  7 个评论
Walter Roberson
Walter Roberson 2017-3-15
If it has color information then does it currently correspond to 8 x 8 x 3 x 32, or does it correspond to 8 x 8 x 32 x 3 ?
If it is 32 color images then it is probably 8 x 8 x 3 x 32

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2017-3-15
编辑:Walter Roberson 2017-3-15
"is there any other way to get an image from the matrix?"
Not with .bmp file format.
With GIF file format you could use 'writemode', 'append' to create an animated GIF
With TIFF file format, you can use 'writemode', 'append' to add a "page" to the TIFF file. However, for TIFF files and multiple images I recommend the more detailed controls of using Tiff objects.
For any of the other image types you have two options:
  1. Write out a series of images with related names, such as output001.bmp output002.bmp and so on; or
  2. reshape to 8 by (8 times 96) -- a short and wide series of images side by side.
You also have the option of writing a 3D volume with dicomwrite(), or of writing a multiband data file https://www.mathworks.com/help/matlab/ref/multibandwrite.html
Oh yes, there are also ways to write each image as a "page" in a PDF file. Which really seems a waste for 8 x 8 images.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by