IMcPointsSelected Property |
![]() |
Namespace: MediaCy.IQL.Features
Default Property Selected ( <OptionalAttribute> Selector As Object ) As Object Get Set
'This is McMeasure_Filter_Examples.bas Option Explicit '**** Utilitiy Sub's 'Note: the BoneBig.jpg example image is a good one for these examples Private Function uLoadExampleImage(Optional strImage As String = "BoneBig.jpg") As Boolean If MsgBox("Open example image?", vbYesNo) = vbYes Then Images.Open Path + "Images\" + strImage End If 'user wants to open an example image 'Else leave the ActiveImage alone If ActiveImage Is Nothing Then MsgBox "There is no ActiveImage, so the example cannot run." End If uLoadExampleImage = ActiveImage Is Nothing End Function 'uLoadExampleImage '**** Runnable Examples Start Here ***** Public Sub ShowRgnAreaOutliersInYellow() If uLoadExampleImage Then Exit Sub ActiveImage.LineFeatures.Reset 'get rid of dangling lines 'Filter on region area, eliminate very small regions, and then show 'first and last quintile outliers in yellow With ActiveImage.RegionFeatures .Threshold.Execute 'get some region features .CleanUpBordersAndNoise , mcrbNoBorder, 10 'eliminate very small regions .Selected = True 'ensure that all features start selected With .mRgnArea Dim varRanks As Variant varRanks = McRankedValues(.value, 5) 'quintiles .RangeMin = varRanks(mcrvfiFirstNtileIndex + 0) 'First 20% .RangeMax = varRanks(mcrvfiFirstNtileIndex + 3) 'Last 20% .Filter 'de-select areas that are out of range End With 'show small and big areas in yellow .DisplayedObjects(McOpNOT(.Selected)).SetColors &HFFFF& End With 'ActiveImage.RegionFeatures End Sub 'ShowRgnAreaOutliersInYellow Public Sub KeepOnlyBigElongatedRegions() If uLoadExampleImage Then Exit Sub ActiveImage.LineFeatures.Reset 'get rid of dangling lines 'Filter on region aspect ratio and area, keeping only big elongated regions With ActiveImage.RegionFeatures .Threshold.Execute 'get some region features .Selected = True 'ensure that all features start selected 'Select elongated region features .mRgnAspect.RangeMin = 1.5 'minimum aspect ratio .mRgnAspect.RangeMax = 10000 'big maximum aspect ratio .mRgnAspect.Filter True 'de-select features that are round 'Select largest 25% of region features Dim varRanks As Variant varRanks = McRankedValues(.mRgnArea, 4) 'quartiles .mRgnArea.RangeMin = varRanks(mcrvfiFirstNtileIndex + 2) 'Top 25% .mRgnArea.RangeMax = 1000000# 'big maximum size .mRgnArea.Filter True 'de-select features that are small 'remove all small or round region features .RemoveFeature 'remove not-Selected features 'Same as above .RemoveFeature McOpNOT(.Selected) End With 'ActiveImage.RegionFeatures End Sub 'KeepOnlyBigElongatedRegions 'This example illustrates the use of the Filter method's AllInRangeElseAnyInRange 'argument to OR two filterings and then AND one to the result of those. Public Sub KeepOnlyLongVerticalLines() If uLoadExampleImage Then Exit Sub ActiveImage.RegionFeatures.Reset 'get rid of dangling regions 'Filter on line angle and length, keeping only longer than average vertical lines With ActiveImage.LineFeatures .SetFromMaskMethod = mcsfmmLinesLongestStraight .Threshold.Execute 'get some region features .CleanUpBordersAndNoise , mcrbAllBorders, 5 'get rid of very short or border lines .Selected = False 'Important: insure that all features start deselected 'get ones going up .mLnAngle.RangeMin = 60 .mLnAngle.RangeMax = 130 .mLnAngle.Filter False 'select only those going up 'or ones going down .mLnAngle.RangeMin = 240 .mLnAngle.RangeMax = 300 .mLnAngle.Filter False 'OR select those going down 'From those, select only longer than average vertical lines .mLnLength.RangeMin = .mLnLength.Mean 'longest of vertical lines 'note that the Mean is only of Selected line features, so 'it is the Mean of only lines that have passed the angle tests. .mLnLength.RangeMax = 1000000# 'big maximum length .mLnLength.Filter True 'AND de-select features that are short 'remove all non-vertical, short line features .RemoveFeature 'remove not-Selected features 'Same as above .RemoveFeature McOpNOT(.Selected) End With 'ActiveImage.RegionFeatures End Sub 'KeepOnlyLongVerticalLines '**** McMeasures.Filter examples ****** Public Sub ShowBigOrElongatedRegions() If uLoadExampleImage Then Exit Sub ActiveImage.LineFeatures.Reset 'get rid of dangling lines 'Filter on region area and roundness, showing regions that 'are either big or are particularly non-round in Cyan, and 'showing regions that are both big and non-round in Magenta With ActiveImage.RegionFeatures .Threshold.Execute 'get some region features .Measures.Unselect 'all Enabled=False 'Set Enable=True for the measurements we will need .Measures.Select Array("mRgnArea", "mRgnRoundness"), True 'the below does the same as the above using ID instead of name '.Measures.Select Array(.mRgnArea.Attributes(mcmaidID), .mRgnRoundness.Attributes(mcmaidID)), True 'The two assignments below do the same as the above Select calls '.mRgnArea.Enabled = True '.mRgnRoundness.Enabled = True 'Set the ranges we want to select on Dim varRanks As Variant 'Select largest 10% of region features varRanks = McRankedValues(.mRgnArea, 10) 'deciles .mRgnArea.RangeMin = varRanks(mcrvfiFirstNtileIndex + 8) 'Top 10% area .mRgnArea.RangeMax = 1000000# 'big maximum area varRanks = McRankedValues(.mRgnRoundness, 10) 'deciles .mRgnRoundness.RangeMin = varRanks(mcrvfiFirstNtileIndex + 7) 'Top 20% round .mRgnRoundness.RangeMax = 10000 'big maximum roundness .Measures.Filter False 'select either big regions OR elongated ones 'show big or elongated region features in cyan .DisplayedObjects(.Selected).SetColors &HFFFF00 .Measures.Filter True 'select big regions AND elongated ones 'show big and elongated region features in magenta .DisplayedObjects(.Selected).SetColors &HFF00FF End With 'ActiveImage.RegionFeatures End Sub 'ShowBigOrElongatedRegions