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

How to access measurement data in your App

Many Apps take advantage of the powerful measurement capabilities of Image-Pro Premier, whether it is Count/Size or simple Manual Measurements but what if your App needs to do more with the measurement data than what the built-in feature does? The following macro illustrates how a simple macro can have full access to the measurement results and statistics. A reference to MediaCy.Addins.Measurements.dll will be needed.
Imports MediaCy.Addins.Measurements

Public Module Macros

Public Sub GetData()
Dim data As McMMData
Dim stats(8) As Double

ThisApplication.Output.show

With measure.MeasurementsCommands.GetData(Nothing)
.Run(ThisApplication.ActiveDocument, data)
End With

' Statistics '

Dim measure As New MeasEntry
measure.Measurement=eMeasures.RgnArea
data.CalcStatistics(measure,stats)

ThisApplication.Output.PrintMessage("Mean Area = " & stats(0))
ThisApplication.Output.PrintMessage("SD Area = " & stats(1))
ThisApplication.Output.PrintMessage("Min Area = " & stats(2))
ThisApplication.Output.PrintMessage("Max Area = " & stats(3))

' Values '

For i As Integer = 0 To data.Rows-1
Dim feature As McMMSubFeature = data.SubFeature(i)
ThisApplication.Output.PrintMessage(String.Format("Area({0}) = {1}",i,feature.Value(eMeasures.RgnArea)))
Next

End Sub

End Module

Comments

  • edited July 2013
    There is also a direct property that returns statistics as McMMData.Statistcs. The list of all measurement features can be retrieved using the SubFeatures property in "for each" loop.  
    Another version of the macro:
        Public Sub GetData2()
            Dim data As McMMData
            ThisApplication.Output.show
    
            With measure.MeasurementsCommands.GetData(Nothing)
                .Run(ThisApplication.ActiveDocument, data)
            End With
    
            With ThisApplication.Output
                ' Statistics '
                .PrintMessage("Mean Area = " & data.Statistics(eMeasures.RgnArea).Mean)
                .PrintMessage("Sum  Area = " & data.Statistics(eMeasures.RgnArea).Sum)
                ' Values '
                Dim i As Integer=0
                For Each sf As McMMSubFeature In data.SubFeatures
                    .PrintMessage(String.Format("Area({0}) = {1}",i,sf.Value(eMeasures.RgnArea)))
                    i+=1
                Next
            End With
        End Sub
    
Sign In or Register to comment.