DIFFERENT HISTOGRAM STATISTICS from GUI and CODE . . .
2019-09-27-182941
All --
I am attempting to extract the MEAN GRAY VALUE from an ROI within a 12bpp image.
The IMAGE HISTOGRAM gives me one value ((1687.88) and code that I have used before gives me a different value (1677.94). Other STATS are different also.
Please see below.
Both of these values change with the size / position of the ROI so I believe that both are restricting their statistics to the ROI.
The values in the GUI match the values extracted from the same ROI using IMAGE-PRO PLUS.
Assistance resolving the difference between the value in the GUI and the CODE would be much appreciated.
Thanks.
-- Matt
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
0
Best Answer
-
Matt,
I was not aware that it was a sequence. The UI histogram is shown for ActiveFrame, but the macro histogram is calculated for all frames.
Can you check it with single frame image?
Yuri
0
Answers
The histogram in a macro uses 256 bins by default, while the UI histogram uses 4096 bins on 12-bit images. You can set number of bins to 4096 to get the same stats:
Public Sub PrintMean Dim hist As Mediacy.IQL.Operations.McHistogram=ThisApplication.ActiveImage.Histogram hist.BinCount=4096 Debug.Print ("Mean =" & hist.Mean(0).ToString) End Sub
Regards,Yuri
Can you please try my code without modifications?
Public Sub PrintMean Dim hist As Mediacy.IQL.Operations.McHistogram=ThisApplication.ActiveImage.Histogram hist.BinCount=4096 Debug.Print ("Mean =" & hist.Mean(0).ToString) End Sub
With and without ROI. How big is your image?Yuri
Number Of Channels: 1
Pixel Data Type: Integer
Bits/Channel: 12
Bits/Pixel: 12
Bytes/Channel: 2
Bytes/Pixel: 2
Range Minimum: 0
Range Maximum: 4095
Camera Model: Rolera XR
Camera ID: 35980
Mode property of McHistogram controls Frame/Image access:
You can check automation help for more options, search for IMcHistogram (or mcHistogramMode).
Yuri