Tilt image in c#

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
architektura
Posts: 21
Joined: 2016-10-03T05:11:21-07:00
Authentication code: 1151

Tilt image in c#

Post by architektura » 2017-01-25T07:47:44-07:00

Hi, c#
Your code from http://www.imagemagick.org/Usage/photos/#tilt_shift

how to translate to c#?

convert beijing_md.jpg -sigmoidal-contrast 15x30% \
\( +clone -sparse-color Barycentric '0,0 black 0,%h gray80' \
-solarize 50% -level 50%,0 \) \
-compose Blur -set option:compose:args 10 -composite \
beijing_model.jpg

but I cant create all

1]
var sharpen = 15;
tilt.SigmoidalContrast(true, Math.Abs(sharpen), 30);
List<SparseColorArg> args = new List<SparseColorArg>();
args.Add(new SparseColorArg(0, 0, new MagickColor("white")));
args.Add(new SparseColorArg(0, image.Height/4, new MagickColor("black")));
tilt.SparseColor(SparseColorMethod.Barycentric, args);
this gives me half of background image -> blurmap http://www.imagemagick.org/Usage/photos ... map_tn.gif

2]
how to translate
-set option:compose:args 10

best regards
ala

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

Re: Tilt image in c#

Post by dlemstra » 2017-02-02T12:45:37-07:00

Below is a translation of your command line:

Code: Select all

// convert beijing_md.jpg
using (MagickImage image = new MagickImage("beijing_md.jpg"))
{
  // -sigmoidal-contrast 15x30%
  // This overload will be available in the next version, you will need to use Quantum.Max * 0.3 for now.
  image.SigmoidalContrast(15, new Percentage(30));
  
  using (MagickImage clone = image.Clone()) // +clone
  {
    var black = new SparseColorArg(0, 0, new MagickColor("black"));
    var gray80 = new SparseColorArg(0, clone.Height, new MagickColor("gray80"));

    // -sparse-color Barycentric '0,0 black 0,%h gray80'
    // This overload will be available in the next version, you will need to use a list for now.
    clone.SparseColor(SparseColorMethod.Barycentric, black, gray80);

    clone.Solarize(new Percentage(50)); // -solarize 50%
    clone.Level(new Percentage(50), new Percentage(0)); // -level 50%,0

    // -compose Blur -set option:compose:args 10 -composite
    image.Composite(clone, CompositeOperator.Blur, "10");

    // beijing_model.jpg
    image.Write("beijing_model.jpg");
  }
}
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

architektura
Posts: 21
Joined: 2016-10-03T05:11:21-07:00
Authentication code: 1151

Re: Tilt image in c#

Post by architektura » 2017-02-13T05:22:01-07:00

Thanks a lot :)
Working I just tilt'ed some images

@dlemstra Thank You!

Post Reply