Verified Commit 7337b077 authored by Renato Alves's avatar Renato Alves 🌱
Browse files

Fix missing changes from merge request arecord -f S16_LE -d 10 -r 16000...

Fix missing changes from merge request arecord -f S16_LE -d 10 -r 16000 --device=hw:0,0 testfile.wav
parent c894b564
......@@ -105,11 +105,33 @@ way. The `ndarray` is:
### What Data to Use with NumPy?
NumPy can be useful for working with all kinds of numeric data that fulfill the criteria above
(i.e. homogeneous and multidimensional). One of the most common applications though, is image data.
Images are essentially arrays of numbers that represent the brightness of each pixel. For example, take the simple
image of an arrow below. The underlying data is a numeric array where 0 represents black and 255 is white.
Images are essentially arrays of numbers that represent the brightness of each pixel.
For example, take the simple image of an arrow below.
![](../fig/arrow_image.png)
The underlying data is a numeric array where 0 represents black and 255 is white.
After importing NumPy, we could create this array as follows:
~~~
import numpy as np # this is how numpy is traditionally loaded
# Our arrow as displayed in the figure above
arrow = np.array([[255, 255, 255, 0],
[ 0, 255, 0, 255],
[ 0, 0, 255, 255],
[ 0, 0, 0, 255]])
print(arrow)
~~~
{: .language-python }
~~~
[[255 255 255 0]
[ 0 255 0 255]
[ 0 0 255 255]
[ 0 0 0 255]]
~~~
{: .output }
We will use some small 2D example images from an electron microscope, to explore the power of
the NumPy `ndarray`.
The image can be downloaded [here: `cilliated_cell.png`](../data/cilliated_cell.png)
......@@ -143,16 +165,9 @@ The 'raw' image is an electron microscopy image of cells from the marine worm
Once we have our data in a NumPy array, we want to explore it a bit
e.g. how many dimensions does our array have, and of what size?
This is represented by the `shape` of an array, which denotes the length of the array in each dimension.
e.g. for the toy arrow example above:
~~~
import numpy as np # this is how numpy is traditionally loaded
# Our arrow as displayed in the figure above
arrow = np.array([[255, 255, 255, 0],
[ 0, 255, 0, 255],
[ 0, 0, 255, 255],
[ 0, 0, 0, 255]])
Returning to the toy arrow example above:
~~~
print(arrow.shape)
print(arrow.ndim)
~~~
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment