Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: UsingColors Example

$
0
0
I converted the example from the reference to C# but I am unable to get the result you would like. Here is my code so far:
using (MagickImage image = new MagickImage("maxresdefault.jpg"))
{
  image.ColorSpace = ColorSpace.HSV;
  var channels = image.Separate().ToArray();

  channels[0].BackgroundColor = MagickColors.Transparent;
  channels[0].ColorFuzz = new Percentage(5);
  channels[0].InverseTransparent(new MagickColor("grey32"));
  channels[0].Alpha(AlphaOption.Extract);

  channels[1].BackgroundColor = MagickColors.Transparent;
  channels[1].ColorFuzz = new Percentage(10);
  channels[1].Transparent(new MagickColor("grey50"));
  channels[1].Alpha(AlphaOption.Extract);

  channels[2].BackgroundColor = MagickColors.Transparent;
  channels[2].ColorFuzz = new Percentage(20);
  channels[2].Transparent(new MagickColor("grey60"));
  channels[2].Alpha(AlphaOption.Extract);

  channels[0].Composite(channels[1], CompositeOperator.Multiply);
  channels[1].Dispose();
  channels[0].Composite(channels[2], CompositeOperator.Multiply);
  channels[2].Dispose();

  channels[0].Negate();

  image.Composite(channels[0], CompositeOperator.CopyAlpha);
  channels[0].Dispose();

  image.Write("test.png");
}
I think you will need to tweak the percentages/gray colors to get the result that you want.

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>