OpenCV单通道图像保存后为何再载入还是3通道的?
答案:2 悬赏:60
解决时间 2021-02-09 17:14
- 提问者网友:单纯说谎家
- 2021-02-09 12:10
OpenCV单通道图像保存后为何再载入还是3通道的?
最佳答案
- 二级知识专家网友:情窦初殇
- 2021-02-09 12:56
猜测你后面去读图像的时候应该使用的是imread()函数的第二个参数使用的是默认值,那么这个时候都是以color形式读取的,所有就又变回3通道了;下面是第二个参数的介绍
flags – Flags specifying the color type of a loaded image:
– CV_LOAD_IMAGE_ANYDEPTH - If set, return 16-bit/32-bit image when the input has
the corresponding depth, otherwise convert it to 8-bit.
– CV_LOAD_IMAGE_COLOR - If set, always convert image to the color one
– CV_LOAD_IMAGE_GRAYSCALE - If set, always convert image to the grayscale one
如果你想读取图像的原样,建议使用如下:"..."替换为自己的图像
Mat test = imread("...", -1);
flags – Flags specifying the color type of a loaded image:
– CV_LOAD_IMAGE_ANYDEPTH - If set, return 16-bit/32-bit image when the input has
the corresponding depth, otherwise convert it to 8-bit.
– CV_LOAD_IMAGE_COLOR - If set, always convert image to the color one
– CV_LOAD_IMAGE_GRAYSCALE - If set, always convert image to the grayscale one
如果你想读取图像的原样,建议使用如下:"..."替换为自己的图像
Mat test = imread("...", -1);
全部回答
- 1楼网友:滚出爷的世界
- 2021-02-09 14:00
iplimage* p = cvloadimage("e:\\1.jpg");
iplimage* dst = cvcreateimage(cvgetsize(p),p->depth,1);
for(int i=0;iimagedata+j*p->widthstep)[i] = (uchar*)(dst->imagedata+j*p->widthstep)[i*3+1];
}
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