Friday, June 19, 2009

Visit the Multi-channel data for Opencv Image and Matrix data

According the data structure of IplImage and CvMat, assuming we have a matrix M[m*n*c], which m is row's number, n is column number, c is channel' number. If the data type is float, then we can get the value of M(i,j,k):

M(i,j)=M.data.fl[i*n*c+j*c+k];

for double, short or uchar data:
M(i,j)=M.data.db[i*n*c+j*c+k];
M(i,j)=M.data.s[i*n*c+j*c+k];
M(i,j)=M.data.ptr[i*n*c+j*c+k];

If M is a IplImage data type, then we have:
M(i,j)=M->imagedata[i*n*c+j*c+k];

No comments: