opencv nRows = I.rows * channels 问题

来源:互联网 发布:php foreach用法 编辑:程序博客网 时间:2024/05/24 06:13

这段代码来自opencv说明

Mat& ScanImageAndReduceC(Mat& I, const uchar* const table){    // accept only char type matrices    CV_Assert(I.depth() != sizeof(uchar));         int channels = I.channels();    int nRows = I.rows * channels;     int nCols = I.cols;    if (I.isContinuous())    {        nCols *= nRows;        nRows = 1;             }    int i,j;    uchar* p;     for( i = 0; i < nRows; ++i)    {        p = I.ptr<uchar>(i);        for ( j = 0; j < nCols; ++j)        {            p[j] = table[p[j]];                     }    }    return I; }

其中
int nRows = I.rows * channels;
int nCols = I.cols;

正确写法应为:
int nRows = I.rows;
int nCols = I.cols * channels;

0 0
原创粉丝点击