How to zero elements of 3D Matrix with opencv Library?

后端 未结 1 953
鱼传尺愫
鱼传尺愫 2021-01-16 10:20

I\'m struggling with zeroing elements of 3D matrix with opencv. I can zero all elements in 2D matrix like following way:

meta = new Mat(Mat::zeros(cluster,3         


        
相关标签:
1条回答
  • 2021-01-16 10:32

    I remind you the documentation, you can use this constructor:

    C++: Mat::Mat(int ndims, const int* sizes, int type, const Scalar& s)
    

    passing cv::Scalar(0) should be good for your purposes.

    int sizes[] = { 100, 100, 100 };
    cv::Mat *matrix = new cv::Mat(3, sizes, CV_32FC1, cv::Scalar(0));
    

    This should make a 3D matrix, a sort of cube with edge 100.

    0 讨论(0)
提交回复
热议问题