-
Notifications
You must be signed in to change notification settings - Fork 44
/
test_crop.py
48 lines (37 loc) · 1.12 KB
/
test_crop.py
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
import pyclesperanto_prototype as cle
import numpy as np
def test_crop():
test1 = cle.push(np.asarray([
[0, 0, 0, 1],
[0, 0, 3, 1],
[0, 0, 3, 1],
[1, 1, 1, 1]
]))
reference = cle.push(np.asarray([
[0, 0, 0],
[0, 0, 3],
[0, 0, 3]
]))
result = cle.create(reference)
cle.crop(test1, result, 0, 0)
a = cle.pull(result)
b = cle.pull(reference)
print(a)
assert (np.array_equal(a, b))
def test_crop_2d():
input_image = cle.create([100, 100])
print(input_image.shape)
output_image = cle.crop(input_image, width=10, height=10)
print(output_image.shape)
assert(len(output_image.shape) == 2)
assert(output_image.shape[0] == 10)
assert(output_image.shape[1] == 10)
def test_crop_3d():
input_image = cle.create([100, 100, 100])
print(input_image.shape)
output_image = cle.crop(input_image, width=10, height=10, depth=10)
print(output_image.shape)
assert(len(output_image.shape) == 3)
assert(output_image.shape[0] == 10)
assert(output_image.shape[1] == 10)
assert(output_image.shape[2] == 10)