-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreateLumMask.js
81 lines (62 loc) · 2.09 KB
/
createLumMask.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
createLumMask.js: Create luminance mask
================================================================================
This script will extract luminance and stretch it for a mask.
================================================================================
*
*
* Copyright Jeremy Likness, 2021
*
* License: https://github.com/DeepSkyWorkflows/DeepSkyWorkflowScripts/LICENSE
*
* Source: https://github.com/DeepSkyWorkflows/DeepSkyWorkflowScripts
*
* mailTo:deepskyworkflows@gmail.com
*/
#feature-id CreateLumMask : DeepSkyWorkflows > CreateLumMask
#define TITLE "Luminance Mask"
#define FEATURE "createLumMask"
#define DEBUG_CLM false
#include "deepSkyCommon.js"
(function (ds) {
ds.debug.register(FEATURE, DEBUG_CLM);
ds.debug[FEATURE].debugLn(TITLE, 'debugging is on.');
ds.features.register(FEATURE, TITLE, {
genMask: function() {
const executionState = ds.getExecutionState();
if (!!!executionState.view.id) {
ds.utilities.writeLines("No activew view. Aborting script.");
return;
}
ds.utilities.writeLines('Generating mask...');
ds.engine.extractLuminance('_LMask');
var mask = ImageWindow.windowById(executionState.channels[0][1]).mainView;
ds.engine.applySTF(mask);
ds.engine.applyHistogramTransformation(mask);
ds.utilities.writeLines(ds.utilities.concatenateStr('Generated mask: ', executionState.channels[0][1]));
}
});
ds.debug[FEATURE].debugLn(
'Registered feature: ',
JSON.stringify(ds.features[FEATURE]));
let bootstrap = ds.engine.bootstrap([
{
setting: "lumMask",
dataType: DataType_Boolean,
defaultValue: true,
persist: false
}
],
ds.features[FEATURE].engine.genMask,
function () {
ds.debug[FEATURE].debugLn('New dialog requested, but script has no UI.');
return {
execute: function () {
ds.features[FEATURE].engine.genMask();
}
};
},
FEATURE,
true);
bootstrap();
})(deepSky);