Discrepancy between cv::Mat::at and cv::minMaxLoc functions

252 Views Asked by At

I have a cv::Mat of type CV_8U. If I use the cv::minMaxLoc function like so:

cv::Mat img(rows, cols, CV_8U, data);

double minVal, maxVal;
cv::Point minLoc, maxLoc;

cv::minMaxLoc(img, &minVal, &maxVal, &minLoc, &maxLoc);

I get:

maxVal = 255, maxLoc = [127, 126]

Then if I use the following code:

img.at<uint8_t>(maxLoc); //or img.at<uint8_t>(127,126);

Result is 0

I actually get zero for every element of the matrix using both cv::Mat::at and cv::imshow(). But cv::minMaxLoc is giving the correct answer. So I was wondering if anyone had any insight as to why these two functions would not agree.

0

There are 0 best solutions below