-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChannel_Viewer.dctl
52 lines (47 loc) · 1.56 KB
/
Channel_Viewer.dctl
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
//Display individual channels as monochrome
//Display combined channels in color
DEFINE_UI_PARAMS(p_DisplayR, Red, DCTLUI_CHECK_BOX, 0)
DEFINE_UI_PARAMS(p_DisplayG, Green, DCTLUI_CHECK_BOX, 0)
DEFINE_UI_PARAMS(p_DisplayB, Blue, DCTLUI_CHECK_BOX, 0)
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p_R, float p_G, float p_B) {
float3 out = make_float3(0); // Initialize output to black
// Count the number of selected channels
int numSelectedChannels = p_DisplayR + p_DisplayG + p_DisplayB;
// Display individual channels as monochrome
if (numSelectedChannels == 1) {
if (p_DisplayR == 1) {
out.x = p_R; // Red channel
out.y = p_R;
out.z = p_R;
}
if (p_DisplayG == 1) {
out.x = p_G;
out.y = p_G; // Green channel
out.z = p_G;
}
if (p_DisplayB == 1) {
out.x = p_B;
out.y = p_B;
out.z = p_B; // Blue channel
}
} else if (numSelectedChannels == 3 || numSelectedChannels == 0) { // Display in full color if all or none selected
out = make_float3(p_R, p_G, p_B);
} else { // Combine selected channels, setting the third one to 0.0
if (p_DisplayR == 0) {
out.x = 0;
} else {
out.x = p_R;
}
if (p_DisplayG == 0) {
out.y = 0;
} else {
out.y = p_G;
}
if (p_DisplayB == 0) {
out.z = 0;
} else {
out.z = p_B;
}
}
return out;
}