t = (double)getTickCount();
Mat img1(1000, 1000, CV_32F);
for (int i=0; i<1000; i++)
{
for (int j=0; j<1000; j++)
{
img1.at<float>(i,j) = 3.2f;
}
}
t = (double)getTickCount() - t;
printf("in %gms
", t*1000/getTickFrequency());
//***************************************************************
t = (double)getTickCount();
Mat img2(1000, 1000, CV_32F);
for (int i=0; i<1000; i++)
{
for (int j=0; j<1000; j++)
{
img2.ptr<float>(i)[j] = 3.2f;
}
}
t = (double)getTickCount() - t;
printf("in %gms
", t*1000/getTickFrequency());
//***************************************************************
t = (double)getTickCount();
Mat img3(1000, 1000, CV_32F);
float* pData = (float*)img3.data;
for (int i=0; i<1000; i++)
{
for (int j=0; j<1000; j++)
{
*(pData) = 3.2f;
pData++;
}
}
t = (double)getTickCount() - t;
printf("in %gms
", t*1000/getTickFrequency());
//***************************************************************
t = (double)getTickCount();
Mat img4(1000, 1000, CV_32F);
for (int i=0; i<1000; i++)
{
for (int j=0; j<1000; j++)
{
((float*)img3.data)[i*1000+j] = 3.2f;
}
}
t = (double)getTickCount() - t;
printf("in %gms
", t*1000/getTickFrequency());
http://blog.csdn.net/yang_xian521/article/details/7161335