Click or drag to resize

IMcObjectSelectedMcObject Property

A McObject instance that exposes a sub-array of the Value property.

Namespace:  MediaCy.IQL.ObjectManager
Assembly:  MediaCy.IQL.ObjectManager (in MediaCy.IQL.ObjectManager.dll) Version: 10.0.6912.0
Syntax
VB
ReadOnly Property SelectedMcObject ( 
	<OptionalAttribute> varSelector0 As Object,
	<OptionalAttribute> varSelector1 As Object,
	<OptionalAttribute> varSelector2 As Object,
	<OptionalAttribute> varSelector3 As Object
) As McObject
	Get

Parameters

varSelector0 (Optional)
Type: SystemObject
[in, optional] Optional selector for dimension 0 of vector data. Dim0 is the slowest moving dimension. If other selector arguments are missing and the number of dimensions in the selectors shape matches the number of dimensions in the Shape property, then selector values are treated as indices into the values unrolled into a 1-dimensional array.
varSelector1 (Optional)
Type: SystemObject
[in, optional] Optional selector for dimension 1 of vector data.
varSelector2 (Optional)
Type: SystemObject
[in, optional] Optional selector for dimension 2 of vector data.
varSelector3 (Optional)
Type: SystemObject
[in, optional] Optional selector for dimension 3 of vector data.

Property Value

Type: McObject
Remarks
Up to 4 dimensions of optional index selectors may be supplied for vector data. If selectors are supplied, then a "temporary" McObject that exposes selected sub-array is returned as the value. This "SelectedMcObject" is not a copy of the selected values, but is instead a "reference" to those selected values. Thus it's Value property may be assigned to to replace only the selected data values (this is equivalent to assigning to the SelectedValues property). The major use for the SelectedMcObject property is to pass a selected subset of data on to other McOMGlobal routines without having to extract the SelectedValues as a Variant. The returned McObject instance should be released as soon as you are done with it. The rules for the selector arguments are the same as for the SelectedValues property. The dimension selector may be a single, scalar index value or it may be an array of such values; negative indices in a selector are legal, but they are ignored. If the selector for a dimension is missing (VT_EMPTY, VT_ERROR or VT_NULL) then all elements of that dimension will be selected. For N-dimensional shaped McObject's, it is possible to supply selector values as indexes into the shape unwrapped into 1-dimensional array. This is done by supplying only the varSelector0 argument (leaving the other arguments missing) and supplying it as a N-dimensional array (if varSelector0 is supplied as a scalar or 1-D array, then it selects only from Dimension 0). The result of selecting in this way is a 1-dimensional array of the selected elements. This situation is actually a very common one, since the logical vector operators (e.g., McOMGlobal.McOpEq) preserve the shape of the left argument. The samples illustrate this and other selection rules: they are well worth examining if you are selecting from anything but 1-dimensional arrays. The selector arguments are supplied in C/C++ order for multidimensional shaped objects. That is, the left-most argument selects into Dim0, the slowest moving dimension. This is the same ordering as in C/C++, but it is the reverse of dimension ordering in VB. On assignment, if all selector values are missing, then variable dimensions are allowed to change size on the assignment to accomodate the source data, but the number of dimensions is not allowed to change nor is the fixed or variable attribute of each dimension. Assigning to the Value property sets the full shape of the stored data, as does assigning a shape directly to the Shape property. See the Notes with the SelectedValues property for more discussion of selected shape. The SelectedMcObject will be a newly created McObject that will be unnamed and have no ParentMcObject. And it will not be part of the McObjects collection, so it cannot be looked up via the Item property nor will it appear in any enumeration.
Examples
VB
' Get histogram values and give a little report.
Dim lChannel As Long
lChannel = CLng(ChannelTB.Text)
Dim imcobjectHistogram As McObject
Set imcobjectHistogram = GlobalTools.McObjectTemp(ActiveImage.Histogram.Values(-1, lChannel))
Dim imcobjectReducedHistValues As McObject
varDims = imcobjectHistogram.Shape(mcobjSIC_NofDims)
If varDims > 1 Then
Set imcobjectReducedHistValues = GlobalTools.McReduce(imcobjectHistogram, , 0) ' Reduce for color images
Else
Set imcobjectReducedHistValues = imcobjectHistogram
End If
varMaxCount = GlobalTools.McMax(imcobjectReducedHistValues)
Set varHistPeakIndices = GlobalTools.McSqueezeSelector(GlobalTools.McOpEQ(imcobjectReducedHistValues, varMaxCount))
Set varSelGE4thOfMax = GlobalTools.McSqueezeSelector(GlobalTools.McOpGE(imcobjectReducedHistValues, varMaxCount / 4))
Set varPeakValues = imcobjectReducedHistValues.SelectedMcObject(varHistPeakIndices)
Results.Text = "Histogram Peak(s) found at " & GlobalTools.McToText(varHistPeakIndices).Value & _
" with count(s) " + GlobalTools.McToText(varPeakValues).Value + vbCrLf
Results.Text = Results.Text & " Indices with counts 1/4 of Max: " & _
McToText(varSelGE4thOfMax) & vbCrLf
Results.Text = Results.Text & " Counts: " & _
McToText(imcobjectReducedHistValues.SelectedValues(varSelGE4thOfMax))
Examples
VB
'This module is SelectionSamples.bas
'It has VB samples for accessing selected subsets
'of the values in Variants and McObjects

