OpenCV 4 - 图像操作

1 读写像素

1-1 读写单通道像素

读一个GRAY像素点的像素值(CV_8UC1)

  • 方法一: Scalar intensity = img.at(y, x);
  • 方法二: Scalar intensity = img.at(Point(x, y));

代码示例:

	Mat src, dst;
	src = imread("./1.png");
	if (!src.data)	//判断图片是否加载成功!
	{
   
		std::cout << "打开图片失败!" << std::endl;
		return -1;
	}
	imshow("src image", src);
	//CV_BGR2GRAY 将BGR(蓝绿红)颜色空间转换为灰度颜色空间
	cvtColor(src, dst,CV_BGR2GRAY);

	int height = dst.rows;
	int widht = dst.cols;
	for (int i = 0; i < height; i++)
	{
   
		for (int j 

你可能感兴趣的:(OpenCV学习笔记,opencv,人工智能,计算机视觉)