private static List <Point> DetectContourPoints(Bitmap target, ThresholdParams param) { BitmapData targetData1 = target.LockBits(new Rectangle(0, 0, target.Width, target.Height), ImageLockMode.ReadWrite, target.PixelFormat); byte[] targetData = new byte[targetData1.Stride * targetData1.Height]; Marshal.Copy(targetData1.Scan0, targetData, 0, targetData.Length); target.UnlockBits(targetData1); byte[] newTargetData = new byte[targetData.Length]; bool[,] mask = new bool[target.Size.Width, target.Size.Height]; List <Point> points = new List <Point>(); if (param.IsAdapt) { points = ThresholdAdapter.Adapt(target, param); } return(points); }
public IActionResult Binarization([FromServices] ImageAccount imageAccount) { var thresholds = new ThresholdAdapter(Request.Query) .Adapt(); var redThresholds = thresholds.First(it => it.Spectrum == ColorSpectrum.Red); var greenThresholds = thresholds.First(it => it.Spectrum == ColorSpectrum.Green); var blueThresholds = thresholds.First(it => it.Spectrum == ColorSpectrum.Blue); var resultImage = new BinarizerBuilder() .RedTemplate(redThresholds.Template) .GreenTemplate(greenThresholds.Template) .BlueTemplate(blueThresholds.Template) .RedThresholds(redThresholds.Thresholds) .GreenThresholds(greenThresholds.Thresholds) .BlueThresholds(blueThresholds.Thresholds) .Build() .Binarization(imageAccount[new IdAdapter(Request.Query).Adapt()].Image); return(File(new Adapters.OutputAdapter.ImageAdapter(resultImage).Adapt(), "image/png")); }