Page 1 of 1

Tilt image in c#

Posted: 2017-01-25T07:47:44-07:00
by architektura
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

Re: Tilt image in c#

Posted: 2017-02-02T12:45:37-07:00
by dlemstra
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");
  }
}

Re: Tilt image in c#

Posted: 2017-02-13T05:22:01-07:00
by architektura
Thanks a lot :)
Working I just tilt'ed some images

@dlemstra Thank You!