/* 计算bin图像。 使用xsobel和ysobel图像来计算每个像素处的梯度和幅度。{Magnitude = sqrt(sq(xsobel) + sq(ysobel) ), gradient = itan (ysobel/xsobel) }。 然后根据梯度的方向,设置相应图像中相应像素的值 */
int x, y;
float temp_gradient, temp_magnitude;
for (y = 0; y < in->height; y++) {
/* ptr1和ptr2分别指向xsobel和ysobel图像中当前行的开头。 ptrs指向bin图像中当前行的开头 */
float* ptr1 = (float*) (xsobel->imageData + y * (xsobel->widthStep));
float* ptr2 = (float*) (ysobel->imageData + y * (ysobel->widthStep));
float** ptrs = (float**) malloc(9 * sizeof(float*));
for (int i = 0; i < 9 ;i++){
ptrs[i] = (float*) (bins[i]->imageData + y * (bins->widthStep));
}
/*对于行中的每个像素,计算梯度取向和幅度,并为bin图像设置相应的值. */