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

App to make measurements

I am writing an app to measure features in an image. I have set a threshold and applied it to my image, then I have created a mask (not sure if this is necessary), but I can't work out how to select the measurement types I want to make (area and mean intensity), after that I want to do the measurement and get the data. Are there any code snippets I can look at or can anyone send me something?

Best Answers

  • Answer ✓
    Paul --

    The way I see it, you have two options . . .

    1) Have your program actually set up the measurements that you need (see XYZSetUpMeasurements)

    or

    2) You:

        ** Set up the measurement that you want to use and store them in an IQO FILE via SAVE MEASUREMENT OPTIONS
        ** Have your program set the MEASUREMENT OPTIONS by performing a LOAD MEASUREMENT OPTIONS (see XYZRecallMeasurementOptionsFile)

    If you use OPTION number 2, the IQO FILE has to be available to any computer running the APP.  I usually do this by putting the IQO FILE in the same folder as the APP and then replacing the ABSOLUTE PATH with a RELATIVE PATH.

    In this case, if the IQO FILE was in the same folder as the VB, RESX, and IPP FILE then

                .FileName = "C:\temp\Example1.iqo"
    would become

                .FileName = MacroDir & "\Example1.iqo"
    

    Please note that the MACRODIR FUNCTION does not work when your APP is stored in an IPX FILE.

    I hope this information is helpful.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
        Public Function XYZSetUpMeasurements() As SimpleScript
            XYZSetUpMeasurements = New SimpleScript
            Dim doc1
    
            With Application.DocumentCommands.Active(XYZSetUpMeasurements)
                .Run(doc1)
            End With
    
            With Measure.MeasurementsCommands.Options(XYZSetUpMeasurements)
                .SelMeasurements = New MeasCollection()
                    .SelMeasurements.Add( New MeasEntry(eMeasures.RgnArea))
                    .SelMeasurements.Add( New MeasEntry(eMeasures.RgnDensity))
                .Segmentation.FilterRanges = New System.Collections.Generic.List(Of MeasFilterEntry)
                    .Segmentation.FilterRanges.Add( New MeasFilterEntry(eMeasures.RgnArea,0R,10000000R))
                    .Segmentation.FilterRanges.Add( New MeasFilterEntry(eMeasures.RgnDensity,-1000000000R,1000000000R))
                .Run(doc1)
            End With
    
        End Function
    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
        Public Function XYZRecallMeasurementOptionsFile() As SimpleScript
            XYZRecallMeasurementOptionsFile = New SimpleScript
            Dim doc1, window1
    
            With Application.DocumentCommands.Active(XYZRecallMeasurementOptionsFile)
                .Run(doc1)
            End With
    
            With Measure.Measurements.OptionsCommands.Open(XYZRecallMeasurementOptionsFile)
                .FileName = "C:\temp\Example1.iqo"
                .FilterIndex = 1
                .Run(doc1)
            End With
    
            With Application.WindowCommands.Define(XYZRecallMeasurementOptionsFile)
                .Run(doc1, window1)
            End With
    
        End Function
    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  • Answer ✓
    Paul,

    Matt's advice for using options file (IQO) would be the best choice, the file will restore all the options related to Count/Size including selected measurements and ranges.Though I recommend loading and saving that file to "Configuration Files" folder (default options folder). In that case the file will be automatically packaged with your app and the path will be automatically reconfigured when you install the app on other computers.

    Regards,

    Yuri

Answers

  • Hi Matt & Yuri - thanks for your advice. I need to allow the user to adjust the threshold so the IQO method might not work, or perhaps I load an IQO file and then 'overwrite' the threshold value. Paul
  • Yes, you load IQO (with hundreds of options) and then allow user to change threshold. (there are some posts on the forum that explain how to change threshold interactively)

    Yuri
Sign In or Register to comment.