MATLAB 对 OpenCV 转化图像对照表
1.Best way to apply a function to each element of Mat
for( i = ... )//through each row in Mat M
for(j = ...)//through each column
M.at<T>(i,j) = tanh( M.at<T>(i,j) );
//大概比之前的要快一倍
for (int i = 0; i < contSize.height; ++i)
{
T* ptr = mat.ptr<T>(y);
for (int j = 0; j < contSize.width; ++j)
{
ptr[j] = ...;
}
}
//效率并非最快
MatIterator_<double> it, end;
for( it = I.begin<double>(), end = I.end<double>(); it != end; ++it)
{
//do something here
}
- 类型转换,通过convertTo 赋值到本身上,通过copy,完成非指针的拷贝
- 矩阵相乘和点乘点除是有区别的