" + TITLE + " Version " + VERSION + " — " + "This script reduces the residual magenta chromatism affecting stars that can be present " + "after combining Hydrogen-Alpha, Sulphur-II and Oxygen-III channels using the Hubble Palette. " + "
Copyright © 2012-2015 Roberto Sartori, Edoardo Luca Radice. All Rights Reserved.
"; this.targetView = new HorizontalSizer; this.viewList = new ViewList(this); this.viewListNullCurrentView = this.viewList.currentView; this.viewList.getAll(); if (parameters.targetView !== null && parameters.targetView.isView) { this.viewList.currentView = parameters.targetView; } else { parameters.targetView = this.viewList.currentView; } this.viewList.onViewSelected = function (view) { parameters.targetView = view; } this.targetView.add(this.viewList); this.parameterPane = new VerticalSizer; this.parameterPane.margin = 6; this.parameterPane.spacing = 4; this.scnrAmountControl = new NumericControl(this); this.scnrAmountControl.label.text = "Amount:"; this.scnrAmountControl.label.minWidth = labelMinWidth; this.scnrAmountControl.slider.setRange(0, sliderMaxValue); this.scnrAmountControl.slider.minWidth = sliderMinWidth; this.scnrAmountControl.setRange(0.0, 1.0); this.scnrAmountControl.setPrecision(2); this.scnrAmountControl.setValue(parameters.scnrAmount); this.scnrAmountControl.onValueUpdated = function (value) { parameters.scnrAmount = value; } this.scnrAmountControl.toolTip = "SCNR amount applied to the inverted image.
"; this.parameterPane.add(this.scnrAmountControl); this.buttonPane = new HorizontalSizer; this.buttonPane.spacing = 6; this.buttonPane.addStretch(); this.buttonPane.add(pushButtonWithTextOnClick(this, "Execute", function () { parameters.exit = false; this.dialog.ok(); })); this.buttonPane.add(pushButtonWithTextOnClick(this, "Close", function () { parameters.exit = true; this.dialog.ok(); })); this.sizer = new VerticalSizer; this.sizer.margin = 6; this.sizer.spacing = 6; this.sizer.add(this.titlePane); this.sizer.add(this.targetView); this.sizer.add(this.parameterPane); this.sizer.add(this.buttonPane); this.adjustToContents(); this.setFixedSize(); } parametersDialogPrototype.prototype = new Dialog; // The script's process prototype. function processPrototype() { this.writeParameters = function (parameters) { console.writeln("Target view: ", parameters.targetView.fullId); console.writeln("Amount: ", format("%d", parameters.scnrAmount)); } this.createImageWindowOfView = function (view) { var imageWindow = createImageWindow( view.image.width, view.image.height, uniqueViewId(mainViewIdOfView(view)), view.image ); return imageWindow; } this.executeMagentaCorrection = function (targetView) { var PInvert = new Invert; var PSCNR = new SCNR; PSCNR.amount = parameters.scnrAmount; PSCNR.protectionMethod = SCNR.prototype.AverageNeutral; PSCNR.colorToRemove = SCNR.prototype.Green; PSCNR.preserveLightness = true; var P = new ProcessContainer; P.add(PInvert); P.add(PSCNR); P.add(PInvert); P.executeOn(targetView, true); } this.execute = function () { this.executeMagentaCorrection(parameters.targetView); } } var process = new processPrototype(); function colorspaceIsValid(image) { // An active window must exist if (image.isGrayscale) { (new MessageBox( "Error: Target view color space cannot be Grayscale.
", TITLE, StdIcon_Warning, StdButton_Ok )).execute(); return false; } return true; } function performChecksAndExecute() { if (!parameters.targetView || !parameters.targetView.image || !colorspaceIsValid(parameters.targetView.image)) { return; } process.execute(); } function executeInGlobalContext() { parameters.targetView = ImageWindow.activeWindow.currentView; parameters.getParameters(); performChecksAndExecute(); } function main() { console.hide(); if (Parameters.isGlobalTarget) { // Script has been launched in global context, execute and exit executeInGlobalContext(); return; } // Prepare the dialog var parametersDialog = new parametersDialogPrototype(); parameters.exit = false; // Runloop while (!parameters.exit) { if (Parameters.isViewTarget && !parameters.targetView) { // A target is already defined, init it as the target view parameters.targetView = this.targetView; parameters.getParameters(); } else { // Dialog needs to be opened in order to select the image and set parameters // Use the current active view as target by default parameters.targetView = ImageWindow.activeWindow.currentView; } // Run the dalog var parametersDialog = new parametersDialogPrototype(); if (!parametersDialog.execute()) { // Dialog closure forced return; } // do the job if (!parameters.exit) { performChecksAndExecute(); } // Workaround to avoid image window close crash in 1.8 RC7. parametersDialog.viewList.currentView = parametersDialog.viewListNullCurrentView; } } main(); // **************************************************************************** // EOF CorrectMagentaStars.js