18.1. Using Repetition with Images

Learning Objectives:

Images (pictures) on a computer are broken up into little bits called pixels, for picture (pix) elements (els). These are laid out on a grid, from left to right (horizontal or x dimension) and top to bottom (vertical or y dimension).

A grid with horizontal (x) and vertical (y) dimensions

Figure: A grid with horizontal (x) and vertical (y) dimensions

Pixels are quite small. Even the small image below has 180 columns and 240 rows of pixels. Each pixel has a color associated with it: an amount of redness, an amount of greenness, and an amount of blueness. Let’s remove the red from this picture. Now, there are lot of lines in the program below, but fortunately, you can ignore most of them. The Audio Tour explains the important lines. Press audio tour button to hear the audio tour explanation. When you run this program it may take several minutes to show the changed image.

A picture of an arch

Figure: A picture of an arch

The program above can take several minutes to execute on the arch.jpg picture. But we’re not stuck using just the arch image. You can change the file name in the program above to the URL for any small photo that is on the internet.

Before you keep reading...

Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.

You have attempted 1 of 5 activities on this page