Homework 25 — image manipulation
Due Wednesday November 28
- In classes 34 and 35 we investigated the power of patterns and made use of them to simplify image manipulation. In these classes we considered and developed modules
- Provides a pattern for photo manipulation and a collection of convenience fuctions to support blueing, color inversion, flipping, mirroring, mono coloring, greyscaling, sepia toning, and palette reduction.
- Provides functions to return the dimensions of two types of image manipulation — same size and clockwise rotation
- Provides functions for determining where is the source pixel for a pixel manipulation supported by
- Provides functions for the pixel manipulations supported by
- The task at hand is to implement module
grey( p )
- In converting an image to its grayscale equivalent the translation sacrifices pixel coloring for intensity. In the conversion, a pixel
(r,g,b)corresponds to a pixel
mis the integer cast of
.299r + .587g + .114b
The formula is known as the NTSC formula.
sepia( p )
- There is no one formula for defining a Sepia pixel conversation. The one used here comes from Microsoft.
- For pixel
(r,g,b), the Sepia conversion is
sr, sg, sb = int( min( i, 255 )), int( min( j, 255 )), int( min( k, 255 )),
i, j, kare
i = .393r + .769g + .189b
j = .349r + .686g + .168b
k = .272r + .534g + .131b
Palette reduction —
distance( p ) and
simplify( p )
- Sometimes to save computer memory, software developers perform a palette reduction of colors used in image representation.
- Our reduction scheme will use an eight-color palette
- Black, White, Red, Green, Blue, Yellow, Magenta, and Cyan; that is,
(0,0,0), (255,255,255), (255,0,0), (0,255,0), (0,0,255), (255,255,0), (255,0,255),and
- In a palette reduction, a pixel
(r,g,b)is replaced by the pixel in in the palette it is closest to. The distance between pixels
abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2)
ccw( spot, w, h )
- In a clockwise rotation an image is rotated by 90 degrees.