2
我在看图像处理算法的掌上手册(http://adaptiveart.eecs.umich.edu/2011/wp-content/uploads/2011/09/The-pocket-handbook-of-image-processing-algorithms-in-C.pdf),我碰到这个代码(下面)。图像处理算法代码,解释指针
谁能帮我了解
*(Im->Data + (x)*Im->Cols + (y))
这是PDF页面33
#define pix(Im,x,y) \
*(Im->Data + (x)*Im->Cols + (y))
/* Compute and return area for objects */
int area(struct Image *In, int x1, int y1, int x2, int y2, unsigned char ObjVal){
long i, j, rows;
int area_value = 0;
for(i=x1; i<=x2; ++i)
for(j=y1; j<=y2; ++j){
if(pix(In,i,j)==ObjVal)++area_value;
}
return(area_value);
}
它假定一个2维阵列中,存储在行优先顺序。这就是如何计算m乘n 2D数组中的数据点(x,y)的方式。 – rts1
图像存储在一个数组中,二维数组中的p [x] [y]'是'p [x *列+ y]'(或者等价于* *(p + x *列) + y)')。 – molbdnilo
使用现代的C++界面 – dynamic