-
Book Overview & Buying
-
Table Of Contents
Learning SciPy for Numerical and Scientific Computing Second Edition - Second Edition
We have been introduced to NumPy's main object—the homogeneous multidimensional array, also referred to as ndarray. All elements of the array are casted to the same datatype (homogeneous). We obtain the datatype by the dtype attribute, its dimension by the shape attribute, the total number of elements in the array by the size attribute, and elements by referring to their positions:
>>> img.dtype, img.shape, img.size
The output is shown as follows:
(dtype('int64'), (512, 512), 262144)
Let's compute the grayscale values now:
>>> img[32,67]
The output is shown as follows:
87
Let's interpret the outputs. The elements of img are 64-bit integer values ('int64'). This may vary depending on the system, the Python installation, and the computer specifications. The shape of the array (note it comes as a Python tuple) is 512 x 512, and the number of elements 262144. The grayscale value of the image in the 33rd column and 68...
Change the font size
Change margin width
Change background colour