Reputation: 1072
I am trying to display this image as i have this image in my directory
but i displaying it with this code
Mat img=imread("D:\\vig.png");
imshow("image",img);
waitKey();
imwrite("D:\\img.jpg",img);
The same image displayed as follows
Whats wrong with it
Upvotes: 3
Views: 1156
Reputation: 39796
your vignette is only in the alpha [4th] channel, and also it looks inverted (opacity values here).
(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);
again, note, that opencv won't do any alpha-compositing, you'll have to roll your own formulas for that.
Upvotes: 8