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;
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.
0
Answers
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:
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.
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