How to know how many channels my image saved in .mat file has?
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Walter Roberson
on 29 Dec 2016
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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!