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

Get number of ROI

Hello

I've got an image with several ROI on it which have been added to the features manager I want to apply the ROI's to a separate image 1 at a time in a loop. I've got code to perform the loop but I can't find a command to end the loop. Here is the code

Dim AddUp As Integer
        AddUp = 0
        Do
            With Select.FeaturesManagerCommands.Apply(NewMacro)
                .Collection = 0
                .Feature = 0
                .Item = AddUp
                .Run(doc1)
            End With
            AddUp = AddUp + 1
        Loop


I was trying to use the result of Feature to stop the loop but its always set to true.  Is there another command I can put within the With statement or is there a way to get an ROI count so that I can use a For loop


Regards

David  

Best Answer

  • Answer ✓
        Public Function GetItemsCount (collection As Integer, feature As Integer) As Integer
            Dim items As Object
            Dim f As MediaCy.IQL.Features.McFeatures
            Dim o As MediaCy.IQL.Display.Overlays.McGraphOverlay
    
            items = MediaCy.Commands.Features.FeaturesManager.Common.GetFeature(collection,feature)
    
            f = TryCast(items, MediaCy.IQL.Features.McFeatures)
            If f IsNot Nothing Then Return f.Count
    
            o = TryCast(items, MediaCy.IQL.Display.Overlays.McGraphOverlay)
            If o IsNot Nothing Then Return o.Count
    
            Return 0
        End Function
     

Answers

  • Hi David,

    The following function returns number of items in the selected collection/feature:

     

     

     

  • Hello Nikita

    Works and even gives me the image overlays as well

    Thanks

    David

  • GetItemsCount function counts objects stored in the Features Manager and they are not from the active image.
Sign In or Register to comment.