Hands-On Activity: 3. Exploring The Array Data Model of An Image
Hands-On Activity: 3. Exploring The Array Data Model of An Image
Learning Goals:
1. Display an image.
2. View the dimensions and pixel values in an image.
Instructions:
Step 0. Preparing installations and updates. Install Python 3.5.2, Pillow. Pillow, the friendly PIL
(Python Imaging Library) fork, is a library for image manipulation. Details can be found in the
document “HandsOn 3a. Installing Python” of this lecture.
Step 1. Open a terminal shell. Open a terminal shell by clicking on the square black box on the top
left of the screen.
Run cd Downloads/lect4data/image
Step 2. Display the image. Display the image by running eog Australia.jpg . eog stands for Eye of
Gnome and is a common image viewer on Linux systems.
eog Australia.jpg
Next, click on the terminal window, and enter control-z and bg to run eog in the background.
Step 3. View the dimensions. We can view the dimensions of the image by running:
./dimensions.py Australia.jpg
This says that the image has 5250 columns and 4320 rows, and each cell is comprised of three 8bit
pixels for Red, Green, and Blue.
Step 4. View pixel values. We can view pixel values at different locations in the image by running the
pixel.py script. To view the pixel value at location 0, 0, run:
./pixel.py Australia.jpg 0 0
This says the values for Red = 11, Green = 10, and Blue = 50. The corners of the image are ocean, so
we expect a high value for Blue, and low values for Red and Green.
Now let's look at a pixel value of land near the middle of the image:
./pixel.py Australia.jpg 2000 2000
This says the values for Red = 118, Green = 89, and Blue = 57. The land is orange and yellow, so we
expect higher values for Red and Green than Blue.