from VideoCapture import Device import ImageDraw import Image import sys import pygame import ImageChops # init pygame pygame.init() # get cam device cam = Device() # setup screen size size = width, height = 320,240 screen = pygame.display.set_mode(size) while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() shot = cam.getImage() # split the image into individual bands source = shot.split() R, G, B = 0, 1, 2 reddata = source[R] greendata = source[G] bluedata = source[B] reddata = reddata.point(lambda i: i > 135 and 200) camshot = ImageChops.subtract(reddata, greendata) camshot = ImageChops.subtract(camshot, bluedata) camshot = camshot.point(lambda i: i > 0 and 255) #paste the 3 processed bands back source[R].paste(camshot, None) source[G].paste(0, None) source[B].paste(0, None) # build a new multiband image camshot = Image.merge(shot.mode, source) camshot = pygame.image.fromstring(camshot.tostring(), (320,240), "RGB") screen.blit(camshot, (0,0)) pygame.display.flip()