Sobel output is directional? Not magnitude?

I’m porting some OpenCV code to Cuda. I notice that the output of this code:

auto dir = std::filesystem::current_path() / "Debug" / "";

cv::Mat image = cv::imread(dir.replace_filename("some_grayscale.png").string(), cv::IMREAD_GRAYSCALE);

cv::Mat imageFloat;
image.convertTo(imageFloat, CV_32FC1);

cv::Mat imageSobel;
cv::Sobel(imageFloat, imageSobel, CV_32FC1, 1, 1, 5);
double min = 0;
double max = 0;

cv::minMaxLoc(imageSobel, &min, &max);

for this image the min is something like -700 and max is +400…

This does not correspond to a gradient magnitude, but perhaps to a directional output? A magnitude would be using square root and be positive.

It this a directional output?

I notice examples that do x and y separately and seem to do edges but the documentation is a bit unclear. For instance, Matlab code would be:

[Gx,Gy] = imgradientxy(dI,"sobel");
[Gmag,Gdir] = imgradient(Gx,Gy);

cand would give me a magnitude and a direction separately.

Thanks

Rick

Just to add some further information…

I tested the following:

cv::Mat image = cv::imread(dir.replace_filename(“some_grayscalefile.png”).string(), cv::IMREAD_GRAYSCALE);

cv::Mat imageCV32F;

image.convertTo(imageCV32F, CV_32FC1);
cv::Mat gradX;

cv::Sobel(imageCV32F, gradX, CV_32FC1, 1, 0, 5);

cv::Mat gradY;

cv::Sobel(imageCV32F, gradY, CV_32FC1, 0,1, 5);

My CUDA kernel matches gradX and gradY exactly.

When I write out the floating point values to a csv file, I see that my values are exact matches.
But…

cv::Mat gradXY;
cv::Sobel(imageCV32F, gradXY, CV_32FC1, 1,1, 5);

produces in gradXY something I cannot determine. It doesn’t seem to be a simple combination of gradX and gradY, either in multiplication or addition…

What is the output supposed to be in this case? The code I’m trying to port uses this value (undocumented, magic stuff of course) and I’m hoping to match it exactly or pretty darn close…

Mystery…

Any original authors on the forum? The documentation doesn’t seem to cover the case of 1,1 for x and y gradients, but rather separate and then combining…