Option Explicit

'***** Variant Examples *******
'The first set of examples uses native VB arrays (which are
'passed as Variants to methods).  Sucessive Sub's get more complex

Public Sub SelectFrom1DVariant()
    Output.Show "Output"
    Output.Clear
    Dim var1D As Variant
    var1D = Array(1, 2, 3, 4, 5)
    Output.PrintMessage "Select Elements 0,4,2 from (1,2,3,4,5) in that order: " & _
        McToText(McOpSelect(var1D, Array(0, 4, 2))) 'show 1 5 3
End Sub 'SelectFrom1DVariant

Public Sub AssignToSelectedValuesOf1DVariant()
    Output.Show "Output"
    Dim array1D(3) As Long 'length-4 array
    Dim varT As Variant
    varT = array1D
    McOpAssignSelected varT, Array(1, 2), Array(0, 2)
    Output.PrintMessage "Assigned-to array. " + McToText(varT) 'show 1 0 2 0
End Sub 'AssignToSelectedValuesOf1DVariant

Public Sub SelectValuesGreaterThan10()
    Output.Show "Output"
    Dim var1D As Variant
    var1D = Array(1, 20, 3, 40, 5, 60)
    Output.PrintMessage "Select values from (1,20,3,40,5,60) greater than ten: " + _
        McToText(McOpSelect(var1D, McOpGT(var1D, 10))) 'show 20 40 60
End Sub 'SelectValuesGreaterThan10

Public Sub SelectFrom2DVariant()
    Output.Show "Output"
    Output.Clear
    Dim var2D As Variant
    var2D = Array(Array(11, 21, 31, 41), Array(12, 22, 32, 42), Array(13, 23, 33, 43))
    Output.PrintMessage "Original 2-D array:" + vbCrlf + McToText(var2D)
    Output.PrintMessage "Select 3rd Row: " & _
        McToText(McOpSelect(var2D, 2)) 'show 13 23 33 43
    Output.PrintMessage "Select 2nd Column: " & _
        McToText(McOpSelect(var2D, Empty, 1)) 'show 21 22 23
    Output.PrintMessage "Select 2nd and 4th Column from 1st Row: " & _
        McToText(McOpSelect(var2D, 0, Array(1, 3))) 'show 21 41
    Output.PrintMessage "Select 2nd and 4th Columns: " & vbCrlf & _
        McToText(McOpSelect(var2D, Empty, Array(1, 3))) 'show 21 41, 22 42, 23 43
    Output.PrintMessage "Select 4th, 2nd and 1st Column from 1st and 3rd Row: " & vbCrlf & _
        McToText(McOpSelect(var2D, Array(0, 2), Array(3, 1, 0))) 'show 41 21 11, 43 23 13
    Output.PrintMessage "Select values Greater than 32: " & vbCrlf & _
        McToText(McOpSelect(var2D, McOpGT(var2D, 32))) 'show 41 42 33 43
    'The McOpGT selector in the above statement is a 2-D array that
    'selects from both rows and columns, the resulting McOpSelect is a 1-D array.
