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

New Post: Black and White and Sepia

$
0
0
Just to be clear do you want a black and white image or a grayscale image? For me a black and white image only contains two colors (black and white). You should only use bilevel if that is your goal. But I think you want a grayscale image.

One trick would be adjusting the gamma of the image:
using (MagickImage image = new MagickImage("input.jpg"))
{
  image.ColorType = ColorType.Grayscale;
  image.Gamma(2.0);
  image.Write("output.jpg");
}
But I think you are looking for the ColorMatrix method:
using (MagickImage image = new MagickImage("input.jpg"))
{
  ColorMatrix matrix = new ColorMatrix(3);
  // SetRow won't be available until the next release.// Use SetValue(x,y) for now (I feel your pain...)
  matrix.SetRow(0, 0.2, 0.5, 0.3);
  matrix.SetRow(1, 0.2, 0.5, 0.3);
  matrix.SetRow(2, 0.2, 0.5, 0.3);
  image.ColorMatrix(matrix);
  image.Write("output.jpg");
}

Viewing all articles
Browse latest Browse all 3693

Trending Articles



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