CREATE CIRCULAR MEASUREMENT OBJECT WITH HOLE . . .
2022-06-29-160135
All --
The IPX FILE attached to this QUESTION will create an IMAGE-PRO IMAGE with TWO CIRCULAR MEASUREMENTS / FEATURES as illustrated here.
I would like to alter the CODE in the IPX FILE so that the SMALLER CIRCULAR MEASUREMENT / FEATURE is a HOLE in the LARGER CIRCULAR MEASUREMENT FEATURE.
This is illustrated here by measuring this BRIGHT RING.
These images illustrate that in the first image, the LARGE CIRCLE is about 100,000 SQ PIX in AREA and the SMALL CIRCLE is approximately 12,000 SQ PIX. The RING is approximately 100,000 - 12,000 = 88,000 SQ PIX in AREA.
What change needs to be made to the CODE
With Measure.MeasurementsCommands.Add(NewMacro)
.MeasurementType = McMeasurements.enumMMSTypes.mmtsCircle
.Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
.Points.Add(New System.Drawing.PointF(239.4515F,237.3418F))
.Points.Add(New System.Drawing.PointF(124.5977F,28.30075F))
.FeatureName = "C2"
.SnapFeature = False
.Run(image1, meas2)
End With
so it will create a CIRCULAR HOLE and the resulting image will have one RING with an AREA of approximately 88,000 SQ PIX?
Thanks in advance.
-- Matt
0
Best Answer
-
Hi Matt,
It's not possible to draw measurement object with a hole in a macro. You can use other way: draw 2 circular ROI's, activate XOR mode and execute Count with whole range.
Here is the macro:Public Function AddObjectWithHole() As SimpleScript AddObjectWithHole = New SimpleScript Dim image1, doc1 With Application.DocumentCommands.ActiveImage(AddObjectWithHole) .Run(image1) End With With [Select].RoiCommands.Add(AddObjectWithHole) .ROIType = Features.ROI.ROITypes.Circle .Points = New System.Collections.Generic.List(Of System.Drawing.PointF) .Points.Add(New System.Drawing.PointF(48F,56F)) .Points.Add(New System.Drawing.PointF(49.67897F,49.67897F)) .Angle = 0R .Run(image1) End With With [Select].RoiCommands.Add(AddObjectWithHole) .ROIType = Features.ROI.ROITypes.Circle .Points = New System.Collections.Generic.List(Of System.Drawing.PointF) .Points.Add(New System.Drawing.PointF(47F,56F)) .Points.Add(New System.Drawing.PointF(21.26029F,21.26029F)) .Angle = 0R .Run(image1) End With With Application.DocumentCommands.Define(AddObjectWithHole) .Run(image1, doc1) End With With [Select].RoiCommands.XORROIs(AddObjectWithHole) .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked .Run(doc1) End With With [Select].RoiCommands.ShowMask(AddObjectWithHole) .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked .Overlay = Overlays.OverlayType.ROIOverlay .Run(doc1) End With With Measure.MeasurementsCommands.Options(AddObjectWithHole) .Segmentation.AutoFindPhase = MediaCy.IQL.Features.mcFindPhase.mcfpManual .Segmentation.SegmentationType = McMMOptions.mcmmSegmentationType.mcmmstThresholdSegmentation .Run(doc1) End With With Measure.ThresholdToolCommands.Thresholds(AddObjectWithHole) .AllowOverlap = False .Interpretation = eInterpretation.Mono .Classes = New System.Collections.Generic.List(Of SegmentationClass) .Classes.Add(New SegmentationClass("Class 1",System.Drawing.Color.Blue,New Double(){0R,255R})) .Run(image1) End With With Measure.MeasurementsCommands.ExecuteCount(AddObjectWithHole) .Run(doc1) End With With [Select].RoiCommands.DeleteAll(AddObjectWithHole) .Run(doc1) End With End Function
Regards,
Yuri0
Answers
Glad that you made it worke and figured out missing references!
Yuri