Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning SciPy for Numerical and Scientific Computing Second Edition

You're reading from  Learning SciPy for Numerical and Scientific Computing Second Edition

Product type Book
Published in Feb 2015
Publisher Packt
ISBN-13 9781783987702
Pages 188 pages
Edition 1st Edition
Languages

Object essentials


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 68th row is 87 (note that in NumPy, as in Python...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}