private void MoveClickHandler(System.Drawing.Point point) { Stopwatch watch = new Stopwatch(); watch.Start(); Bitmap clone = (Bitmap)Image.FromFile(ImagePath); BlackPixels.GetCombinationPairs() .Select(t => new { Points = t, line = PointUtils.GetPolarLineFromCartesianPoints(t), }) .Where(p => { var index = _accumulator.GetAccumulatorIndex(p.line); return(index[0] == point.X && index[1] == point.Y); }) .SelectMany(p => new[] { p.Points.Item1, p.Points.Item2 }) .ToList() .ForEach(p => clone.SetPixel(p.X, p.Y, Color.Magenta)); Source = clone; watch.Stop(); Console.WriteLine("click: Measured time: " + watch.Elapsed.TotalMilliseconds + " ms."); }
private async void GetLines() { _accumulator = new Accumulator(Source.Width, Source.Height, RhoDivisor, ThetaDivisor); await Task.Run(delegate { BlackPixels.GetCombinationPairs() .Select(PointUtils.GetPolarLineFromCartesianPoints) .ToList() .ForEach(_accumulator.AddVote); var line = _accumulator.GetMaxValue(); var bitmap = _accumulator .GetAccumulatorTable() .Spline(AccumulatorExtensions.GenerateNormalizedGauss(GaussSize, gaussFactor)) .ConvertToBitmap(); Application.Current.Dispatcher.Invoke(() => AccumulatorImage = bitmap); Debug.WriteLine(line); }); }