CS 106A Lecture Notes - Lecture 18: Executable

30 views2 pages

Document Summary

2-d arrays (cont. : shrinking an image to half its original dimensions. When we brighten an image, we create a new array based on the original one, change the colors, and then set that array as the one to use. For this array, however, we need half as many pixels in order to shrink the image. We can loop over the result array (which is half the size of the original array) for convenience. We should shrink every 2px x 2px block to a 1x1 block. In order to do that, for every 4 pixels in the original picture, replace it with 1 pixel result[r][c] = pixels[r * 2][c * 2]; (shrink by half: enlarging an image to twice its original dimensions. Set the result array to be twice as many pixels as the original array result[r][c] = pixels[r / 2][c / 2]; (shrink by half) Classes and objects (difficult conceptual topic: class examples.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents