-
Book Overview & Buying
-
Table Of Contents
NumPy Cookbook
By :
In this recipe, we will load a sample image of Lena, which is available in the SciPy distribution, into an array. This chapter is not about image manipulation, by the way; we will just use the image data as an input.
Lena Soderberg appeared in a 1972 Playboy magazine. For historical reasons, one of those images is often used in the field of image processing. Don't worry; the picture in question is completely safe for work.
We will resize the image using the repeat function. This function repeats an array, which in practice means resizing the image by a certain factor.
A prerequisite for this recipe is to have SciPy, Matplotlib, and PIL installed. Have a look at the corresponding recipes in this chapter and the previous chapter.
Load the Lena image into an array.
SciPy has a lena function, which can load the image into a NumPy array:
lena = scipy.misc.lena()
Some refactoring has occurred since version 0.10, so if you are using an older version, the...
Change the font size
Change margin width
Change background colour