Mat Isobelx;
cv::Sobel(Isrc(box), Isobelx, CV_32FC1, 1, 0);
Mat Isobely;
cv::Sobel(Isrc(box), Isobely, CV_32FC1, 0, 1);
Mat Gmag(Isobelx.size(), CV_8UC1);
int w_Isobel = Isobelx.cols;
int h_Isobel = Isobelx.rows;
int hist[361] = { 0 };
for (int i = 0; i < h_Isobel; i++)
{
float *pdataX = Isobelx.ptr<float>(i);
float *pdataY = Isobely.ptr<float>(i);
float *pdataMag = Gmag.ptr<float>(i);
for (int j = 0; j < w_Isobel; j++)
{
float Gx = pdataX[j];
float Gy = pdataY[j];
if (sqrt(Gx*Gx+Gy*Gy) > 130)
{
pdataMag[j] = 255;
int angle = (int)fastAtan2(Gy, Gx);
if (angle > 180)
angle = angle - 180;
hist[angle] += 1;
}
else
pdataMag[j] = 0;
}
}
cv::cartToPolar(Isobelx, Isobely, Gmag, Gdir, 1);