In Matlab a(a>50)=0
can replace all elements of a
that are greater than 50 to 0. I want to do same thing with Mat in OpenCV. How to do it?
Naah. to do that, just one line:
cv::Mat img = imread('your image path');
img.setTo(0,img>50);
as simple as that.
What you want is to truncate the image with cv::threshold.
The following should do what you require:
cv::threshold(dst, dst, 50, 0, CV_THRESH_TOZERO_INV);
this is the function definition
double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type)
http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html?highlight=threshold#threshold
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With