Line Profile
Hello
I'm writing an automation which measures the peak to peak distance in a binary image. I can measure the distances without problem, however I cannot access the data from the Line Profile table for measurements I use the following code
Dim data1 As McMMData With measure.MeasurementsCommands.GetData(Nothing) .Run(ThisApplication.ActiveImage, data1) End With With ThisApplication.Output For Each sf As McMMSubFeature In data1.SubFeatures Area = sf.Value(eMeasures.RgnArea) Next End With
but when I try the same thing using LineProfileCommands as below there is no GetData option. Is there another command to use instead
With measure.LineProfileCommands.??? End With
Any help appreciated
Regards
David
Answers
-
Hi David,
The Line Profile measurements table is not exposed directly, but you can “collect” this table with the Data Collector (select data provider: Line Profile, Edge Measurements). After the data collected in the Data Collector use the macro to retrieve the Edge Measurements table.
Public Function Get_Line_Profile_Measurements_Table() As SimpleScript Get_Line_Profile_Measurements_Table = New SimpleScript Dim data With Measure.Data.CollectorCommands.GetData(Get_Line_Profile_Measurements_Table) .Run(data) End With With Automate.ScriptingCommands.CodeCommand(Get_Line_Profile_Measurements_Table) If .Run() Then ' User Code Here Dim ds As System.Data.DataSet Dim dt As System.Data.DataTable ds = TryCast(data, System.Data.DataSet) If ds IsNot Nothing AndAlso ds.Tables.Contains("LPMeasurements") Then dt = ds.Tables("LPMeasurements") End If End If End With End Function
0 -
Hello Nikita
Still doesn't really help as I'd already tried to get the data from the data collector itself using the macro posted by Yuri (Programmatically extracting data from data collector) I can get yours and Yuri macro to give me the table names but no data and there is definitely data in the data collector and in the Line Profile data table.
The macro by Yuri does appear to cycle through the rows and columns held in the data collector but the only meaningful output is the column name the only other output is NaN or 1. So unfortunately I'm still confused.
Regards
David
0 -
Hi David,I don't know why Data Collector access didn't work for you.I have created a test app that does exactly that.Please test it (without any modifications).1 .Run SendDataToDC macro first and2. then PrintDataCollector.You should get the output like this:Table - MeasurementsCollect# Feature Name Region:Area Region:Diameter, Mean1 P1R1 130 11.8978439769161 P1R2 127 11.79666452319951 P1R3 105 10.60649353800561 P1R4 470 23.47444270762191 P1R5 27 6.15377918245377...Let me know if you have problems,Regards,Yuri0
-
The macro that prints DataCollector is:
Public Function PrintDataCollector() As SimpleScript PrintDataCollector = New SimpleScript Dim dataSet With Measure.Data.CollectorCommands.GetData(PrintDataCollector) .Run(dataSet) End With With Automate.ScriptingCommands.CodeCommand(PrintDataCollector) If .Run() Then ' User Code Here' ThisApplication.Output.Show For Each table As System.Data.DataTable In dataSet.tables ThisApplication.Output.PrintMessage( String.Format("Table - {0}",table.TableName)) Dim s As String="" For Each col As System.Data.DataColumn In table.Columns If s.Length>0 Then s+=vbTab s+=col.Caption Next 'print column headers ThisApplication.Output.PrintMessage( s,True) For Each row As System.Data.DataRow In table.Rows s="" For Each c As System.Data.DataColumn In table.Columns If s.Length>0 Then s+=vbTab 'get Value s+=row(c).ToString Next 'print row of data ThisApplication.Output.PrintMessage(s,True) Next Next End If End With End Function
Yuri0 -
David, this macro configures Data Collector to collect Line Profile Peak-Peak measurements.
Public Function Data_Collector_Line_Provile_Peak_Peak() As SimpleScript Data_Collector_Line_Provile_Peak_Peak = New SimpleScript With Measure.Data.Collector.MeasurementsCommands.Clear(Data_Collector_Line_Provile_Peak_Peak) .Run() End With With Measure.Data.Collector.MeasurementsCommands.Copy(Data_Collector_Line_Provile_Peak_Peak) .ProviderName = "LineProfile" .TableName = "LPMeasurements" .ColumnName = "Peaks_Peaks" .Run() End With End Function
0 -
Hello Yuri
Your testdatacollector script doesn't work at all. It causes an instant crash when I try to open it in the project explorer, I've never got it to the point of running. I've tried downloading it again so presumably the file is corrupt, can you post it again and I'll have another go
Dave
0 -
David,I just downloaded and tested the project. It works correctly on my PC. Just in case I've attached it again.What version of Premier do you use? (I tested with 9.1.1)Do you have other macro projects open in Premier? If yes, try to close them, restart Premier and load the project (just to exclude possibilities of hidden errors from other projects).If nothing works, let me know and we can do a webex.Regards,Yuri0
-
Hello Yuri
That worked in that it found and printed out all the measurments from the thresholded and counted image. Still not sure how to get it to switch table to show the line profile data but I'll persevere now that you've given me some code to get me started.
Dave
0 -
David,Nikita gave the name of the table and measurement that you need, so to get that specific table you can use:
table = dataSet.tables("LPMeasurements")
and to get column:
c = table.Columns("Peaks_Peaks")
Yuri
0 -
Thanks Yuri/Nikita
This seems to work, I just need to refine it a little for my app
David
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