Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting a Grayscale image to black&white using Aforge.Net

I am quite new to Aforge.Net and I am looking for a way to convert a greyscale image to black and white. I couldnt really find any support on it?

I managed to convert a normal image to a GrayScale bye applying a Grayscale filter. but i couldnt find anything regarding the black and white converion

Can someone give me a hand with it please.

like image 379
Mr.Noob Avatar asked Jun 12 '12 21:06

Mr.Noob


1 Answers

Use the Threshold Class to convert the image to black and white.

 // create filter
Threshold filter = new Threshold( 100 );
// apply the filter
filter.ApplyInPlace( image );

Details of the Threshold Class can be found at Aforge.

The filter does image binarization using specified threshold value. All pixels with intensities equal or higher than threshold value are converted to white pixels. All other pixels with intensities below threshold value are converted to black pixels. The filter accepts 8 and 16 bpp grayscale images for processing. Note:Since the filter can be applied as to 8 bpp and to 16 bpp images, the ThresholdValue value should be set appropriately to the pixel format. In the case of 8 bpp images the threshold value is in the [0, 255] range, but in the case of 16 bpp images the threshold value is in the [0, 65535] range.

like image 198
Sharkz Avatar answered Sep 29 '22 01:09

Sharkz