Sunday, March 5, 2017

Convert a color image to black and white image in C#

  • In this simple article you will learn that how we can convert colored image into black and white image in
  • This technique uses a ColorMatrix to perform the conversion. A ColorMatrix is a 5x5 matrix that can make just about any modifications to the color of an image. A ColorMatrix is pretty complicated and deserves a whole tutorial to itself.
  • We're going to use GDI to draw the new black and white image. The benefit of this technique over the last one is that we don't need to know any information about the image's pixel format. The code here is pretty straight forward. First create the blank image and get a Graphics object from it. Next, create the ColorMatrix that will convert the original image to grayscale. Declare an ImageAttributes object that will use the ColorMatrix and use it to draw the new image using DrawImage.
Below is code for your problem   

No comments:

Post a Comment