我在openCV库上遇到了此示例代码。 p [j] = table [p [j]]行是做什么的?我遇到过多维数组,但以前没有这样的东西。
Mat& ScanImageAndReduceC(Mat& I, const uchar* const table)
{
// accept only char type matrices
CV_Assert(I.depth() == CV_8U);
int channels = I.channels();
int nRows = I.rows;
int nCols = I.cols * channels;
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;
}
最佳答案
它通过使用一个表格进行颜色替换,其中每个像素强度映射到其他某个值。通常用于诸如颜色分级,直方图调整甚至阈值设置之类的技术。
在此,该表包含无符号char值,并通过像素值进行索引。像素的强度p[i]
用作表的索引,然后将该索引处的值写入该像素,替换其原始值。
关于c++ - 在图像扫描上下文中了解嵌套数组C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63387535/