SMIL
1.0.3
numpy_array.py
1
2
import
smilPython
as
sp
3
import
numpy
as
np
4
5
# Create an image
6
sx = 256
7
sy = 384
8
im1 = sp.Image(sx, sy)
9
im1.show()
10
11
# Create a numpy array containing the real image pixels
12
imArr = im1.getNumArray()
13
14
# Display the dimensions of the created array
15
print(
"Array dims:"
, imArr.shape)
16
17
# Do something with the array... E.g., draw a circle
18
imArr[:] = 0
19
# the circle will be centered at the center of the image
20
radius, cx, cy = 64, sy//2, sx//2
21
y, x = np.ogrid[0:sx, 0:sy]
22
# get the indexes of the pixels inside the circle
23
index = (x - cx)**2 + (y - cy)**2 <= radius**2
24
imArr[:,:][index] = 255
25
26
# Call the "modified" method in order to update the viewer content
27
im1.modified()
28
29
input()
30
Generated on Mon Jan 15 2024 15:19:26 for SMIL by
1.9.1