Number of bits used in an image

40 次查看(过去 30 天)
med-sweng
med-sweng 2012-10-11
How can I get the number of bits used in an image?
Thanks.

回答(2 个)

Image Analyst
Image Analyst 2012-10-11
Look at class(yourImageArray).
  2 个评论
Kaihua Hou
Kaihua Hou 2021-9-22
if class(myIMG) returns uint8, should the number of bits be n_row*n_column*8 bits?
Image Analyst
Image Analyst 2021-9-23
Yes, correct. They number of bytes is n_row * n_column and the number of bits is 8 times that = n_row * n_column * 8.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2012-10-11
There is no mechanism for detecting the number of bits intended to be used in an image. There are, however, methods for detecting the number of bits needed to represent an image.
Provided that the image is stored in an integer data class:
NBITS = @(X) log2(nextpow2(double(X)+1));
maxbits = NBITS(max(YourImage(:)));
unusedbits = NBITS(min(diff(unique(YourImage(:))))) - 1;
The stored values are then packet into maxbits of information. For example, if the data class was uint8() but the maximum stored value used was (say) 99, then that would only require 7 bits of information to represent so maxbits would be 7.
However, some of the lower bits might be unused, as would be the case if 12 bits of image information was "left-justified" in a 16 bit number. The bottom unusedbits of the image do not contain any distinct information (0 if all the bottom bits are used).
Note, though, that the fact that there are bits at the bottom that do not contain any distinct information does not mean that the bits were "intentionally left blank": the situation can happen just by chance.

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by