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

Image Histogram

Hi,
I need to get the image histogram info (RGB image).
I tried this code
    '----------------------------------------------------------------------
    Dim hist As MediaCy.IQL.Operations.McHistogram = ImEmpty.Histogram
    Dim dMedia As Double = hist.Mean  <---- Error Type mismatch (10080)
    Dim dMinimo As Double = hist.Min<---- Error Type mismatch (10080)
    Dim dMassimo As Double  =hist.Max<---- Error Type mismatch (10080)
    Dim dStdDev As Double = hist.StdDev<---- Error Type mismatch (10080)
    Dim dModa As Double = hist.Mode<---- Error Type mismatch (10080)
    '----------------------------------------------------------------------
NOTE ImEmpty is a McImage instance
According to the IQL reference the Mean is a double parameter

In case of AOI presence on the image should I use the region access method ( some think similar at the follow code)? 
 
    Dim ra As McRegionAccess=ImEmpty.CreateRegionAccess()
ra.RegionMask=ImEmpty.Aoi'process only active ROI
If yes which is the correct sintax to be used ? Thank you Maurizio

Answers

  • edited April 2015
    Hi Maurizio,

    If image is color, the Mean will be an array of values for every channel:

        Public Sub TestHist
            Dim hist As MediaCy.IQL.Operations.McHistogram = ThisApplication.ActiveImage.Histogram
            Dim dMedia As Double() = hist.Mean
            Debug.Print ThisApplication.GlobalTools.McToText(dMedia).Value
        End Sub
    If you don't know what output type is, I recommend using Object : 

        Public Sub TestHist2
            Dim hist As MediaCy.IQL.Operations.McHistogram = ThisApplication.ActiveImage.Histogram
            Dim dMedia As Object = hist.Mean
            Debug.Print ThisApplication.GlobalTools.McToText(dMedia).Value
        End Sub
    

    Regards,

    Yuri
  • Regarding ROI: histogram always uses ROI boundaries by default, so you don't have to do anything.

    Yuri
Sign In or Register to comment.