我试图找到a的最大像素值cv::Mat
.
问题:*maxValue
总是回归0
.
从这个SO线程,我理解' max_element
返回迭代器,而不是值.这就是我使用*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;
Run Code Online (Sandbox Code Playgroud)
注意:如果min_element
替换代替max_element
,则minValue
代替maxValue
,*minValue
将始终返回0
.
我有大量的点数据集.所以我想从这些点集中找到最小值和最大值.现在我正在使用普通for循环这个目的很好它正在工作,但我想知道使用opencv库的可能性,因为我希望使用这个库.所以请任何人帮助我.谢谢