Help converting these IM commands to Magick.NET

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
Posts: 1
Joined: 2017-02-22T00:28:48-07:00
Authentication code: 1151

Help converting these IM commands to Magick.NET

Post by Kroko » 2017-02-22T00:58:19-07:00

Hello, I am a new user of ImageMagick and Magick.Net.
A lot of people recommand me to use IM and Magick.Net to perform image operations.

My goal is to remove Greenscreen from images. So I found IM script on Internet that gave me a basis but I don't manage to convert it to

I hope somebody could help me.

Code: Select all

magick convert greenscreen.jpg -alpha set ( +clone -blur 0x5 -colorspace Lab -channel R -evaluate set 50%% +channel -colorspace sRGB +dither -colors 30 -fuzz 15%% -fill None -draw "alpha 0,0 replace" -channel A -negate +channel ) -compose copyopacity -composite -filter Gaussian -resize 10%% -define filter:sigma=8.9 -resize 1000%% -alpha off gb_1.png
I have convert it to this but it can't convert this part

Code: Select all

+dither -colors 30 -fuzz 15%% -fill None -draw "alpha 0,0 replace"

Code: Select all

Dim greenscreen As New ImageMagick.MagickImage(source)

            Using clone As ImageMagick.MagickImage = greenscreen.Clone
                clone.Blur(0, 5)
                clone.ColorSpace = ImageMagick.ColorSpace.Lab
                clone.Evaluate(ImageMagick.Channels.Red, ImageMagick.EvaluateOperator.Set, New ImageMagick.Percentage(50))
                clone.ColorSpace = ImageMagick.ColorSpace.sRGB

                '-colors 30
                '-fuzz 15%%
                '-fill None
                '-draw "alpha 0,0 replace"

                Dim settings As New ImageMagick.QuantizeSettings()
                settings.Colors = 30
                settings.DitherMethod = ImageMagick.DitherMethod.No
                clone.ColorFuzz = New ImageMagick.Percentage(15)

                Dim FC As New ImageMagick.DrawableFillColor(Color.Transparent)
                Dim DA As New ImageMagick.DrawableAlpha(0, 0, ImageMagick.PaintMethod.Replace)


                '-compose copyopacity -composite
                greenscreen.Composite(clone, ImageMagick.CompositeOperator.Copy)
            End Using
            greenscreen.Resize(New ImageMagick.Percentage(10))
            greenscreen.GaussianBlur(8, 9)
            greenscreen.Resize(New ImageMagick.Percentage(1000))
Thanks for any help.

User avatar
Posts: 1588
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789

Re: Help converting these IM commands to Magick.NET

Post by dlemstra » 2017-02-25T03:41:19-07:00

Those commands would translate to this:

Code: Select all

// +dither -colors 30
image.Quantize(new QuantizeSettings()
  DitherMethod = DitherMethod.No,
  Colors = 30
// -fuzz 15%%
image.ColorFuzz = (Percentage)15;
// -fill None
image.Settings.FillColor = MagickColors.None;
// -draw "alpha 0,0 replace"
image.Draw(new DrawableAlpha(0, 0, PaintMethod.Replace));
.NET + ImageMagick = Magick.NET, @MagickNET, Donate

Post Reply