-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathclij1_clij2_combination.ijm
63 lines (52 loc) · 1.8 KB
/
clij1_clij2_combination.ijm
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
/*
# Combining CLIJ and CLIJ2
Authors: Robert Haase, Daniela Vorkel, April 2020
[Source](https://github.com/clij/clij2-docs/tree/master/src/main/macro/clij1_clij2_combination.ijm)
This macro shows how to combine CLIJ and CLIJ2.
Initially, we define two input images we would like to combine by adding.
*/
// clean up first
run("Close All");
// get test data
run("Blobs (25K)");
run("8-bit");
rename("original");
getDimensions(width, height, channels, slices, frames)
original = getTitle();
newImage("background", "16-bit ramp", width, height, slices);
background = getTitle();
/*
## Initialize GPU and push image data to GPU memory
When combining CLIJ and CLIJ2, it is important to initialize CLIJ2 like in the following example.
CLIJ2 takes care of initializing CLIJ in the background:
*/
run("CLIJ2 Macro Extensions", "cl_device=");
Ext.CLIJ2_clear();
/*
## Pushing images to GPU memory
Afterwards, all methods from CLIJ and CLIJ2 are available, for example to push images to the GPU:
*/
// push images to GPU using CLIJ2
Ext.CLIJ2_push(original);
// push images to GPU using CLIJ
Ext.CLIJ_push(background);
// clean up ImageJ
run("Close All");
/*
... and for creating an output image with 32 bits using CLIJ:
*/
originalWithBackground = "originalWithBackground";
Ext.CLIJ_create2D(originalWithBackground, width, height, 32);
/*
## Combining images managed by CLIJ and CLIJ2
Images, which have been pushed and/or created by CLIJ or CLIJ2, can be combined with any command:
*/
Ext.CLIJ2_addImagesWeighted(original, background, originalWithBackground, 1, 0.01);
// show result using CLIJ2
Ext.CLIJ2_pull(originalWithBackground);
run("Invert LUT");
/*
## Finally, clean up using CLIJ2
As for every workflow, clean up at the end:
*/
Ext.CLIJ2_clear();