public HRegion Process(HRegion region) { if (Math.Abs(Radius) < 0.0000001) { return(region.MoveRegion(0, 0)); } var closingCircle = region.ClosingCircle(Radius); return(closingCircle); }
/// <summary> /// Example test method 1 for the Process call. /// </summary> private void FindBoundary() { HRegion lighter = new HRegion(); HRegion filledRgn = new HRegion(); HRegion closedRgn = new HRegion(); HRegion connectedRgn = new HRegion(); HRegion largestRegion = new HRegion(); HRegion circleRegion = new HRegion(); try { this.WaferRegion.Dispose(); lighter = this.Image.Threshold(5.0, 255.0); filledRgn = lighter.FillUp(); closedRgn = filledRgn.ClosingCircle(5.0); connectedRgn = closedRgn.Connection(); largestRegion = connectedRgn.SelectShapeStd("max_area", 0.0); // System.Threading.Thread.Sleep(2000); // Does not block. this.processedRegion = largestRegion.ShapeTrans("convex"); // Debug display test. // Uncomment and block processed display in View to see the debug output. // Comment out call to CircularizeAndShrinkRegion for a persistent display. ////this.DebugDisplay.Dispose(); ////DisplayCollection tempDC = new DisplayCollection(); ////tempDC.AddDisplayObject(lighter.CopyObj(1, -1), "red"); ////this.DebugDisplay = tempDC; } catch (HalconException) { this.ErrorMessage = "Halcon Exception in FindBoundary"; this.ErrorCode = ProcessingErrorCode.ProcessingStep1Error; } catch (Exception) { this.ErrorMessage = "System Exception in FindBoundary"; this.ErrorCode = ProcessingErrorCode.ProcessingStep1Error; } finally { lighter.Dispose(); filledRgn.Dispose(); closedRgn.Dispose(); connectedRgn.Dispose(); largestRegion.Dispose(); circleRegion.Dispose(); } }