that’s the convention in OpenCV for “weird” image formats. when in doubt, it’s a good bet.
neat would be if each pixel had its three or so color values, right next to each other in memory. that’d be CV_8UC3.
weird is anything where the channels have different resolutions (chroma subsampling), and also anything that might be planar or otherwise not strictly per-pixel interleaved. most YUV is clearly weird.
in those cases, it makes no sense to use anything other than “it’s a bag of bytes” (CV_8U
). you can certainly not read a single pixel by reading adjacent bytes in those cases.
in those cases, the width of the Mat is often the full resolution width of the image that is represented. “height” then takes up however much it has to to fit the data. that could be true height *1.5 in the 4:2:0 chroma-subsampling case, and *2.0 for 4:2:2.