Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you can use the Mat::at<type>(i,j,k) operator for that:

const int mySizes[3]={3,5,5};

cv::Mat f = Mat::zeros(3,mySizes,CV_64F);
f.at<double>(1,2,3) = 17;

for ( int i=0;i<mySizes[0];i++) {
    for ( int j=0;j<mySizes[1];j++) {
        for ( int k=0;k<mySizes[2];k++) {
            cerr << f.at<double>(i,j,k) << " ";
        }
        cerr << endl;
    }
    cerr << endl;
}
cerr << endl;

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

0 0 0 0 0
0 0 0 0 0
0 0 0 17 0
0 0 0 0 0
0 0 0 0 0

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0