Image Histogram
Hello
I'm trying to extract the max intensity value at each frame in a sequence. I could do a count and get the max intensity from the data table. However it seems that it would be easier and simpler code if I could get it from the image histograms. I've found the Histogram.AbsoluteRange command in the help files which seems like it would be ideal. I'm using the following code
Dim test Dim im As McImage im = ThisApplication.ActiveImage test(1,im) = im.Histogram.AbsoluteRange
I get an error about the object variable being empty, but as far as I can tell im has a value and as its a single channel image I've tried 0 and 1 for the channel but neither works. I can't see where the mistake is, any help appreciated
Regards
David
0
Best Answer
-
Hi David,
You have to activate ProcessActiveFrameOnly to get histogram data of active frame. AbsoluteRange retuns a 2D array of Start/End values per channel.Public Sub PrintHistStats Dim im As McImage=ThisApplication.ActiveImage If im Is Nothing Then Exit Sub Dim hist As MediaCy.IQL.Operations.McHistogram=im.Histogram 'measure only active frame hist.Mode=MediaCy.IQL.Operations.mcHistogramMode.mchmProcessActiveFrameOnly ThisApplication.Output.Show ThisApplication.Output.Clear For i As Integer=0 To im.FrameCount-1 im.ActiveFrameIndex=i Dim mean As Object=hist.Mean Dim absRange As Object=hist.AbsoluteRange ThisApplication.Output.PrintMessage(String.Format("Frame = {0}, Mean ={1}, AbsoluteRange = {2}",i+1,ThisApplication.GlobalTools.McToText(mean).Value,ThisApplication.GlobalTools.McToText(absRange,New Object(){"","",":",";"}).Value)) Next End Sub
You can find more info in the help on IMcHistogram page and the methods.Image-Pro Premier Automation Help
AbsoluteRange Property (Channel, SourceImage)Automation Reference ► MediaCy.IQL.Operations ► IMcHistogram ► AbsoluteRange[([( Int32, Object])]) Visual BasicReturns the absolute minimum and maximum luminanance.Declaration SyntaxRemarksThese are not the same as McImage.RangeMin and McImage.RangeMax which are set by the user for floating point images, and represent the minimum and maximum possible values for integral image types. The values may also differ from the Min and Max McHistogram properties. The Min and Max properties give the BinXValues element of the lowest and highest, respectively, bins with non-zero counts. These values will usually differ from the AbsoluteRange for floating point image types and where the BinCount is less than MaxBinCount. AbsoluteRange is exposed as a 2D array ([IMcIMage.NumberOfChannels][2] in C, (0 to 1,0 to IMcIMage.NumberOfChannels-1) in VB) if Channel=-1, or an array containing two double precision floating point values if Channel is non-negative. If the source McImage.ActiveFrameRange specifies some frames, then unless the Mode mchmProcessActiveFrameOnly bit is set or the SampledFrame property is non-negative, the AbsoluteRange is computed from all of the specified frames. If the Mode mchmProcessActiveFrameOnly bit is set, then only the McImage.ActiveFrame is conisidered. If the Mode mchmIgnoreAoi bit is set, then any Aoi is ignored. The AbsoluteRange property honors the Interpretation property and also the Mode mchmApplyIntensityCalibration flag. If the Interpretation is one that has a natural luminance channel (e.g., mciHSL or mciHSI), then when the Mode mchmApplyIntensityCalibration flag is set, intensity calibration is only applied to the luminance channel.
Regards,
Yuri
0
Answers
Hello Yuri
That works
Thanks
David