cv::max() does not work in-place anymore (Bug #1643)


Added by Johannes Jordan about 2 years ago. Updated about 2 years ago.


Status:Done Start date:2012-03-01
Priority:High Due date:
Assignee:Alexander Shishkov % Done:

0%

Category:core
Target version:2.4.0
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

The following code worked before the update to 2.3.1:

cv::Mat_<float> img;
[...]
// get rid of negative values
cv::max(img, 0., img);

With 2.3.1, it fails. The matrix has all zeroes after this call!
The following code however works as expected:

bands[i] = cv::max(bands[i], 0.);


Related issues (Add)


Associated revisions

Revision c9489a8b
Added by Alexander Shishkov about 2 years ago

fixed #1643

History

Updated by Saul T about 2 years ago

This is caused by the header file inline fuctions being incorrect in "opencv2/core/mat.hpp". The max() functions that take three arguments:

template<typename _Tp> static inline void max(const Mat_<_Tp>& a, const Mat_<_Tp>& b, Mat_<_Tp>& c)
{
    cv::min((const Mat&)a, (const Mat&)b, (Mat&)c);
}

template<typename _Tp> static inline void max(const Mat_<_Tp>& a, double s, Mat_<_Tp>& c)
{
    cv::min((const Mat&)a, s, (Mat&)c);
}

template<typename _Tp> static inline void max(double s, const Mat_<_Tp>& a, Mat_<_Tp>& c)
{
    cv::min((const Mat&)a, s, (Mat&)c);
}

all incorrectly call min(). The functions that take two arguments however correctly call max().

Updated by Alexander Shishkov about 2 years ago

  • Assignee set to Alexander Shishkov
  • Target version set to 2.4.0

Updated by Alexander Shishkov about 2 years ago

Thanks for the report!
fixed in r7522

  • Status changed from Open to Done

Also available in: Atom PDF