简体   繁体   English

使用Aforge.net将Ycbcr图像转换为灰度

[英]Converting Ycbcr Image to grayscale with Aforge.net

I'm new to Aforge.net. 我是Aforge.net的新手。
I have filtered and image with YCbCr filter with Aforge.Net 我已经使用Aforge.Net使用YCbCr过滤器进行过滤和图像处理

YCbCrFilter.Y = new Range(0, 1);
YCbCrFilter.Cb = new Range(-0.1862745098039216f, 0.0294117647058824f);
YCbCrFilter.Cr = new Range(0.0137254901960784f, 0.2254901960784314f);
// apply the filter
var YCbCrFilteredImage = YCbCrFilter.Apply(bitmap);

I need to convert the resulted image (ie YCbCrFilteredImage ) to Grayscale image, to convert it later to black and white image. 我需要将结果图像(即YCbCrFilteredImage )转换为Grayscale图像,以便稍后将其转换为黑白图像。
So how can I do the converting to grayscale? 那么如何进行灰度转换呢?

Salam Ruba ,, use this grayscale values Grayscale(0.2125, 0.7154, 0.0721) and for thresholding the BradleyLocalThresholding is the best in this library. Salam Ruba使用此灰度值Grayscale(0.2125,0.7154,0.0721)进行阈值设置,BradleyLocalThresholding是该库中最好的。 also instead of YCbCrFilter maybe you would like to use HSL Filtering and here is the code for you 也可能要使用HSL过滤 ,而不是YCbCrFilter,这是适合您的代码

    YCbCrFiltering YCbCrFilter = new YCbCrFiltering();
    YCbCrFilter.Y = new Range(0, 1);
    YCbCrFilter.Cb = new Range(-0.1862745098039216f, 0.0294117647058824f);
    YCbCrFilter.Cr = new Range(0.0137254901960784f, 0.2254901960784314f);
    // apply the filter
    var YCbCrFilteredImage = YCbCrFilter.Apply(bitmap);
    Grayscale gfilter = new Grayscale(0.2125, 0.7154, 0.0721);
    YCbCrFilteredImage = gfilter.Apply(YCbCrFilteredImage);
    BradleyLocalThresholding thfilter = new BradleyLocalThresholding();
    thfilter.ApplyInPlace(YCbCrFilteredImage);

you can search for blobs now ;) 您现在可以搜索blob了;)

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

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