Make color composite image

Hello, 
I'm trying to follow the code snippet example in the help files for creating a color composite image. I keep getting this error when I execute the docomposite method; "Object does not expose the required interface"

This is the code I am using;
 'create an instance of the color composite Operator
Dim ColorComposite As Operations.McColorComposite
ColorComposite = ThisApplication.CreateOperator("McColorComposite") 'no parent

Dim mcimageComposite As McImage
    Set mcimageComposite = ColorComposite.DoComposite( _
        varSourceImages, _
        larraySourceColors, _
        ControlFlags, _
        larraySourceStartingFrames, _
        varSourceLookupTables, _
        ptSourceOffsetsXY, _
        dptMagnificationsXY, _
        -1, _
        larraySourceStartingFrames, _
        0, _
        ptDestOffsetXY, _
        Empty, _
        Empty)
thanks for your help.

Answers

  • It looks like you are trying to adapt the example from the Scripting Workbench Automation help "MediaCy.IQL Namespace" -> "MediaCy.IQL.Operations" (NOT Operators) -> "McColorComposite Interface".  That example was written for VB6, so you will have something of a challenge converting it to the VB.NET model used by the scripting workbench.

    I don't want to discourage you from exploring the innards of the IQL imaging engine, but the McColorComposite operator is about 3 levels down from where you need to be if you just want to create a macro to combine images into a color composite and save that as a new image.  All you need to do is turn on macro recording (Automate ribbon tab), open the monochrome images you want to composite, open a composite window (Adjust tab, Composite button), use the Add button in the panel to the right of the window to add all images, press the Apply button and stop macro recording.  The result will look something like the below:

        Public Function ColorCompositeExample() As SimpleScript
            ColorCompositeExample = New SimpleScript
            Dim docList1 = New List(1), doc1
            Dim docList2 = New List(1), doc2
            Dim docList3 = New List(1), doc3, doc4, image1, doc5

            With Application.RibbonCommands.SelectRibbonTab(ColorCompositeExample)
                .TabName = "Adjust"
                .Run()
            End With

            With Application.DocumentCommands.Open(ColorCompositeExample)
                .Filenames = New String() {ThisApplication.Path(mcPathType.mcptSampleImages) & "Color\Red_TRITC_10.tif"}
                .Run(docList1)
            End With

            With Application.DocumentCommands.Activate(ColorCompositeExample)
                .Run(docList1(0), doc1)
            End With

            With Application.DocumentCommands.Open(ColorCompositeExample)
                .Filenames = New String() {ThisApplication.Path(mcPathType.mcptSampleImages) & "Color\Green_FITC_10.tif"}
                .Run(docList2)
            End With

            With Application.DocumentCommands.Activate(ColorCompositeExample)
                .Run(docList2(0), doc2)
            End With

            With Application.DocumentCommands.Open(ColorCompositeExample)
                .Filenames = New String() {ThisApplication.Path(mcPathType.mcptSampleImages) & "Color\Blue_DAPI_10.tif"}
                .Run(docList3)
            End With

            With Application.DocumentCommands.Activate(ColorCompositeExample)
                .Run(docList3(0), doc3)
            End With

            With Adjust.ColorCompositeCommands.[New](ColorCompositeExample)
                .Run(doc4)
            End With

            With Application.DocumentCommands.Activate(ColorCompositeExample)
                .Run(doc4, doc4)
            End With

            With Adjust.ColorCompositeCommands.AddAll(ColorCompositeExample)
                .Run(doc4)
            End With

            With Adjust.ColorCompositeCommands.Apply(ColorCompositeExample)
                .Visible = True
                .Cleanup = True
                .Result = ColorComposite.ApplyResults.Image
                .Dimension = ColorComposite.SequenceDimensions.Auto
                .Run(doc4, image1)
            End With

            With Application.DocumentCommands.Activate(ColorCompositeExample)
                .Run(image1, doc5)
            End With

        End Function

    If your purpose was not just to automate creation of composite images (which the above macro will do), but rather to explore IQL operators, then you picked a quite tricky one in McColorComposite.   The snippet of macro code in you post is missing all of the code to set up the arguments for the call to DoComposite.  You would need to convert the entire example to VB.NET in order to run it in the Scripting Workbench.


  • Hi, Thank you for the response. 
    Many of the help examples (perhaps all?) are written for VB6. You are correct, it is tricky to convert them for use in the workbench. 
    As you guessed, my goal was to create a composite image. The macro recorder works well but generates code that seems inefficient and difficult to decipher. 
    I was able to create this code which simplifies the recorded macro a bit and works well for my purpose. it's not pretty, but it does work. 
    Public Function createColorComposite(ByRef frac As McImage, ByRef flaw As mcimage, ByRef bright As McImage, ByRef remaining As McImage, ByRef compositeMask As McImage)
    
    Dim docComp
    
        With Adjust.ColorCompositeCommands.[New](Nothing)
                .Run(docComp)
            End With
    
        With Adjust.ImageCommands.Tint(Nothing)
                .Color=System.Drawing.Color.Red 'fract
                .ApplyProperties = True
                .Run(frac)
            End With
        With Adjust.ImageCommands.Tint(Nothing)
                .Color=System.Drawing.Color.White   'flaw
                .ApplyProperties = True
                .Run(flaw)
            End With
    
        With Adjust.ImageCommands.Tint(Nothing)
                .Color=System.Drawing.Color.GreenYellow   'bright
                .ApplyProperties = True
                .Run(bright)
            End With
        With Adjust.ImageCommands.Tint(Nothing)
                .Color=System.Drawing.Color.White   'remainder
                .ApplyProperties = True
                .Run(remaining)
            End With
    
    
        With Adjust.ColorCompositeCommands.Add(Nothing)
                .Run(docComp, frac)
            End With
        With Adjust.ColorCompositeCommands.Add(Nothing)
                .Run(docComp, flaw)
            End With
        With Adjust.ColorCompositeCommands.Add(Nothing)
                .Run(docComp, bright)
            End With
        With Adjust.ColorCompositeCommands.Add(Nothing)
                .Run(docComp, remaining)
            End With
    
    
        With Adjust.ColorCompositeCommands.Apply(Nothing)
                .Visible = True
                .Cleanup = True
                .Run(docComp, compositeMask)
            End With
    
    
    compositeMask.Name= "ColorComposite"
    
    End Function
Sign In or Register to comment.