VisonMaster 2021-05-26 20:14
浏览 61

.exe 已触发了一个断点。

#include<opencv.hpp>
#include<iostream>

using namespace std;
using namespace cv;

int main()
{
	//读入8位灰度图像
	Mat src;
	src = imread("Lena.png", 0);
	imshow("Src image", src);
	Mat dst(src.rows, src.cols, CV_8UC3, Scalar(0, 0, 0));
	for (int i = 0; i < src.rows; i++)
	{
		uchar *current = src.ptr<uchar>(i);
		Vec3f *current_d = dst.ptr<Vec3f>(i);
		for (int j = 0; j < src.cols; j++)
		{
			current_d[j][0] = current[j];
			current_d[j][1] = current[j];
			current_d[j][2] = current[j];
		}
	}
	cout << dst << endl;
	imshow("假彩色图像", dst);
	while (waitKey(0) != 'q') {};
}

为什么会出现这种问题,当把dst构造函数列数设为src.cols*src.cols可以显示图片

  • 写回答

0条回答 默认 最新

      报告相同问题?

      悬赏问题

      • ¥15 求制作一个个人网页,
      • ¥15 寻涂色内存脚本作者有项目有市场有资源.却技术
      • ¥15 蓝桥杯c51单片机问题
      • ¥15 ajax跨域问题请求修改代码
      • ¥15 python matplotlib
      • ¥15 短信测压+语音,有偿,必须用Python
      • ¥20 COCOS2DX的protobuf协议注册函数问题
      • ¥15 (标签-Pytorch|关键词-Stream)
      • ¥15 求深圳2019年开放数据应用创新大赛的营运车辆数据!
      • ¥15 软件UI界面绘制折线图