// JavaScript source code


function registerImages() {
    /*
     * Register images and combine channels to produce LRGB and LRGB images - the
     * idea is the user will have an interface that specifies a naming convention
     * for the channels (L, R, G and B or L, RGB) and the script generator
     * program will auto-generate the code specifying file paths
     * (easy to do with C#, for example)
     */




    var imageReg = new StarAlignment;

    imageReg.distortionCorrection = true;
    imageReg.localDistortion = true;
    imageReg.fitPSF = StarAlignment.prototype.FitPSF_Always; // or FitPSF_Never to disable (not recommended)
    imageReg.useTriangles = REPLACE_WITH_USE_TRIANGLES;
    imageReg.referenceImage = "REPLACE_WITH_PATH_TO_REFERENCE_IMAGE";
    imageReg.referenceIsFile = true;
    imageReg.targets = REPLACE_WITH_TARGETS;
    imageReg.generateDrizzleData = false; // is now true by default
    imageReg.useSurfaceSplines = true; // ### must be true to use distortion correction
    imageReg.outputDirectory = "REPLACE_WITH_PATH_TO_OUTPUT_DIRECTORY";
    imageReg.outputExtension = ".fit";




    //imageReg.mode = StarAlignment.prototype.RegisterMatch;
    imageReg.writeKeywords = true;
    imageReg.noGUIMessages = true;

    //imageReg.outputPrefix = "";
    //imageReg.outputPostfix = "_r";
    //imageReg.maskPostfix = "_m";

    imageReg.outputSampleFormat = StarAlignment.prototype.SameAsTarget;
    // Optional, force saving as 16-bit..
    // But PixInsight clobbers the low-end values as it scales the peak values to 65k
    // So if you have really high peak values (e.g., 97k), then the low values are lost.
    // In comparison, RegiStar simply truncates the float values to integer, no scaling.
    //imageReg.outputSampleFormat = StarAlignment.prototype.i16;

    imageReg.overwriteExistingFiles = false;
    imageReg.onError = StarAlignment.prototype.Continue;
    //imageReg.useFileThreads = true;
    //imageReg.fileThreadOverload = 1.20;
    imageReg.executeGlobal();
}

function main()
{
    registerImages();

}

main();



