Basic method which shows how to create a checkerboard of given size in memory.
Basic method which shows how to create a checkerboard of given size in memory. Pixels are written one by one.
1import iolink
2
3from array import array
4
5import timeit
6
7
11 shape = iolink.VectorXu64(sideLength, sideLength)
12 dt = iolink.DataTypeId.UINT8
13
14
15 image = iolink.ImageViewFactory.allocate(shape, dt)
16
17 tileCount = 10
18
19 blackValue = 0
20 whiteValue = 255
21
22
23 tileSizeInPixel = shape[0] // tileCount
24
25
26 for i in range(0, shape[0]):
27 for j in range(0, shape[1]):
28
29
30
31 tileIndexX = i // tileSizeInPixel
32 tileIndexY = j // tileSizeInPixel
33
34
35
36 if ( (tileIndexX + tileIndexY) % 2 == 0):
37 image.write([i, j], blackValue)
38 else:
39 image.write([i, j], whiteValue)
40
41 return image
42
43start = timeit.default_timer()
45stop = timeit.default_timer()
46print('CheckerBoard created in: ', stop - start, "s")
47
48print("Generated ImageView:", str(img))
49
50
52
53
54
55
56
59
60
61
62
63print("SUCCESS")
Definition checkerBoard.py:1