public void GetLengthBeforLoop() { var pixels = GenerateImage(); Stopwatch time = new Stopwatch(); time.Start(); var picture = Grayscale.ToGrayscale(pixels); time.Stop(); Console.Out.WriteLine(time.ElapsedTicks); }
private static void Main() { var bmp = (Bitmap)Image.FromFile("eurobot.bmp"); var pixels = LoadPixels(bmp); var form = new Form { ClientSize = new Size(3 * ResizeRate * bmp.Width, 2 * ResizeRate * bmp.Height) }; var panel = new TableLayoutPanel { RowCount = 2, ColumnCount = 3, Dock = DockStyle.Fill }; form.Controls.Add(panel); panel.Controls.Add(CreateBox(ConvertToBitmap(pixels)), 0, 0); var grayscale = Grayscale.ToGrayscale(pixels); panel.Controls.Add(CreateBox(ConvertToBitmap(grayscale)), 1, 0); var clear = MedianFiltere.MedianFilter(grayscale); panel.Controls.Add(CreateBox(ConvertToBitmap(clear)), 2, 0); var sobell = SobelFilterClass.SobelFilter(clear, new double[, ] { { -1, -2, -1 }, { 0, 0, 0 }, { 1, 2, 1 } }); panel.Controls.Add(CreateBox(ConvertToBitmap(sobell)), 0, 1); var trashhold = ThresholdFilterClass.ThresholdFilter(sobell, 0.1); panel.Controls.Add(CreateBox(ConvertToBitmap(trashhold)), 1, 1); var bitmap = ConvertToBitmap(sobell); using (var g = Graphics.FromImage(bitmap)) { var lines = HoughTransform.HoughAlgorithm(sobell); var pen = new Pen(Color.Red, 2); foreach (var e in lines) { g.DrawLine(pen, e.X0 * ResizeRate, e.Y0 * ResizeRate, e.X1 * ResizeRate, e.Y1 * ResizeRate); } } panel.Controls.Add(CreateBox(bitmap), 2, 1); Application.Run(form); }