Day 2: images as arrays and plotting

2 / 27 / 2015

Prior

These two tutorial pages are from the scipy lecture notes:

Day

Installing scikit-image

You might want to install scikit-image – the image processing toolkit for Python. You will need it for the last (and optional) part of the last exercise today.

  • If you have Anaconda, the package is already installed;

  • If you have Python(X,Y) on Windows, download and run http://nipy.bic.berkeley.edu/pna/archives/scikits.image-0.10.1-7_py27.exe;

  • If you have OSX, and do not have Anaconda (for example, if you followed the instructions for OSX install for this class) then:

    pip install -U scikit-image
    
  • If you have Linux, first – ask your friendly instructor, because Linux systems differ more from each other than OSX and Windows. If we aren’t around for some reason, then:

    • If you are on Ubuntu or Debian 64-bit, try:

      sudo pip install --no-index -f http://travis-wheels.scikit-image.org scikit-image
      
    • Otherwise, or if that doesn’t work:

      sudo pip install -U six
      sudo pip install -U scikit-image
      

    As usual, if you have any problems, we are very happy to help.

Introduction to day 2

To get started

cd pna2015
git pull
cd day2
ipython notebook

Some new Python stuff

  • Tuples are immutable lists;
  • Mutable and immutable in Python;
  • Making a tuple with a single element;
  • List comprehensions are short-cut for loops.

Revision from homework

  • Numpy is a package (and a module);
  • Getting help with dot <tab> in IPython and np.lookfor;
  • Matplotlib is a package (and a module);
  • Showing an array as an image with imshow;
  • Plotting a line from an array with plot;
  • Slicing arrays;
  • Indexing arrays with masks;
  • Numerical operations in numpy;
  • + - * / == != > < >= <= are always elementwise;
  • Transpose
  • Reshape