-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathcrop.py
More file actions
36 lines (27 loc) · 726 Bytes
/
crop.py
File metadata and controls
36 lines (27 loc) · 726 Bytes
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
# crop.py
# =======
#
# Crop out a part of an image on the GPU
#
# Author: Robert Haase, [email protected]
# October 2019
#########################################
from ij import IJ;
from net.haesleinhuepf.clij2 import CLIJ2;
IJ.run("Close All");
# load example image
imp = IJ.openImage("http://wsr.imagej.net/images/blobs.gif");
# imp = IJ.openImage("c:/structure/data/blobs.tif");
imp.show();
# init GPU
clij2 = CLIJ2.getInstance();
# push image to GPU
input = clij2.push(imp);
# reserve memory for output, with a given size and type as input
output = clij2.create([75, 75], input.getNativeType());
# crop
clij2.crop(input, output, 10, 10);
# show result
clij2.pull(output).show();
# clean up
clij2.clear();