I have a cv::Mat image, and I am thinking about having a second cv::Mat of the same size, but where each entry stores a complex data structure corresponding to that pixel instead. Can this be done with cv::Mat or is a vector of vectors my only open there?
Share
Looking at
cv::Mat‘s documentation, especially the constructors and thetype,channelsanddepthmethods, it seems to only be able to contain simple OpenCV data types (8/16/32-bit ints, 32/64-bit floats, or 1/2/3/4-tuples of these, but not a mixture, of course).But even then, I wouldn’t suggest a vector of vectors for a two-dimensional array/matrix/image (where all rows have the same number of columns), but rather a simple 1D vector with some simple index magic doing the mapping from 2D to 1D. This has much better memory locality and allocation behaviour.