显示时图像更改形状 [英] Image change the shape when displaying
本文介绍了显示时图像更改形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试显示此图片,因为我在我的目录中有此图片
I am trying to display this image as i have this image in my directory
但我用此代码显示它
Mat img=imread("D:\\vig.png");
imshow("image",img);
waitKey();
imwrite("D:\\img.jpg",img);
同样的图像显示如下
它有什么问题
推荐答案
您的晕影只在alpha [第4]频道,并且它看起来颠倒(这里的不透明度值)。
your vignette is only in the alpha [4th] channel, and also it looks inverted (opacity values here).
(您的第一张照片似乎显示一个白色图片(或背景)的正片复合图片,可能来自photoshop等)
(your 1st picture seems to show a proper alpha composite with a white image(or background), that's probably from photoshop or the like. )
Mat img=imread("vig.png",-1); // load 'as is', don't convert to bgr !!
Mat ch[4];
split(img,ch);
Mat im2 = ch[3]; // here's the vignette
// im2 = 255 - im2; // eventually cure the inversion
imshow("image",im2);
waitKey();
imwrite("img.jpg",im2);
注意,opencv不会做任何alpha合成,你必须滚动自己的公式。
again, note, that opencv won't do any alpha-compositing, you'll have to roll your own formulas for that.
这篇关于显示时图像更改形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文