How to know how many channels my image saved in .mat file has?
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a stack of medical images saved in mat files. My question is how can I know how many channels it has, or it is grayscale or not?
Your help is appreciated
Thanks in advance
0 个评论
回答(1 个)
Walter Roberson
2016-12-29
I have an array with 600 elements here. How can I know what its height and width is, and how many channels it has? Is it 60 by 10 with 1 channel? Is it 25 by 6 with 4 channels? Are the height and width and number of channels stored in the first 4 elements of the array and the actual data is in the last 596 elements of the array?
"or it is grayscale or not"
Once you have figured out the number of elements in the data array, then if the number of elements is not divisible by 3 then it is not RGB; if the number of elements is not divisible by 4 then it is not RGBA or CMYK. However, the reverse cannot be said: if the number of elements is divisible by 3 then it is not necessarily RGB and if it is divisible by 4 then it is not necessarily RGBA or CMYK.
If the data is composed entirely of non-negative integral values, then it might be pseudo-color (indexed image).
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Import, Export, and Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!