初识Opencv4.X----像素最值寻找

//像素最值寻找
#include <stdio.h>
#include <iostream>
#include <string>
#include <opencv2\opencv.hpp>
using namespace std;
using namespace cv;

int main()
{
    
    
	system("color F0");//改变输出界面的颜色,白色
	float a[10] = {
    
     1,2,3,4,5,6,7,8,9,10 };
	Mat img = Mat(2, 5, CV_32FC1,a);
	double min_value, max_value;
	Point min_local, max_local;
	cout << img << endl;
	minMaxLoc(img, &min_value, &max_value, &min_local, &max_local);
	cout << "最大像素值:" << max_value << max_local << endl;
	cout << "最小像素值:" << min_value << min_local << endl;
	//当图像为多通道时,可以通过reshape函数变为单通道
	return 0;
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_46146657/article/details/120199235