Image Magick ++等价于转换-fill [英] Image Magick++ equivalent to convert -fill
问题描述
我有一个convert命令,我需要翻译成Image Magick函数调用。
I have a convert command that I need to translate into Image Magick function calls.
convert.exe bar.jpg -fuzz 40%-fillrgb(53456,35209,30583)-opaquergb(65535,65535,65535 )foo2.jpg
我想知道是否有人可以给我一个例子,我需要应用以获得相同的效果?
I was wondering if anyone could give me an example of the methods I need to apply to get the same effect?
感谢您的帮助!
推荐答案
Magick ++ 很清楚,但是有更多的例子使用 c & MagickWand 。在大多数情况下, -fill 只是设置一个可应用于各种操作的颜色属性。在Magick ++中,您可以使用 Image.fillColor ;但是, Image.opaque 方法会将一种颜色替换为另一种颜色。除了不透明方法外,您还可以通过 -fuzz 选项来调整颜色阈值=nofollow> Image.colorFuzz 。
The documentation for Magick++ is pretty clear, but there's a lot more examples using c & MagickWand. For the most part, -fill is just setting a color attribute that can be applied to a wide variety of actions. In Magick++, you would use Image.fillColor; however, the Image.opaque method swaps one color for another. In addition to the opaque method, color threshold can be adjusted by setting the -fuzz option with Image.colorFuzz.
#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;
int main(int argc, char **argv)
{
InitializeMagick(*argv);
// Setup items
Image image;
/*
Remember to read & understand Magick++/Color.h to
ensure you are initializing the correct color constructor.
*/
Color target = Color("rgb(65535, 65535, 65535)");
Color fill = Color("rgb(53456, 35209, 30583)");
// Convert 40% to double
const double fuzz = 40*QuantumRange/100;
// Read image object
image.read("bar.jpg");
// Set fuzz threshold
image.colorFuzz(fuzz);
// Apply opaque paint
image.opaque(target,fill);
// Save image
image.write("foo2.jpg");
return 0;
}
MagickWand示例
C & MagickWand Example
#include <stdio.h>
#include <wand/MagickWand.h>
int main(int argc, char **argv) {
// MagickWand items
MagickWand *image = NULL;
PixelWand *target = NULL;
PixelWand *fill = NULL;
// Convert 40% to double
const double fuzz = 40*QuantumRange/100;
MagickWandGenesis();
// Setup Wand
target = NewPixelWand();
fill = NewPixelWand();
image = NewMagickWand();
// Load image
MagickReadImage(image,"bar.jpg");
// Set Colors
PixelSetColor(target,"rgb(65535, 65535, 65535)");
PixelSetColor(fill,"rgb(53456, 35209, 30583)");
// Apply effect(wand,0.40);
MagickOpaquePaintImage(image,target,fill,fuzz,MagickFalse);
// Save image
MagickWriteImages(image,"foo2.jpg",MagickTrue);
// Clean up
image=DestroyMagickWand(image);
MagickWandTerminus();
return 0;
}
这篇关于Image Magick ++等价于转换-fill的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!