OpenCV中文网站

 找回密码
 立即注册
搜索
热搜: 安装 配置
查看: 9363|回复: 1

新人求助

[复制链接]
发表于 2018-11-6 19:18:43 | 显示全部楼层 |阅读模式
用imwrite写图像,确定地址没问题,但是为什么写不进去???也不显示图像呢????
代码如下:#include<iostream>
#include<string>
#include<sstream>
#include<opencv2\core.hpp>
#include<opencv2/highgui.hpp>
using namespace std;
using namespace cv;
int main(int argc, char * argv[]) {
        Mat img = imread("1.jpg");
        Mat gray = imread("1.jpg",0);

        imwrite("1_gray.jpg", gray);//写图像

        //通过opencv函数获取图像像素
        int myrow = img.cols - 1;
        int mycol = img.rows - 1;
        Vec3b pixel = img.at<Vec3b>(myrow, mycol);
        cout << "ixel value(B,G,R)" << (int)pixel[0] << "," << (int)pixel[1] << "," << (int)pixel[2] << ")" << endl;
        namedWindow("test_BGR", CV_WINDOW_AUTOSIZE);
        namedWindow("test_gray", CV_WINDOW_AUTOSIZE);
        imshow("test_BGR", img);
        imshow("test_gray", gray);
        waitKey(0);
        return 0;
}

回复

使用道具 举报

发表于 2018-11-7 23:11:33 | 显示全部楼层
还lena.jpg看一下
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|OpenCV中文网站

GMT+8, 2024-4-20 02:57 , Processed in 0.012959 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表