PythonLearner
PythonLearner

Reputation: 85

How to find the Bit Depth of an image

I am trying to get the Statistics of image like width, height, bands, min, max, mean, stddev etc., I could find all of these but however i can't find the Bit Depth of an image. i could not find any function , is there a way for this ?

Upvotes: 5

Views: 22762

Answers (1)

P.R.
P.R.

Reputation: 3917

"Color depth, also known as bit depth, is either the number of bits used to indicate the color of a single pixel, in a bitmapped image or video frame buffer, or the number of bits used for each color component of a single pixel." [0]

You can check it by checking the data-type. If you are getting a numpy array in python, you can check the data-type with my_array.dtype. You probably get either a uint8 (8 bit/ 1 byte per colour channel) or uint16 (16 bit / 2 bytes per colour channel) in rare cases. But most images are encoded in uint8.

[0] https://en.wikipedia.org/wiki/Color_depth

Upvotes: 7

Related Questions