End Sub 'SelectFrom2DVariant

Public Sub AssignToSelectedValuesOf2DVariant()
    Output.Show "Output"
    Output.Clear
    Dim var2D As Variant
    var2D = Array(Array(11, 21, 31, 41), Array(12, 22, 32, 42), Array(13, 23, 33, 43))
    Output.PrintMessage "Original 2-D array:" + vbCrlf + McToText(var2D)
        'Assign 2, 3, 4 to the 1st column
    McOpAssignSelected var2D, Array(2, 3, 4), Empty, 0
    Output.PrintMessage "** 2,3,4 assigned to 1st column: " & vbCrlf & _
        McToText(var2D)  'show 2 21 31 41, 3 22 32 42, 4 23 33 43
        'Zero all odd values in the above
    McOpAssignSelected var2D, 0, McOpNE(McOpAndBits(var2D, 1), 0)
    'The McOpNE selector in the above statement is a 2-D array that
    'selects elements in both rows and columns for assigment.  Note also
    'how the associative assignment used the RightOperand scalar value of zero
    'repeatedly as necessary to assign to all selected (odd) values.
    Output.PrintMessage "** All odd values of above array zero'ed: " & vbCrlf & _
        McToText(var2D)  'show 2 0 0 0, 0 22 32 42, 4 0 0 0
End Sub 'AssignToSelectedValuesOf2DVariant

'***** McObject Examples *******
'The next set of examples uses McObjects to hold arrays of data.
'The first 5 Sub's are versions of the above that use a McObject to
'hold the array data instead of a Variant.
'Sucessive Sub's get more complex

Public Sub SelectFrom1DMcObject()
    Output.Show "Output"
    Output.Clear
    Dim mcobj1D As McObject
    Set mcobj1D = McObjectTemp(Array(1, 2, 3, 4, 5))
    Output.PrintMessage "Select McObject elements 0,4,2 from (1,2,3,4,5) in that order: " & _
        McToText(mcobj1D.SelectedMcObject(Array(0, 4, 2)))  'show 1 5 3
    Output.PrintMessage "This does the same thing (with an extra internal copy): " & _
        McToText(McOpSelect(mcobj1D, Array(0, 4, 2)))  'show 1 5 3
End Sub 'SelectFrom1DMcObject

Public Sub AssignToSelectedValuesOf1DMcObject()
    Output.Show "Output"
    Dim mcobjT As McObject
    Set mcobjT = McArrayTemp("INTEGER", 4) 'length-4 1-D array
    mcobjT.SelectedValues(Array(0, 2)) = Array(1, 2)
    Output.PrintMessage "Assigned-to McObject array. " + McToText(mcobjT) 'show 1 0 2 0
End Sub 'AssignToSelectedValuesOf1DMcObject

Public Sub SelectValuesGreaterThan10FromMcObject()
    Output.Show "Output"
    Dim mcobj1D As McObject
    Set mcobj1D = McObjectTemp(Array(1, 20, 3, 40, 5, 60))
    Output.PrintMessage "Select McObject values from (1,20,3,40,5,60) greater than ten: " + _
        McToText(mcobj1D.SelectedMcObject(McOpGT(mcobj1D, 10)))  'show 20 40 60
    Output.PrintMessage "This does the same thing (with an extra internal copy): " + _
        McToText(mcobj1D.SelectedValues(McOpGT(mcobj1D, 10)))  'show 20 40 60
    Output.PrintMessage "This also does the same thing with an extra copy: " + _
        McToText(McOpSelect(mcobj1D, McOpGT(mcobj1D, 10))) 'show 20 40 60
End Sub 'SelectValuesGreaterThan10FromMcObject

