0% found this document useful (0 votes)
29 views3 pages

Hands-On Activity: 3. Exploring The Array Data Model of An Image

This document provides instructions for exploring the array data model of an image using Python. It has the following key steps: 1. Display an image of Australia using the eog image viewer. 2. View the dimensions of the image using a dimensions script - this image is 5250 columns by 4320 rows with 3 8-bit pixels for red, green, and blue at each location. 3. View pixel values at different locations using a pixel script - for example, locations near the edges have high blue and low red/green values as expected for ocean.

Uploaded by

HGE05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Hands-On Activity: 3. Exploring The Array Data Model of An Image

This document provides instructions for exploring the array data model of an image using Python. It has the following key steps: 1. Display an image of Australia using the eog image viewer. 2. View the dimensions of the image using a dimensions script - this image is 5250 columns by 4320 rows with 3 8-bit pixels for red, green, and blue at each location. 3. View pixel values at different locations using a pixel script - for example, locations near the edges have high blue and low red/green values as expected for ocean.

Uploaded by

HGE05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Hands-on Activity: 3.

Exploring the Array Data Model


of an Image

Learning Goals:

By the end of this activity, you will be able to:

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.

Change into the image directory:

Run cd Downloads/lect4data/image

Run ls to see the image and scripts:

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.

To view the pixel value at another corner of the image, run:


./pixel.py Australia.jpg 5000 0
This is the same result since location 5000 0 is also ocean.

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.

You might also like