Home Image-Pro Automation (Macros, Apps, Reports)
Options

Convert ROI into Measurement

Hallo,

I am looking for an easy way to convert ROIs in Measurements. Because I know there is a simple way to convert Measurements into ROIs. Like:

<div>Private Sub ConvertMeasurementsToROIs()</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Dim imageA as McImage=ThisApplication.ActiveImage</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Dim md As Mediacy.Addins.Measurements.McMMData=imageA.MeasurementsData</div><div>&nbsp; &nbsp; &nbsp; &nbsp; If md.SubFeatures.Count=0 Then Exit Sub</div><br><div>&nbsp; &nbsp; &nbsp; &nbsp; 'get McRegions from the first features</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Dim rgns As MediaCy.IQL.Features.McRegions=TryCast(md.SubFeatures(0).GetFeatures,MediaCy.IQL.Features.McRegions)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; If rgns IsNot Nothing Then</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'create ROIs from measurement features</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; imageA.Aoi.CopyFrom(rgns)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; End If</div><div><span>End Sub</span></div>

Thank you in advance
Best,
Friedrich

Best Answers

  • Options
    Answer ✓
    Hi Friedrich,

    You can do it using the Features manager (Select tab). Add ROIs to feartures manager and put it on the image as Measurements:



    Or, if you want to do it using a macro, use this code:

        Public Sub ROIsToMeasurements
            Dim im As McImage = ThisApplication.ActiveImage
            Dim md As McMMData = im.MeasurementsData
            md.AddFeaturesAsManualMeasurements(im.Aoi.Duplicate)
            'optionally cleanup ROIs
            im.Aoi.Reset
        End Sub
    

    Yuri
  • Options
    Answer ✓
    Hi Friedrich,

    The measurements could be locked, to unlock them:
    1. Ensure that the Filled option of the measurement outlines is off:

    2. Unlock the objects in the Select group dropdown:

    Regards,

    Yuri

Answers

  • Options
    Great!

    Thanks a lot
    Best,
    Friedrich
  • Options
    Hi Yuri,

    after I have converted the ROI into a measurement with the macro, I cannot move or enlarge or reduce the measurement with the selection tool. This also happens when I try the first method described with the feature manager.

    Best,
    Friedrich

  • Options
    Hi Yuri,

    yes, the measurement was locked. I enlarged the code with:

    md.UnlockObjects(True)
    Thanks
    Best,
    Friedrich
Sign In or Register to comment.