Size of Matrix OpenCV

后端 未结 5 933
遇见更好的自我
遇见更好的自我 2020-12-07 11:36

I know this might be very rudimentary, but I am new to OpenCV. Could you please tell me how to obtain the size of a matrix in OpenCV?. I googled and I am still searching, bu

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 12:39

    Note that apart from rows and columns there is a number of channels and type. When it is clear what type is, the channels can act as an extra dimension as in CV_8UC3 so you would address a matrix as

    uchar a = M.at(y, x)[i];
    

    So the size in terms of elements of elementary type is M.rows * M.cols * M.cn

    To find the max element one can use

    Mat src;
    double minVal, maxVal;
    minMaxLoc(src, &minVal, &maxVal);
    

提交回复
热议问题