What is the dimension of the array representing a BGR image ?

asked Feb 6 '15

begueradj gravatar image

According to documentation, a BGR image is represented this way in OpenCV: image description

My question: what is the dimension of the array displayed by this picture ?

Preview: (hide)

Comments

1

n * m floats or n * m * 3 uchars, because a float has 32 bits and one uchar has 8 bits, so 3 uchars are 32 bits

thdrksdfthmn gravatar imagethdrksdfthmn (Feb 6 '15)edit

Thank you. But in each column there are 3 subcolumns, so ... ?

begueradj gravatar imagebegueradj (Feb 6 '15)edit
1

yes, if you have a union, the 3 uchars are occupying the same memory as the 1 float: 32 b. So m * n * sizeof(float) == m * n * 3 * sizeof(uchar), it depends on how you interpret the memory

thdrksdfthmn gravatar imagethdrksdfthmn (Feb 6 '15)edit

Thank you for the precision. When I run image.shape (in Numpy) I get as a dimension 3.

begueradj gravatar imagebegueradj (Feb 6 '15)edit

Strange, how does your image look like? or what code line exactly you have used? because according to the docs you shall get something like (n, m) ...

thdrksdfthmn gravatar imagethdrksdfthmn (Feb 6 '15)edit

@thdrksdfthmn Sorry, I mean image.ndim gives 3 not 2

begueradj gravatar imagebegueradj (Feb 19 '15)edit

What are you using? Python? isn't ndim equivalent to channels from C++? If so, then you have 3 channels (R, G, B, or B, G, R)

thdrksdfthmn gravatar imagethdrksdfthmn (Feb 19 '15)edit