Exploratory Programming for the Arts and Humanities (MIT Press) by Nick Montfort

Exploratory Programming for the Arts and Humanities (MIT Press) by Nick Montfort

Author:Nick Montfort [Montfort, Nick]
Language: eng
Format: mobi, epub, pdf
ISBN: 9780262034203
Publisher: The MIT Press
Published: 2016-04-08T04:00:00+00:00


8.3  Pixel-by-Pixel Image Manipulation

For simplicity’s sake, even though we created one nice rose-colored rectangle, we’ll begin this section by discussing grayscale images, images where the all the color values have the same amount of red, blue, and green. We’ll use images of the same standard format, PNG. Leaving color for later is not an unusual way to proceed. In programming, it’s often good to start with simpler versions of a problem. In visual art and design, intensity (dark and light) is often dealt with before color.

With the exception of allrose.png, the images we created in the previous section—allwhite.png, allgray.png, allblack.png, almostall.png, and oneline.png—are all grayscale PNGs. For image manipulation purposes, obtain a different grayscale PNG image from the Web. Look for something with some detail and with different level of grays, and for an image that isn’t horizontally or vertically symmetric. A photograph or a scanned charcoal drawing will work; line drawings or images that consist of words (type) are not best. Entirely black rectangles will be a particularly bad choice. If you can’t find a suitable image, just create one quickly in a drawing program.

In a PNG image, the intensity of each pixel varies between 0 (no light, a completely black pixel) and 255 (the maximum amount of light, a white pixel). It might be easier to think about if the range went from 0 to 100 and we could simply specify a percentage of light, but the 256 possible values of intensity correspond to the values that can be stored in a single byte, which has eight binary digits (or bits). These bits can each be 1 or 0, on or off, and since there are eight of them in order there are 28 = 256 possibilities. If we start counting from 0, our first value, 255 is our 256th value, the maximum number.

It isn’t essential to know about the architecture of computers to understand how to program them effectively; one of the types of abstraction that developers of programming languages have striven to implement is the ability to think about computation and problem-solving independent of hardware. It can be good to know that when “255” and similar values crop up, however, they are not being placed capriciously or maliciously by the creators of different systems. They actually relate to underlying aspects of computer systems.

Some programming environments do allow for percentages or similar values to be specified instead of numbers in the range from 0 to 255, and this can be a help to new programmers. John Maeda’s design by numbers (DBN), a predecessor of Processing, works this way. Even in this age of high-level languages and abstraction, however, there are very good reasons to use the computer’s native representation. If one can only specify an integer value between 0 and 100, any mapping that is used will be uneven and it will not be possible to indicate many native color values (the other 155 of them). If one is allowed to specify a floating-point number between 0



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.