Python Notes

The following are notes used for the Python tutorial.

Go here for OpenCV installation notes.

The best tutorial I’ve found for using Python with computer vision: http://scipy-lectures.github.com/advanced/image_processing/index.html

Suggestion: use ipython by either running “ipython qtconsole –pylab” in the command line or in Windows running the program Pylab. In order to do this you need Qt installed – it will give you instructions if you don’t have it.

Tutorial Outline

Other resources:

Frequently Asked Questions

Question: What is the best way to experiment with images and test my code?

Answer: iPython has a number of tools (such as auto-complete) that make developing with it much more pleasant. The best way to launch this in a command line is to type “ipython –pylab” or “ipython qtconsole –pylab” This automatically loads the plotting tools (pylab) for you. On windows you can simply use the program “Pylab” in the Enthought program folder.

Question: What if my scipy.misc.imread() gives an error?

Answer: You may not have the Python Imaging Library (PIL) installed. It should automatically be installed on Windows and Linux. To install on a MAc use Macports with the command “sudo port install py27-pil”

Question: What is the best way to read an image?

Answer: Use scipy.misc.imread()

Question: When I display a grayscale image using imshow() it looks weird and multi-colored. How do I fix this?

Answer: By default matplotlib colorizes single-valued data such as a grayscale image. To change the colormap so it looks normal use plt.imshow(im, cmap=plt.cm.Greys_r). Alternatively, you can change the default colormap for this session by typing plt.gray() once in your file.

Comments are closed.