Effacer les filtres
Effacer les filtres

How to know how many channels my image saved in .mat file has?

3 vues (au cours des 30 derniers jours)
Sara Salimi
Sara Salimi le 29 Déc 2016
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

Réponses (1)

Walter Roberson
Walter Roberson le 29 Déc 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).

Catégories

En savoir plus sur Import, Export, and Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by