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
-
2022-06-30-171024Yuri --Thank you for your guidance on this.I copied your
Function AddObjectWithHole()
into myFORUM-QUESTION.ipxPROJECT FILE.The PROJECT would not load until I added REFERENCES as shown hereand added IMPORTS to the IPP FILE as shown hereAfter that, the PROJECT did LOAD but runningAddObjectWithHole
Did not generate the results expected.I created an "AddObjectWithHole2" from "AddObjectWithHole" and did a bit of tweaking so that after runningNewMacroandAddObjectWithHole2 (below)the result is an image with a MEASUREMENT OBJECT with the same proper boundaries and AREA MEASUREMENT of approximately 88,000 SQ PIX from above. The result of runningNewMacro+AddObjectWithHole2is shown hereThe CODE that needed to be modified to make "AddObjectWithHole2" work with the IMAGE from "NewMacro" is COMMENTED OUT and followed immediately by the 2 CODE.Oops . . .I almost forgot to mention that I needed to set theMEASUREMENT OPTIONS+CLEAN BORDERS OPTION = NONEI have posted all of this for the folks that may find this example helpful.Thank you very much for your assistance.-- MattPublic Function AddObjectWithHole2() As SimpleScript AddObjectWithHole2 = New SimpleScript Dim image1, doc1 With Application.DocumentCommands.ActiveImage(AddObjectWithHole2) .Run(image1) End With With [Select].RoiCommands.Add(AddObjectWithHole2) .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)) .Points.Add(New System.Drawing.PointF(238.3966F,243.6709F)) .Points.Add(New System.Drawing.PointF(356.7896F,356.7896F)) .Angle = 0R .Run(image1) End With With [Select].RoiCommands.Add(AddObjectWithHole2) .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)) .Points.Add(New System.Drawing.PointF(239.4515F,237.3418F)) .Points.Add(New System.Drawing.PointF(124.5977F,124.5977F)) .Angle = 0R .Run(image1) End With With Application.DocumentCommands.Define(AddObjectWithHole2) .Run(image1, doc1) End With With [Select].RoiCommands.XORROIs(AddObjectWithHole2) .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked .Run(doc1) End With With [Select].RoiCommands.ShowMask(AddObjectWithHole2) .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked .Overlay = Overlays.OverlayType.ROIOverlay .Run(doc1) End With With Measure.MeasurementsCommands.Options(AddObjectWithHole2) .Segmentation.AutoFindPhase = MediaCy.IQL.Features.mcFindPhase.mcfpManual .Segmentation.SegmentationType = McMMOptions.mcmmSegmentationType.mcmmstThresholdSegmentation .Run(doc1) End With With Measure.ThresholdToolCommands.Thresholds(AddObjectWithHole2) .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})) .Classes.Add(New SegmentationClass("Class 1",System.Drawing.Color.Blue,New Double(){0R,65280R})) .Run(image1) End With With Measure.MeasurementsCommands.ExecuteCount(AddObjectWithHole2) .Run(doc1) End With With [Select].RoiCommands.DeleteAll(AddObjectWithHole2) .Run(doc1) End With End Function
0 -
Hi Matt,
Glad that you made it worke and figured out missing references!
Yuri0 -
2022-07-01-145025Yuri --I just keep sayingWHAT WOULD YURI DO?; - )-- Matt
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions