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

Suspend and Resume Measurement Extraction . . .

2019-03-13-171720

All --

I am working on an APP that generates many (100s) of RECTANGULAR MEASUREMENT OBJECTS on an image.

It seems that the APP slows down as more MEASUREMENT OBJECTS are created.

I thought there was CODE to SUSPEND and then RESUME the extraction of MEASUREMENTS from MEASUREMENT OBJECTS.

I have looked for this code in my PROJECTS and here on the FORUM but I cannot find it.

I would like to:
  1. SUSPEND MEASUREMENT UPDATES
  2. CREATE THE MEASUREMENT OBJECTS
  3. RESUME MEASUREMENT UPDATES
Thank you in advance.

-- Matt

Best Answers

  • Accepted Answer
    Matt,

    If you create objects one by one, then after adding of every object the data windows are updated, and that will slow down when you reach large number of objects. The best way would be to add all measurement objects at once.
    There are several ways to to that:
    1. Create all rectangular objects with the Grid Overlay Tool (Process tab), then add the grid to Features Manager and put it on the image as Measurements. You can also create rectangles using other tools (ROIs, Annotation,... and then add them as Measurements).
    2. Use low level functions to add Box objects to McRegions and then add these McRegions using McMMData.AddFeaturesAsManualMeasurements function. (search Automation Help by: IMcRegions.SetBox and AddFeaturesAsManualMeasurements for details).

    Yuri
  • Accepted Answer
    Hi Matt,

    Here is the example that adds 100 rectangle measurement objects to the active image:
    Imports MediaCy.Addins.Measurements
    Imports MediaCy.IQL.Features
    Public Module Module1
        Public Sub AddManyRctMeasures
            Dim im As McImage=ThisApplication.ActiveImage
            If im Is Nothing Then Exit Sub'no image
    
            Dim rgns As McRegions=im.RegionFeatures.Duplicate'create new regions
            Dim nRows As Integer=10
            Dim nCols As Integer=10
            Dim rw As Integer=im.Width/nCols
            Dim rh As Integer=im.Height/nRows
            Dim ind As Integer=0
            For i As Integer=0 To nRows-1
                For j As Integer=0 To nCols-1
                    rgns.SetBox(ind,j*rw,i*rh,(j+1)*rw-1,(i+1)*rh-1)
                    ind+=1
                Next
            Next
            Dim md As McMMData=im.MeasurementsData
            md.AddFeaturesAsManualMeasurements(rgns)
        End Sub
    End Module
    
    I've also attached IPX file.

    Yuri

Answers

  • 2019-03-14-092242

    Yuri --

    Thank you for the guidance.

    I will probably look into the #2 suggestion first.  If I can get this running it seems it that would be a more polished solution. 

    If I cannot get that up and running quickly, I will pursue your #1 suggestion.  I have done this type of thing in the past.

    A SUSPEND MEASUREMENTS OPTION may be a reasonable FEATURE REQUEST.  This would be something similar to EXCEL's ability to put a WORKSHEET/WORKBOOK into MANUAL CALCULATION MODE (vs AUTOMATIC CALCULATION MODE) so that a complicated WORKSHEET/WORKBOOK can be manipulated without the load of CALCULATION slowing things down.  This would be especially valuable OPTION when dealing with LARGE IMAGES with LARGE NUMBERS of MEASUREMENT OBJECTS.

    Thanks again.

    -- Matt

  • 2019-03-14-142217

    Yuri --

    I was unable to learn enough from the AUTOMATION HELP to use SUGGESTION #2.

    I implemented your SUGGESTION #1.  Initially I had the CODE generate the RECTANGULAR OBJECTS as ROI OBJECTS but this was only slightly faster than generating the OBJECTS as MEASUREMENT OBJECTS.  I then changed the CODE to generate the OBJECTS as ANNOTATION OBJECTS and that was significantly faster.  I was then able to use the FEATURE MANAGER to convert these into MEASUREMENT OBJECTS.

    I also found that turning off the UNDO BUFFERS helped speed things up.

    Is there some example code that illustrates your SUGGESTION 2?  I am sure that would be a more efficient and more polished solution.

    Thank you very much.

    -- Matt


  • 2019-03-14-160104

    Yuri --

    Thank you for the EXAMPLE CODE.

    I was able to transfer it into my PROJECT and run it on the image.

    I have a couple of other features that I need to get on-line before looping back to this but using this will be more polished than current method I am using with the ANNOTATION OBJECTS being saved and converted to MEASUREMENT OBJECTS.

    Thanks again.

    -- Matt


Sign In or Register to comment.