public static async void PercentBlackSelectionBinarisation(this Brush brush, int percent) { Bh.Initialize(brush); var histogram = new Histogram((ImageBrush)brush); var lut = BinarisationHelper.GetBlackPercentLut(percent, Bh.Width * Bh.Height, histogram.HistogramAv); for (var i = 0; i < Bh.Length; i += 4) { var r = Bh.Pixels[i + 2]; var g = Bh.Pixels[i + 1]; var b = Bh.Pixels[i]; Bh.Pixels[i + 2] = (byte)lut[r]; Bh.Pixels[i + 1] = (byte)lut[g]; Bh.Pixels[i] = (byte)lut[b]; } await Bh.UpdateBrush(); }
public static void PerformOtsu(this Brush brush) { int threshold = BinarisationHelper.GetOtsuThreshold((ImageBrush)brush); MakeManualBinarisation(brush, threshold); }