显示.exe停止工作,但是去掉那个for循环就可以运行,是ptr<>的使用不当吗
#include
#include
#include
#include
using namespace std;
using namespace cv;
int main()
{
// 读入一张图片
Mat img = imread("F:/vsprogram/projecttest/01.jpg");
// 创建一个名为 "picture"窗口
namedWindow("picture");
//创建一个等大图像
Mat new_img(img.rows,img.cols,CV_8UC3);
//row 行height
for (int j= 0; j<img.rows; j++)
{
for (int i = 0; i < img.cols; i++)
{
int y=j;
int x = i;
new_img.ptr<float>(y)[x] = img.ptr<float>(j)[i];
}
}
// 在窗口中显示原画
imshow("picture", new_img);
// 等待6000 ms后窗口自动关闭
waitKey(6000);
}