简体   繁体   English

使用Aforge.Net将灰度图像转换为黑白图像

[英]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. 我是Aforge.Net的新手,我正在寻找一种将灰度图像转换为黑白图像的方法。 I couldnt really find any support on it? 我真的找不到任何支持吗?

I managed to convert a normal image to a GrayScale bye applying a Grayscale filter. 我设法通过应用灰度滤镜将普通图像转换为GrayScale。 but i couldnt find anything regarding the black and white converion 但我无法找到有关黑白转换的任何信息

Can someone give me a hand with it please. 请有人帮我一把。

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 . 门槛类的详细信息可以在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. 滤镜接受8和16 bpp灰度图像进行处理。 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. 注意:由于滤镜可以应用于8 bpp和16 bpp图像,因此应将ThresholdValue值适当地设置为像素格式。 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. 在8bpp图像的情况下,阈值在[0,255]范围内,但是在16bpp图像的情况下,阈值在[0,65535]范围内。

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 大津: 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 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 迭代: 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 . 我相信这些链接可以让您在将灰度图像转换为黑白图像时进行更多曝光,这称为二值化

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM