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

how to export histogram statistics in a macro

I can copy the histogram itself to excel or i can export the entire data into excel and calculate relevant stats. in excel. Is there an easier way to extract the statistics only (Gmean, area, stdev etc)?


Comments

  • You can get all histogram stats using McHistogram object:

        Sub PrintHistStats
            Dim hist As MediaCy.IQL.Operations.McHistogram=ThisApplication.ActiveImage.Histogram
            Debug.Print "Red mean = " & hist.Mean(0)
            Debug.Print "Green mean = " & hist.Mean(1)
            Debug.Print "Red deviation = " & hist.StdDev(0)
        End Sub
    

    Check Automation help on McHistogram for other properties:

    Yuri
  • I am unable to find "automation help on McHistogram" . I am having difficulty finding help in general and hence posting questions of dubious challenge :(. Where should i be looking?
  • The help file itself is located at

    C:\Program Files\Media Cybernetics\Image-Pro Premier 9.1\Help\Image-Pro Premier Automation Help.chm

    you can open it directly from the folder. Also you can open it from Premier using the "Automation reference" menu item in the Help button drop-down in the Scripting workbench window (Question mark blue icon on the top-right side of the window).

  • When i run the code on a BINARY image the debug.print output does NOT match the stats triggered by histogram command. Snapshots attached. Please explain. I thought the mean  = (sum/area) but that does not appear to be the case. Please explain or give definitions for SUM &/or Mean. Thx.
  • Histogram panel uses HistogramSampled, which is faster for large images. You can compare the results using this macro:

         Sub PrintHistStats2
            Dim hist As MediaCy.IQL.Operations.McHistogram=ThisApplication.ActiveImage.Histogram
            Debug.Clear
            Debug.Print "Histogram"
            Debug.Print "Stdev = " & hist.StdDev(0)
            Debug.Print "Mean = " & hist.Mean(0)
            Debug.Print "Sum = " & hist.Sum(0)
            hist =ThisApplication.ActiveImage.HistogramSampled
            Debug.Print "HistogramSampled"
            Debug.Print "Stdev = " & hist.StdDev(0)
            Debug.Print "Mean = " & hist.Mean(0)
            Debug.Print "Sum = " & hist.Sum(0)
        End Sub
    
    The definitions from the help:
    The calibrated (depending on Mode) Sum of all the bin counts where calibrated bin counts (Values) are multiplied by their x value (calibrated intensity), and accumulated.
    image Declaration Syntax
    Visual Basic
    ReadOnly Property Sum ( _
    	Channel As Integer _
    ) As Object
    	Get
    image Parameters
    Channel (Int32)
    image Remarks
    The Compute method is called automatically (on the parent IMcImage) whenever it is necessary. In order to compute the Histogram on another image than the parent, one has to call Compute explicitly. This property returns an array of NumberOfChannels values if Channel=-1, or otherwise a single double precision floating point value for the specified channel. Note that since most property viewers (including the VBA Immediate window) will only display single (scalar) values, the channel must be specified when the property is used in this way, for instance, ? ThisApplication.ActiveImage.Histogram.Sum 0

    The calibrated (depending on Mode) Mean of all the bin counts.
    image Declaration Syntax
    Visual Basic
    ReadOnly Property Mean ( _
    	Channel As Integer _
    ) As Object
    	Get
    image Parameters
    Channel (Int32)
    image Remarks
    The Compute method is called automatically (on the parent IMcImage) whenever it is necessary. In order to compute the Histogram on another image than the parent, one has to call Compute explicitly. This property returns an array of NumberOfChannels values if Channel=-1, or otherwise a single double precision floating point value for the specified channel. Note that since most property viewers (including the VBA Immediate window) will only display single (scalar) values, the channel must be specified when the property is used in this way, for instance, ?ActiveImage.Histogram.Sum 0 The property is exposed as an array of NumberOfChannels values if Channel=-1, or a single double precision floating point value.


    Yuri
Sign In or Register to comment.