C++ opencv的像素访问问题

我想问的是mat的ptr函数只能按行访问数据元素吗
/* .ptr with [] /
for ( int i=0; i {
uchar *data = image.ptr( i );
for ( int j=0; j<cols; j++ )
{
data[j] = 0;
/

if color one:
data[j*3 + 0] = 0;
data[j*3 + 1] = 0;
data[j*3 + 2] = 0;
*/
}
}

/* .ptr with pointer */
for ( int i=0; i {
uchar *data = image.ptr( i );
for ( int j=0; j<cols*image; j++ )
{
*data++ = 0;
}
}

 可以按列
for ( int j=0; j<行数; j++ )
*(data+(j * 每列大小) + 第几列)