I am trying to find the maximum pixel value of a cv::Mat.
The Problem : *maxValue is always returning 0.
From this S.O. thread, I understand that 'max_element return iterators, not values. This is why I use *maxValue'
cv::Mat imageMatrix;
double sigmaX = 0.0;
int ddepth = CV_16S; // ddepth – The desired depth of the destination image
cv::GaussianBlur( [self cvMatFromUIImage:imageToProcess], imageMatrix, cv::Size(3,3), sigmaX);
cv::Laplacian(imageMatrix, imageMatrix, ddepth, 1);
std::max_element(imageMatrix.begin(),imageMatrix.end());
std::cout << "The maximum value is : " << *maxValue << std::endl;
Note : If min_element is substituted in place of max_element, and minValue in place of maxValue, *minValue will always return 0.