Home Image-Pro Automation (Macros, Apps, Reports)

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:

    &nbsp;&nbsp;&nbsp; Public Function ColorCompositeExample() As SimpleScript<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ColorCompositeExample = New SimpleScript<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Dim docList1 = New List(1), doc1<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Dim docList2 = New List(1), doc2<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Dim docList3 = New List(1), doc3, doc4, image1, doc5<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; With Application.RibbonCommands.SelectRibbonTab(ColorCompositeExample)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .TabName = "Adjust"<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Run()<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End With<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; With Application.DocumentCommands.Open(ColorCompositeExample)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Filenames = New String() {ThisApplication.Path(mcPathType.mcptSampleImages) & "Color\Red_TRITC_10.tif"}<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Run(docList1)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End With<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; With Application.DocumentCommands.Activate(ColorCompositeExample)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Run(docList1(0), doc1)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End With<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; With Application.DocumentCommands.Open(ColorCompositeExample)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Filenames = New String() {ThisApplication.Path(mcPathType.mcptSampleImages) & "Color\Green_FITC_10.tif"}<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Run(docList2)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End With<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; With Application.DocumentCommands.Activate(ColorCompositeExample)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Run(docList2(0), doc2)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End With<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; With Application.DocumentCommands.Open(ColorCompositeExample)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Filenames = New String() {ThisApplication.Path(mcPathType.mcptSampleImages) & "Color\Blue_DAPI_10.tif"}<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Run(docList3)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End With<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; With Application.DocumentCommands.Activate(ColorCompositeExample)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Run(docList3(0), doc3)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End With<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; With Adjust.ColorCompositeCommands.[New](ColorCompositeExample)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Run(doc4)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End With<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; With Application.DocumentCommands.Activate(ColorCompositeExample)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Run(doc4, doc4)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End With<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; With Adjust.ColorCompositeCommands.AddAll(ColorCompositeExample)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Run(doc4)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End With<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; With Adjust.ColorCompositeCommands.Apply(ColorCompositeExample)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Visible = True<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Cleanup = True<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Result = ColorComposite.ApplyResults.Image<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Dimension = ColorComposite.SequenceDimensions.Auto<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Run(doc4, image1)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End With<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; With Application.DocumentCommands.Activate(ColorCompositeExample)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Run(image1, doc5)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End With<br><br>&nbsp;&nbsp;&nbsp; End Function<br>

    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.