简体   繁体   中英

Converting Ycbcr Image to grayscale with Aforge.net

I'm new to Aforge.net.
I have filtered and image with YCbCr filter with Aforge.Net

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.
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. also instead of YCbCrFilter maybe you would like to use HSL Filtering and here is the code for you

    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 ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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