title: Is it possible to mask an image in Python Imaging Library (PIL)?
body: <p>I have some traffic camera images, and I want to extract only the pixels on the road.  I have used remote sensing software before where one could specify an operation like</p>
  
  <p>img1 * img2 = img3</p>
  
  <p>where img1 is the original image and img2 is a straight black-and-white mask.  Essentially, the white parts of the image would evaluate to</p>
  
  <p>img1 * 1 = img3</p>
  
  <p>and the black parts would evaluate to</p>
  
  <p>img1 * 0 = img3</p>
  
  <p>And so one could take a slice of the image and let all of the non-important areas go to black.</p>
  
  <p>Is there a way to do this using PIL? I can't find anything similar to image algebra like I'm used to seeing.  I have experimented with the blend function but that just fades them together.  I've read up a bit on numpy and it seems like it might be capable of it but I'd like to know for sure that there is no straightforward way of doing it in PIL before I go diving in.</p>
  
  <p>Thank you.</p>