Which function can I use in opencv as max() in matlab

c++, matlab, matrix, max, opencv

Solution

Actually the exact same syntax works:

Mat im = cv::imread("...");
Mat im_capped = cv::max(im, 0);

Or if you want give it a matrix of zeros of the same size:

Mat thresh(im.size(), im.type(), Scalar::all(0));
Mat im_capped = cv::max(im, thresh);

According to the docs:

Problem

In MATLAB: ``` max(image,0) ``` sets the negative values to zero. Is there any available function in OpenCV to do the same?

Original source