How to find a circle inside a rectangle in AForge

I am trying to detect a Circle inside a Rectangle in AForge . I successfully defined Rectangles , but could not find circles inside the Rectangle . How to find a shape inside another shape in AForge .

 string strPath = Server.MapPath("~/Recipt001.png"); Bitmap myBitmap = new Bitmap(strPath); //Some filters Grayscale, invert, threshold //Blod Filtering BlobCounter blobCounter = new BlobCounter(); blobCounter.ProcessImage(temp); blobCounter.ObjectsOrder = ObjectsOrder.YX; blobCounter.FilterBlobs = true; Blob[] blobs = blobCounter.GetObjectsInformation(); Graphics g = Graphics.FromImage(myBitmap); Pen redPen = new Pen(Color.Red, 2); SimpleShapeChecker shapeChecker = new SimpleShapeChecker(); // dictionary of color to highlight different shapes Dictionary<PolygonSubType, Color> colors = new Dictionary<PolygonSubType, Color>(); colors.Add(PolygonSubType.Unknown, Color.White); colors.Add(PolygonSubType.Trapezoid, Color.Orange); colors.Add(PolygonSubType.Parallelogram, Color.Red); colors.Add(PolygonSubType.Rectangle, Color.Green); colors.Add(PolygonSubType.Square, Color.Blue); colors.Add(PolygonSubType.Rhombus, Color.Gray); colors.Add(PolygonSubType.EquilateralTriangle, Color.Pink); colors.Add(PolygonSubType.IsoscelesTriangle, Color.Purple); colors.Add(PolygonSubType.RectangledTriangle, Color.SkyBlue); colors.Add(PolygonSubType.RectangledIsoscelesTriangle, Color.SeaGreen); for (int i = 0, n = blobs.Length; i < n; i++) { List<IntPoint> corners; List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]); Point center; double radius; if (shapeChecker.IsQuadrilateral(edgePoints, out corners)) { if (shapeChecker.CheckPolygonSubType(corners) == PolygonSubType.Rectangle) { g.DrawPolygon(redPen, ToPointsArray(corners)); } } } redPen.Dispose(); g.Dispose(); 
+6
source share
1 answer

None of the image processing libraries and even image processing in MATLAB allows you to search for ROIs inside ROIs (ROIs are areas of interest like rectangles or circles). CROP REGION concept → SEARCH FOR OBJECTS IN THE REGION

So, first find the primary rectangles, then circle the image in the rectangles and search in a circle inside them. Otherwise, find all the circles and all the rectangles, and then classify the circles belonging to that rectangle that use simple mathematical data.

+1
source

Source: https://habr.com/ru/post/1014802/


All Articles