从给定矩阵中查找最大矩阵和最小矩阵
Find Max matrix & minimum Matrix out of given matrixes
本文关键字:查找 更新时间:2023-10-16
我是c++和opencv的新手。我有3个矩阵,我想从这3个矩阵中找出最大矩阵和最小矩阵,举个例子
A=[12 3] B= [2 4 6] c=[4 8 12]则A为最小值,c为高标量值的矩阵,有什么方法可以找到它吗?
另一方面,我尝试了以下方法,但这是不正确的。
Mat A=imread("") // intialise the mat 1X3
Mat B= //intialise the mat 1X3
if (A>B) printf("Matrix A greater than B") // this line encounter the Error that is not the correct way of doing that.
嗨,OpenCV有cv::min和max函数为您实现!下面是一个示例用法!希望这对你有帮助!
int _tmain(int argc, _TCHAR* argv[])
{
//Fill Random Numbers in 3 Mats
Mat mTest(5,5,CV_8UC3),mMin,mMax;
randn(mTest,Scalar::all(125),Scalar::all(100));
Mat mTest_3[3];
split(mTest, mTest_3);
//Find Min and max from 3 Mats!
mMin=cv::min(mTest_3[0],cv::min(mTest_3[1],mTest_3[2]));
mMax=cv::max(mTest_3[0],cv::max(mTest_3[1],mTest_3[2]));
cout<< "Inputs 1: n"<<mTest_3[0]<<"n";
cout<< "Inputs 2: n"<<mTest_3[1]<<"n";
cout<< "Inputs 3: n"<<mTest_3[2]<<"n";
cout<< "Min : n"<<mMin<<"n";
cout<< "Max : n"<<mMax<<"n";
}
相关文章:
- 正在查找文档以获得PS4平台的C++中的设备信息
- 在C++中查找文件
- 模板元程序查找相似的连续类型名称
- 在UNIX系统中使用DIR查找文件的字节大小
- 查找最接近的大于当前数字的数字的索引
- 有没有一种方法可以创建一个带有哈希表的数据库,该哈希表具有恒定时间查找功能
- 查找后更改类变量
- 使用正则表达式regex_search在字符串中查找字符串
- 使用gcc从静态链接的文件中查找可选符号
- 在C++中查找范围的长度
- 算法问题:查找从堆栈中弹出的所有序列
- 在Windows中查找扬声器输出的当前音量级别
- 如何在C++中使用X509证书模在令牌中查找私钥
- 使用.find函数在c++中查找字符和另一个字符之间的大小
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 在 for 循环中查找问题时遇到困难
- 如何在文件中查找字节序列
- 试图创建一个多线程程序来查找0-100000000之间的总素数
- 使用堆查找第K个最大元素的时间复杂性
- 一个函数,用于查找字符串1包含字符串2 c++的次数