BlendNarrowbandImages

Syntax

Application.BlendNarrowBandImages ( numberOfImages, destImage, srcImages, srcWavelengths, srcScales, srcLuminance, doAutoBackground )

Parameters

Integer numberOfImages - the number of source images to be processed.

String destImage - The complete path to the output file.

Variant srcImages() - An array of MaxIm.Document objects to be blended.

Variant srcWavelengths() - An array of Doubles, representing the wavelength in nanometers of the source images. Values for luminance planes must be included, but will be ignored.

Variant srcScales() - An array of Doubles, representing the scale factor of intensity for blending the source images in percent values. Values for Luminance planes must be between 0% and 100%.

Variant srcLuminance() - An array of Booleans which flags an input image as a Luminance plane (True), or a color plane (False). Only one luminance plane may be supplied per image list.

Short doAutoBackground - 1 to perform automatic background subtraction from each source image, 0 to use the images as they are.

Returns

Nothing.

Remarks

All documents supplied in srcImages() must be open in MaxIm DL at the time of executing this command. srcWavelengths(), srcScales(), and srcLuminance() arrays supplied must be in same order as srcImages(), and must all be of size numberOfImages. Performing automatic background subtraction is suggested for best results.

Sample Code

The following sample code is written in JavaScript.

// NB Blending COM Automation sample code v1.0

//   By: Adam Robichaud

//

// INPUT VARIABLES

//

// Destination of image to be saved

var destFile = "D:\\RGB and Narrowband Images\\IC405-NBStack.fit";

// Construct an array of files to be blended.

var srcImgs = new Array(5);

srcImgs[0] = "D:\\RGB and Narrowband Images\\IC405-L.fit";

srcImgs[1] = "D:\\RGB and Narrowband Images\\IC405-R.fit";

srcImgs[2] = "D:\\RGB and Narrowband Images\\IC405-G.fit";

srcImgs[3] = "D:\\RGB and Narrowband Images\\IC405-B.fit";

srcImgs[4] = "D:\\RGB and Narrowband Images\\IC405-Ha.fit";

//

// DEMONSTRATION CODE FOLLOWS

//

// Create a MaxIm DL Application Object

var App = new ActiveXObject("MaxIm.Application");

WScript.Echo( "MaxIm DL Version " + App.Version );

// Open documents for each supplied file

var srcDocs = new Array(5);

for ( i = 0; i < 5; i++ )

{

srcDocs[i] = new ActiveXObject("MaxIm.Document");

srcDocs[i].OpenFile( srcImgs[i] );

console.log( srcDocs[i].DisplayName );

}

WScript.Echo("Making Document SAFEARRAY");

srcDocs = JS2VBArray( srcDocs );

// Create an array of the wavelengths for each image plane to be used

// Order must correspond to the files provided above.

var srcWls = new Array(5);

srcWls[0] = 100.00; // Wavelengths of luminance planes will be ignored

srcWls[1] = 700.00;

srcWls[2] = 510.00;

srcWls[3] = 440.00;

srcWls[4] = 656.28;

WScript.Echo("Making Wavelength SAFEARRAY");

srcWls = JS2VBArray( srcWls );

// Set scale factors of image planes in percent.

// Order must correspond to the files provided above.

var srcScales = new Array(5);

srcScales[0] = 100.; // Scales of luminance planes are bound within 0. and 100.

srcScales[1] = 100.;

srcScales[2] = 100.;

srcScales[3] = 100.;

srcScales[4] = 100.;

WScript.Echo("Making Scale factor SAFEARRAY");

srcScales = JS2VBArray( srcScales );

// Set one (and only ONE) luminance plane

// Order must correspond to the files provided above.

var srcLum = new Array(4);

srcLum[0] = true;

srcLum[1] = false;

srcLum[2] = false;

srcLum[3] = false;

srcLum[4] = false;

WScript.Echo("Making Luminance bool SAFEARRAY");

srcLum = JS2VBArray( srcLum );

// Perform background subtraction on the input planes (best results)

var AutoBkgd = 1;

// Blend the images!

WScript.Echo("Blending documents!");

var destDoc = new ActiveXObject("MaxIm.Document");

App.BlendNarrowBandImages( 5, destDoc, srcDocs, srcWls, srcScales, srcLum, AutoBkgd );

// Save the resulting document

WScript.Echo("Saving document to: " + destFile );

destDoc.SaveFile(destFile, 3, false, 1, false);

// Close open documents

WScript.Echo("Closing all open documents");

App.CloseAll();

WScript.Echo("Done!");

// Book-keeping Array converter:

function JS2VBArray( objJSArray )

{

var dictionary = new ActiveXObject( "Scripting.Dictionary" );

for ( var i = 0; i < objJSArray.length; i++ )

{

dictionary.add( i, objJSArray[ i ] );

}

return dictionary.Items();

}