如何根据opencv中的某些条件修改Mat的值? [英] how to modify values of Mat according to some condition in opencv?

查看:101
本文介绍了如何根据opencv中的某些条件修改Mat的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Matlab中, a(a> 50)= 0 可以替换 a 中大于50到0的所有元素. OpenCV .怎么做?

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?

推荐答案

您想要的是使用cv :: threshold截断图像.

What you want is to truncate the image with cv::threshold.

以下应满足您的要求:

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

这篇关于如何根据opencv中的某些条件修改Mat的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