title: Image Processing using MPI
body: <p>I have to do some image processing using parallel programming. I'm using Python with MPI (mpi4py).
  I have two functions, Sepia and Flip. I think they are self explanatory. This is the sequential code:</p>
  
  <pre><code>def sepia(name):
    img = Image.open('dog.jpg')
    for i in range(width):
      for j in range(height):
        r, g, b = img.getpixel((i, j))
        rr = int(r * 0.393 + g * 0.769 + b * 0.189)
        gg = int(r * 0.349 + g * 0.686 + b * 0.168)
        bb = int(r * 0.272 + g * 0.534 + b * 0.131)
        img.putpixel((i,j),(rr,gg,bb))
    img.save(name)
  
  def flip(name):
    img = Image.open('dog.jpg')
    white = (255,255,255)
    image = Image.new("RGB", (width, height))
    for i in range(width):
      for j in range(height):
        r, g, b = img.getpixel((i,j))
        image.putpixel((width-i-1, height-j-1),(r,g,b))
    image.save(name)
  </code></pre>
  
  <p>How can I parallelize this code using MPI?</p>