SMIL  0.8
 All Classes Functions Variables Groups Pages
Python NumPy interface

NumPy is a package for scientific computing with Python.

Smil allows to create a NumPy array containing the image pixels with the method Image::getNumArray. This is not a copy of the data but a real access to the image pixels via NumPy.

Note
This function is wrapped only in python.

Here is an example of python script:

1 from smilPython import *
2 import numpy as np
3 
4 # Create an image
5 im1 = Image(256, 512, 2)
6 im1.show()
7 
8 # Create a numpy array containing the real image pixels
9 imArr = im1.getNumArray()
10 
11 # Display the dimensions of the created array
12 print("Array dims:", imArr.shape)
13 
14 # Do something with the array...
15 imArr[:] = 0
16 radius, cx, cy = 64, 127, 164
17 y, x = np.ogrid[-radius: radius, 0 : radius]
18 index = x**2 + y**2 <= radius**2
19 imArr[cx-radius:cx+radius, cy-radius:cy+radius, 0][index] = 255
20 
21 # Call the "modified" method in order to update the viewer content
22 im1.modified()
23