Class 38 — Monday, November 22

Green screening

It’s simply smashing — For visitors on the Lawn — If they watch their steps


Look both ways


Agenda


Downloads


Module mash.py




Primary function

def combine( bg, fg, sx, sy, back_screen ) :

  bw, bh = bg.size # size of background image

  fw, fh = fg.size # size of foreground image

  copy = bg.copy() # get a copy of background image

  new_image = copy.convert( 'RGB' ) # to be the basis of new image

  for fx in range( 0, fw ) : # consider every (fx, fy)

  for fy in range( 0, fh ): # possibility of the new image

  fspot = ( fx, fy ) # name spot (fx, fy )

  fpixel = fg.getpixel( fspot ) # get fspot pixel on fg image

  nx = sx + fx # determine the shifted nspot on new image

  ny = sy + fy # to paint fpixel

  nspot = ( nx, ny )

  # check whether fpixel should be painted on new image at nspot

  if ( colorable( nspot, new_image, fpixel, back_screen ) ) :

  new_image.putpixel( nspot, fpixel )

  return new_image # return the mash up


Support constants

SIMILARITY_THRESHOLD = 85 # minimum distance to be dissimilar

GREEN = ( 0, 255, 0 ) # default back screen color



Support functions