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

Image Histogram

Hi Yuri,
thank you very much.
In the meantime I found this solution that is a little bit different from yours, let me know if it is correct.
    Dim hist As MediaCy.IQL.Operations.McHistogram = ImEmpty.Histogram
    Dim dMedia As Double = hist.Mean(0)
    Dim dMinimo As Double = hist.Min(0)
    Dim dMassimo As Double  = hist.Max(0)
    Dim dStdDev As Double = hist.StdDev(0)
The image is 8GL but, in case of RGB24, using the index (0) Red (1) Green and (2) Blu I got all the info
I would like to get the histo Moda (max frequency index ) too.
I tried to use the followed code it reports me an error (HRESULT 0x80020011 DISP_E_NOTACOLLECTION)
Dim dMode As Double = hist.Mode(0) Probabily it is not the parameter I need. Ciao Maurizio

Answers

  • Hi Maurizio,

    hist.Mode is not what you want, it's just a mode to calculate histogram:
    Mode - A read-write property used to specify how the histogram values and statistics are computed and reported. (see Public Enumeration mcHistogramMode).

    The statistical Mode parameter can be extracted using another method, find bin value with maximum amplitude:

        Public Sub HistMode
            Dim histogram As MediaCy.IQL.Operations.McHistogram=ThisApplication.ActiveImage.Histogram
            Dim Channel As Integer=0'check Red channel
            'find mode: find bin value with maximum amplitude
            Dim maxVal As Long = -1
            Dim modeBin As Long = -1
            For bin As Long = 0 To histogram.BinCount - 1
                Dim binVal As Long = histogram.Values(bin, Channel)
                If binVal > maxVal Then
                    maxVal = binVal
                    modeBin = bin
                End If
            Next
            If modeBin >= 0 Then
                Debug.Print "Histogram mode value  = " & histogram.BinXValues(modeBin)
            End If
        End Sub
    

    Yuri

  • thank you Yuri, I did the same.
    Ciao
    Maurizio
Sign In or Register to comment.