ImageMagick result differ from Magick++

萝らか妹 提交于 2019-12-13 18:40:12

问题


I have 3 images: source.jpg, saturated.jpg and mask.jpg, I want to blend the source.jpg and saturated.jpg using the mask.jpg.

When I use the ImageMagick's convert command:

convert source.jpg saturated.jpg mask.jpg -compose over -composite result.jpg

I get this result.

But when I do the same with Magick++:

Magick::Image source,saturated,mask;
source.read("source.jpg");
saturated.read("saturated.jpg");
mask.read("mask.jpg");
source.clipMask(mask);
source.composite(saturated,0,0,OverCompositeOp);

I get this result.

Can someone please tell me what I am doing wrong?


回答1:


This gets pretty close to the command line version:

#include <Magick++.h> 
#include <iostream> 
using namespace std; 
using namespace Magick; 

int main(int argc,char **argv) 
{ 
   InitializeMagick(*argv);
   Magick::Image source,saturated,mask;
   source.read("source.jpg");
   saturated.read("saturated.jpg");
   mask.read("mask.jpg");
   mask.type( Magick::GrayscaleType );
   mask.negate();
   source.mask(mask);
   source.composite(saturated,0,0,OverCompositeOp);
   source.write("mppresult.jpg");
}


来源:https://stackoverflow.com/questions/34329954/imagemagick-result-differ-from-magick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!