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
0
Comments
-
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
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