IMcImageCastingSourceRange Property |
![]() |
Namespace: MediaCy.IQL.Engine
'This example stretches the luminance of pixels under the AOI 'to the full scale RangeMin and RangeMax for the McImage.Type ThisApplication.ActiveImage.CastingSourceRange = Empty 'reset to defaults Debug.Print "Default CastingSourceRange is: " _ & GlobalTools.McToText(ActiveImage.CastingSourceRange).Value 'Get a copy of the McImage.Type with default Min/MaxCastingLuminance Dim mcimagetypeDest As McImageType Set mcimagetypeDest = ThisApplication.ActiveImage.Type 'Get a copy of the McImage.Type 'Find the absolute luminance range of any channel Dim arrayFullRange As Variant ThisApplication.ActiveImage.Histogram.Interpretation = mciAnyInterp arrayFullRange = ThisApplication.ActiveImage.Histogram.AbsoluteRange Debug.Print "Full source luminance range is: " & GlobalTools.McToText(arrayFullRange).Value Dim rangeAnyChannel As DOUBLERANGE rangeAnyChannel.Start = McMin(McObjectTemp(arrayFullRange).SelectedValues(Empty, 0)) rangeAnyChannel.end = McMax(McObjectTemp(arrayFullRange).SelectedValues(Empty, 1)) Debug.Print "Max source luminance range for any channel is: " _ & GlobalTools.McToText(rangeAnyChannel).Value 'Set the casting source range to the range of luminances in the image AOI ThisApplication.ActiveImage.CastingSourceRange = rangeAnyChannel Debug.Print "The CastingSourceRange is now: " & GlobalTools.McToText(ActiveImage.CastingSourceRange).Value 'Get a McRegionAccess of the AOI cast to RangeMin thru RangeMax Dim regionaccessCast As McRegionAccess Set regionaccessCast = ThisApplication.ActiveImage.Aoi.AccessMaskedImageData( _ mcimagetypeDest, mcwcAllChannels, McActiveFrame) 'The above will reset the CastingSourceRange to its default Debug.Print "The CastingSourceRange has been reset to: " _ & GlobalTools.McToText(ActiveImage.CastingSourceRange).Value 'Check the Min and Max luminance values in the block Dim varBlockOfPixels As Variant, lNinBlock As Long lNinBlock = regionaccessCast.GetArea(varBlockOfPixels) vMin = McMin(varBlockOfPixels) vMax = McMax(varBlockOfPixels) Debug.Print "Min, Max in the cast block = " & McSprintf("%d, %d", vMin, vMax) 'Mark the regionaccessCast as "dirty", so that a back-cast will be done regionaccessCast.SignalImageChanged 'Now release the region access to force the back cast into the image. 'Since CastingSourceRange is now the default of RangeMin to RangeMax, 'the back-cast will stretch the luminances under the AOI to this range. Set regionaccessCast = Nothing