The data itself contained in cv::Mat is not required to be simple primitives. Each element of the data in a
cv::Mat can itself be either a single number, or multiple numbers. In the case of multiple numbers, this is
what the library refers to as a multichannel array. In fact, an n-dimensional array and an (n-1)-dimensional
multichannel array are actually very similar objects, but because of the frequency of occasions in which it
is useful to be able to think of an array as a vector valued array, the library contains special provisions for
such structures.
13
One reason why this distinction is made is because of memory access. By definition, an element of an array
is the part that may be vector-valued. For example, an array might be said to be a two-dimensional three-
channel array of 32-bit floats; in this case, the element of the array is the three 32-bit floats with a size of 12
bytes. When laid out in memory, rows of an array may not be absolutely sequential; there may be small
gaps that buffer each row before the next. The difference between an
-dimensional multichannel array is that this padding will always occur at the end of full
rows (i.e., the channels in an element will always ...