本文内容:OpenCV中与随机数有关的函数:cv::randu()、cv::randn()、cv::randShuffle()。
1. cv::randu()
函数原型:
template<typename _Tp> _Tp randu(); // return random number of specific type
cv::randu(
cv::InputOutputArray mtx, // all values will be eandomized
cv::InputArray low, // minmum,1-by-1 (Nc=1,4) or 1-by-4(Nc=1)
cv::InputArray high, // maxmum,1-by-1 (Nc=1,4) or 1-by-4(Nc=1)
);
计算:![]()
函数说明:从函数声明可以看出来有两种方式调用cv::randu()。一种是模板形式,另一种是提供希望填充数据的矩阵及两个附加矩阵。
第一种方法将返回适当类型的随机值,以这种方式生成的随机数是均匀分布的。对于整数,产生从0到该类型的最大值范围内的数;对于浮点类型,产生0.0到1.0(不包括1.0)之间的数,此模板形式仅生成单个数字。

最低0.47元/天 解锁文章
248

被折叠的 条评论
为什么被折叠?



