ShapeMap Test() { var rgbimage = new RGBImage(currentbtmp); var red = new ColorChannelImage(rgbimage, ColorChannel.R); var green = new ColorChannelImage(rgbimage, ColorChannel.G); var blue = new ColorChannelImage(rgbimage, ColorChannel.B); //GrayImage donegreen = null; //GrayImage donered = null; //GrayImage doneblue = null; #if PARALLEL var task1 = Task.Factory.StartNew(() => ApplyEdgeDetection(green)); var task2 = Task.Factory.StartNew(() => ApplyEdgeDetection(red)); var task3 = Task.Factory.StartNew(() => ApplyEdgeDetection(blue)); Task.WaitAll(task1, task2, task3); #else ApplyEdgeDetection(green); ApplyEdgeDetection(red); ApplyEdgeDetection(blue); #endif green = null; blue = null; red = null; var CombinedEdgeImage = rgbimage.GetBinaryImage(); Stage1.Image = CombinedEdgeImage.GetBitmap(); var blobs = CombinedEdgeImage.FindShapes(); Stage2.Image = blobs.GetBitmap(); var shapes = Shape.ShapeFromBinary(blobs); var bitmp2 = new Bitmap(300, 300, System.Drawing.Imaging.PixelFormat.Format24bppRgb); for (int i = 0; i < shapes.Count; i++) { for (int j = 0; j < shapes[i].Length; j++) { var point = shapes[i].GetPoint(j); bitmp2.SetPixel(point.X, point.Y, Color.White); } } Stage3.Image = bitmp2; for (int i = 0; i < shapes.Count; i++) { shapes[i].Reduce(5); } var bitmp = new Bitmap(300, 300, System.Drawing.Imaging.PixelFormat.Format24bppRgb); for (int i = 0; i < shapes.Count; i++) { for (int j = 0; j < shapes[i].Length; j++) { var point = shapes[i].GetPoint(j); bitmp.SetPixel(point.X, point.Y, Color.White); } } Stage4.Image = bitmp; //var targetShapes = shapes; Shape.OrderShapes(shapes); //Shape targetShapes = null; //for (int i = 0; i < shapes.Count; i++) //{ // if (shapes[i].Length >= (int)Shape.form.Circle) // { // targetShapes = shapes[i]; // } //} var targetTriangle = Shape.FindFormInForm(shapes, Shape.form.Circle, Shape.form.Triangle); var targetSquare = Shape.FindFormInForm(shapes, Shape.form.Circle, Shape.form.Square); var targetCircle = Shape.FindFormInForm(shapes, Shape.form.Circle, Shape.form.Circle); var targetShapes = new List <Shape> { targetTriangle, targetSquare, targetCircle }; var map = new ShapeMap(targetShapes); return(map); }