remove_red!(b)
functions in ppm.rb
unix command:
display filename
Create a function happy_face() that returns a 3D Rubby array containing the bitmap image of the \(5\text{ pixel}\times 4\text{ pixel}\) smiling face shown below.
Example Usage:
>> plot(happy_face(),20)
Note: The eyes are "midnight blue", the lips are "crimson", and the nose is black". (See RGB Color Table)
Create a function remove_green!(image) that alters image so that none of the pixels have any green remaining in them but they each still have the same red and blue values.
Example:
>> b = load_ppm("nautical.ppm"); nil => nil >> plot(b) => nil >> remove_green!(b) => nil >> plot(b) => nil
becomes |
Create a function dim!(image) that alters image so that each pixel is an \(\frac{1}{3}\) as bright as in the original image. Each pixel should also keep the same proportion of red, green, blue (subject to rounding errors).
Possible algorithm: For each row in the image and each column in that row:
Example:
>> b = load_ppm("nautical.ppm"); nil => nil >> plot(b) => nil >> dim!(b) => nil >> plot(b) => nil
becomes |
Challenge: Create a function big_face() that returns a 3d bitmap array for a 300x300 face as shown in the following figure:
Example:
>> plot(big_face()) => nil