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

Get area size based on histogram

Hi there,

I can get any values by program code (e.g. intensity mean) from the histogram based on ROI. Also it works fine with the XOR ROIs functionality to read out correct values.

    Public Sub ShowROIArea
        Dim histo As MediaCy.IQL.Operations.McHistogram=ThisApplication.ActiveImage.Histogram
        histo.Mode = MediaCy.IQL.Operations.mcHistogramMode.mchmApplySpatialCalibration
        histo.Interpretation = mcInterpretation.mciMonochrome
        histo.Mode = histo.Mode And (Not MediaCy.IQL.Operations.mcHistogramMode.mchmIgnoreAoi) 'use ROI

        MsgBox histo.Mean(0).ToString
    End Sub
How can I read out the Area shown in the histogram?

Thank in advance
fsup

Comments

  • Hi fsup,

    You can get area directly from ROI (ActiveImage.Aoi) or you can get it from the histogram by summarizing the values of all bins. Here is the macro:

        Public Sub ShowROIArea
            Dim histo As MediaCy.IQL.Operations.McHistogram=ThisApplication.ActiveImage.Histogram
            histo.Mode = MediaCy.IQL.Operations.mcHistogramMode.mchmApplySpatialCalibration
            histo.Interpretation = mcInterpretation.mciMonochrome
            histo.Mode = histo.Mode And (Not MediaCy.IQL.Operations.mcHistogramMode.mchmIgnoreAoi) 'use ROI
            'ensure that we count all pixels in ROI
            histo.SamplingCoverage=100
            'calculate area as the sum of all bins
            Dim area As Double=0
            Dim nBins As Integer=histo.BinCount
            For i As Integer=0 To nBins-1
                area+=histo.Values(i,0)
            Next
            'show area in calibrated units
            MsgBox "ROI area = " & area.ToString()
    
            'MsgBox histo.Mean(0).ToString
        End Sub
    

    Yuri
  • Hallo Yuri,

    thank you for your prompt reply. It works fine B) 
    fsup
Sign In or Register to comment.