Skip to content
Snippets Groups Projects

add intro numpy example

Merged Kimberly Isobel Meechan requested to merge numpy-ex-1 into master
All threads resolved!
+ 14
13
@@ -35,19 +35,20 @@ keypoints:
- include an aside about I/O - reading/writing files (pandas (the `.to_*()` methods and highlight some: `csv`, `json`, `feather`, `hdf`), numpy, `open()`, (?) bytes vs strings, (?) encoding)
- Finish with example of `df.plot()` to set the scene for plotting section
> ## Reading data to a numpy array
> We'll use the popular image analysis package scikit-image, to read two example images into numpy
> arrays.
> > ~~~
> > from skimage.io import imread
> > raw = imread('cilliated_cell.png')
> > nuclei = imread('cilliated_cell_nuclei.png')
> > # if you want to see what these images look like - we can use matplotlib (more to come later!)
> > import matplotlib.pyplot as plt
> > plt.imshow(raw, cmap='gray')
> > plt.imshow(nuclei)
> > ~~~
> > {: .language-python }
## Reading data to a numpy array
We'll use the popular image analysis package scikit-image, to read two example images into numpy
arrays.
~~~
from skimage.io import imread
raw = imread('cilliated_cell.png')
nuclei = imread('cilliated_cell_nuclei.png')
# if you want to see what these images look like - we can use matplotlib (more to come later!)
import matplotlib.pyplot as plt
plt.imshow(raw, cmap='gray')
plt.imshow(nuclei)
~~~
{: .language-python }
> ## Exploring Image Arrays
> * What are the dimensions of these arrays?
> * What data type are these arrays?
> * What is the minimum and maximum value of these arrays?
Loading