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

asked 2015-02-06 02:46:04 -0500

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 ?

edit retag flag offensive close merge delete

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 ( 2015-02-06 02:48:00 -0500 )edit

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

begueradj gravatar imagebegueradj ( 2015-02-06 02:54:19 -0500 )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 ( 2015-02-06 04:20:36 -0500 )edit

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

begueradj gravatar imagebegueradj ( 2015-02-06 07:29:52 -0500 )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 ( 2015-02-06 09:16:56 -0500 )edit

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

begueradj gravatar imagebegueradj ( 2015-02-19 03:06:50 -0500 )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 ( 2015-02-19 03:45:42 -0500 )edit