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

2

5

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.

Carburet answered 12/6, 2012 at 21:21 Comment(2)
Can you access and change the individual elements of the image? If so, just loop through, and apply a threshold to each pixel.Betide
Are you talking about a thresholded black/white image (e.g. everything > 200 is white) or a dithered image (with dot density proportional to original grayscale intensity)?Rinee
B
9

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.

Brevier answered 12/6, 2012 at 23:22 Comment(2)
Hi Sharkz, thanks for your answer i believe it should work. just a quick question what do you mean by 8bpp and 16bpp grayscale images?Carburet
Bits per pixel in short bpp - it tells how many bits to be used for the representation of one pixel. The higher the number the more the range of color displayed by the image. This link visualizes the effects on an image changing its bpp.Brevier
K
2

Try these three thresholding techniques. Sample snippets are given in the links.

Otsu : http://www.aforgenet.com/framework/docs/html/b2bd54da-46c2-cb64-3577-0962d8f56554.htm

SIS : http://www.aforgenet.com/framework/docs/html/39e861e0-e4bb-7e09-c067-6cbda5d646f3.htm

Iterative : http://www.aforgenet.com/framework/docs/html/e01406a7-511d-ae4d-79b6-5f7eba523824.htm

Im sure these links will give you a bit more exposure on converting a greyscale image to black and white which is known as binarizing.

Kenti answered 12/7, 2013 at 21:51 Comment(1)
THanks for your help @Kenti I managed to sort all my issues :)Carburet

© 2022 - 2024 — McMap. All rights reserved.