Sobel operator gives too large values
I've applied Sobel operator to my image and obtained very large values (e.g 1347440720, -1970897035, ...). Is it normal? Should I scale it using convertScaleAbs( grad_x, abs_grad_x )? My snippet of code is here. What is more interesting minmaxLoc gives uninterpretable values too. Help me please with this case.
Mat prev_frame = imread("1.jpg", 0);
Mat frame = imread("2.jpg", 0);
Mat grad_x, grad_y;
int scale = 1;
int delta = 0;
int ddepth = CV_16S;
cout << grad_x << endl;
Sobel(prev_frame, grad_x, ddepth, 1, 0, 3, scale, delta, BORDER_DEFAULT );
Sobel(prev_frame, grad_y, ddepth, 0, 1, 3, scale, delta, BORDER_DEFAULT );
Mat diff = frame - prev_frame;
double min, max;
minMaxLoc(grad_y, &min, &max);
cout << min << endl;
cout << max << endl;
for (int i = 0; i < grad_x.cols; i++)
{
for (int j = 0; j < grad_x.rows; j++)
{
cout << grad_x.at<int>(i, j) << endl;
}
}
OUTPUT:
51968
65523
0
0
0
.
.
.
1532713819
1532713819