IMcProfileEdgesRawProfiles Property |
![]() |
Namespace: MediaCy.IQL.Features
Property RawProfiles ( Optional bClosedProfiles As Boolean = false, <OptionalAttribute> RangeMinMax As Object ) As Object Get Set
'This is GlobalMcProfileEdgesSamples.bas 'It has samples of using a global McProfileEdges operator instance '(one without a parent operator) to detect "edges" on arbitrary profiles. ' Option Explicit 'This method creates a global McProfileEdges instance named "GlobalEdges" Public Sub CreateGlobalMcProfileEdges() CreateOperator "McProfileEdges", , "GlobalEdges" End Sub 'CreateGlobalMcProfileEdges 'This method finds local peaks in a monochrome image histogram Public Sub FindMonochromeImagePeaks() Output.Show "Output" Output.Clear 'Open a grayscal image Images.Open Path + "Images\" + "MusBrain.tif" If ActiveImage Is Nothing Then Exit Sub 'Create an unnamed global McProfileEdges instance Dim globalEdges As McProfileEdges Set globalEdges = CreateOperator("McProfileEdges", Empty) 'Get a luminance histogram of the image ActiveImage.Histogram.Interpretation = mciMonochrome 'just to be sure we get only 1 channel With globalEdges 'Assign the histogram as the single profile .RawProfiles(False, 0) = ActiveImage.Histogram.Values 'Average 31 adjacent bins when looking for peak patterns .EdgeFindingMethod = mcpefmMatchPattern .Pattern = Array(0#, 0.5, 1#, 0.5, 0#) .MatchLength = 31 .ThresholdForEdge = 20 'Find a max of 5 peaks .MaxEdgesPerProfile = 5 .FindEdges Dim strReport As String strReport = Str(.EdgeCounts(0)) & " peaks were found in the luminance histogram." If .EdgeCounts(0) <> 0 Then strReport = strReport & vbCrLf & "Peaks were found at: " & McToText(.EdgeDistances(0)) End If 'any peaks found End With 'globalEdges Output.PrintMessage strReport ActiveWindow.Close End Sub 'FindMonochromeImagePeaks 'This method finds peaks in a monochrome image histogram based on log of bin counts Public Sub FindColorImagePeaks() Output.Show "Output" Output.Clear 'Open a color image Images.Open Path + "Images\" + "FlTriple.tif" If ActiveImage Is Nothing Then Exit Sub 'Create an unnamed global McProfileEdges instance Dim globalEdges As McProfileEdges Set globalEdges = CreateOperator("McProfileEdges", Empty) 'Get an RGB histogram of the image ActiveImage.Histogram.Interpretation = mciRGB 'just to be sure we get only 1 channel With globalEdges 'use Log histogram bin counts for peak detection Dim mcobjCounts As McObject Set mcobjCounts = McObjectTemp(ActiveImage.Histogram.Values) 'set all zero counts to 1 (log of zero is illegal) Dim selZeroCounts As McObject Set selZeroCounts = McOpEQ(mcobjCounts, 0) mcobjCounts.SelectedValues(selZeroCounts) = 1 'set the raw profile to find "edges" on to Log(Histogram.Values) .RawProfiles(False, 0) = McLog(mcobjCounts) 'Get count of profiles Dim lRawProfilesCount As Long lRawProfilesCount = UBound(.RawProfiles) + 1 'Find highest peaks in each color band .EdgeFindingMethod = mcpefmPeaks .Weights = Array(0.25, 1#, 1#, 1#, 0.25) .MatchLength = 5 .ThresholdForEdge = 50 'Find a max of 5 peaks .MaxEdgesPerProfile = 5 .FindEdges Dim strReport As String, iChannel As Long strReport = "Peaks in an RGB histogram." For iChannel = 0 To 2 strReport = strReport & vbCrLf & Str(.EdgeCounts(iChannel)) & " peaks were found in the channel " & Str(iChannel) & " histogram." If .EdgeCounts(iChannel) <> 0 Then strReport = strReport & vbCrLf & "Peaks were found at: " & McToText(.EdgeDistances(iChannel)) End If 'any peaks found Next iChannel End With 'globalEdges Output.PrintMessage strReport ActiveWindow.Close End Sub 'FindColorImagePeaks