Itseez/opencv — pull request #2957 by cambyse (2014-07-09 21:28:00+00:00)
Title: bug fix 3696

A bug was reported in the bug-tracker with the following example:

Mat a=Mat::ones(2,3, CV_32S);
Mat b;
max(a, b); // 1. No Error
max(b, a); // 2. OpenCV Error

with this example, there are 2 strange things :
1) The first call doesn't raise any error
2) the max function is not "permutable" i.e max(a, b)!=max(b,a)

I found that, when b is not initialized, in the method MatOp_Bin::assign, the following function is called cv::max(e.a, e.s[0], dst) with the second argument as a scalar.
The good function that should be called is cv::max(e.a, e.b, dst) because the two arguments given at the begining are matrix.

The same bug exists for the "min" function

This pull request solve the two points 1) and 2)