Skip to content

division with MatExpr #15760

@berak

Description

@berak
System information (version)
  • OpenCV => 4.1.2-dev
  • Operating System / Platform => win7 32bit
  • Compiler => mingw64 8.1

assuming X a valid Mat and Y an empty/invalid one, the expression X / Y does not throw an exception, but calculates 1 / X instead.

because here (e.b.data is invalid in our case):

else if( e.flags == '/' && e.b.data )
cv::divide(e.a, e.b, dst, e.alpha);
else if( e.flags == '/' && !e.b.data )
cv::divide(e.alpha, e.a, dst );

why does it have e.a and e.alpha in reverse ?
shouldn't it have thrown Sizes of input arguments do not match , like it does in the Y / X case ?

Steps to reproduce
Mat x(3,3,CV_32FC3,Scalar(3,2,1));
Mat y; // invalid
Mat r = x / y;
cout << r << endl;

[0.33333334, 0.5, 1, 0.33333334, 0.5, 1, 0.33333334, 0.5, 1;
0.33333334, 0.5, 1, 0.33333334, 0.5, 1, 0.33333334, 0.5, 1;
0.33333334, 0.5, 1, 0.33333334, 0.5, 1, 0.33333334, 0.5, 1]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions