Homework 25 — image manipulation

Due Wednesday November 28


Modules color.py and locate.py

  • 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 manip.py
  • Provides functions for the pixel manipulations supported by manip.py

Grayscaling — color.py function grey( p )

.299r + .587g + .114b

The formula is known as the NTSC formula.

mandrill mandrill


Sepia — color.py function sepia( p )

sr, sg, sb = int( min( i, 255 )), int( min( j, 255 )), int( min( k, 255 )),

where i, j, k are

i = .393r + .769g + .189b

j = .349r + .686g + .168b

k = .272r + .534g + .131b

mandrill mandrill


Palette reduction — color.py functions distance( p ) and simplify( p )

abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2)

mandrill mandrill


Clockwise rotation locate.py function ccw( spot, w, h )

mandrill mandrill

 


 

 

 
   
   
   
 
  © 2019 Jim Cohoon   Resources from previous semesters are available.