Public Sub SelectFrom2DMcObject()
    Output.Show "Output"
    Output.Clear
    Dim mcobj2D As McObject
    Set mcobj2D = McArrayTemp("INTEGER", Array(3, 4)) '3 rows by 4 columns
    mcobj2D.OpSelfAssign (Array(Array(11, 21, 31, 41), Array(12, 22, 32, 42), Array(13, 23, 33, 43)))
    Output.PrintMessage "Original 2-D array:" + vbCrlf + McToText(mcobj2D)
    Output.PrintMessage "Select McObject 3rd Row: " & _
        McToText(mcobj2D.SelectedMcObject(2))  'show 13 23 33 43
    Output.PrintMessage "Select 2nd Column: " & _
        McToText(mcobj2D.SelectedMcObject(Empty, 1)) 'show 21 22 23
    Output.PrintMessage "Select 2nd and 4th Column from 1st Row: " & _
        McToText(mcobj2D.SelectedMcObject(0, Array(1, 3))) 'show 21 41
    Output.PrintMessage "Select 2nd and 4th Columns: " & vbCrlf & _
        McToText(mcobj2D.SelectedMcObject(Empty, Array(1, 3))) 'show 21 41, 22 42, 23 43
    Output.PrintMessage "Select 4th, 2nd and 1st Column from 1st and 3rd Row: " & vbCrlf & _
        McToText(mcobj2D.SelectedMcObject(Array(0, 2), Array(3, 1, 0))) 'show 41 21 11, 43 23 13
    Output.PrintMessage "Select McObject values Greater than 32: " & vbCrlf & _
        McToText(mcobj2D.SelectedMcObject(McOpGT(mcobj2D, 32))) 'show 41 42 33 43
    'The McOpGT selector in the above statement is a 2-D array that
    'selects from both rows and columns, the resulting SelectedMcObject property is a 1-D array.
    Output.PrintMessage "This does the same thing (with an extra internal copy): " & vbCrlf & _
        McToText(McOpSelect(mcobj2D, McOpGT(mcobj2D, 32)))   'show 41 42 33 43
End Sub 'SelectFrom2DMcObject

Public Sub AssignToSelectedValuesOf2DMcObject()
    Output.Show "Output"
    Output.Clear
    Dim mcobj2D As McObject
    Set mcobj2D = McObjectTemp(Array(Array(11, 21, 31, 41), Array(12, 22, 32, 42), Array(13, 23, 33, 43)))
        'Compare the above to the way mcobj2D was filled in SelectFrom2DMcObject, above.
        'The results are equivalent except that this McObject will have type "SHORT" (16-bit
        'integer), since that is the VB integer type of the Array statements here.  The
        'McArrayTemp then OpSelfAssign gives you more control (e.g., you could fill all
        'rows the same without having to specify them all).
    Output.PrintMessage "Original 2-D array:" + vbCrlf + McToText(mcobj2D)
        'Assign 2, 3, 4 to the 1st column
    mcobj2D.SelectedMcObject(Empty, 0) = Array(2, 3, 4)
    'the following would work too
    'McOpAssignSelected mcobj2D, Array(2, 3, 4), Empty, 0
    Output.PrintMessage "** 2,3,4 assigned to 1st column: " & vbCrlf & _
        McToText(mcobj2D)  'show 2 21 31 41, 3 22 32 42, 4 23 33 43
        'Zero all odd values in the above
    mcobj2D.SelectedMcObject(McOpNE(McOpAndBits(mcobj2D, 1), 0)) = 0
    'The McOpNE selector in the above statement is a 2-D array that
    'selects elements in both rows and columns for assigment.  Note also
    'how the associative assignment used the assigning scalar value of zero
    'repeatedly as necessary to assign to all selected (odd) values.
    Output.PrintMessage "** All odd values zero'ed: " & vbCrlf & _
        McToText(mcobj2D)  'show 2 0 0 0, 0 22 32 42, 4 0 0 0
End Sub 'AssignToSelectedValuesOf2DMcObject
See Also