Image change the shape when displaying

前端 未结 1 1778
北海茫月
北海茫月 2021-01-21 02:15

I am trying to display this image as i have this image in my directory

\"enter

but

相关标签:
1条回答
  • 2021-01-21 03:01

    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);
    

    enter image description here

    again, note, that opencv won't do any alpha-compositing, you'll have to roll your own formulas for that.

    0 讨论(0)
提交回复
热议问题