title: I'm trying to render an image pieces to speed up it's rendering in python
body: <p>This is the code I am looking to modify in python2 or 3. The for j loop with the nested for i loop is what needs to be put into multiple processes. This code takes each pixel and determines it color (for my computer graphics class). As an added bonus I thought using subprocesses or multiprocessing would be helpful.</p>
  
  <pre><code>from __future__ import division, print_function
  
  from util import *
  
  def raytrace(scene, img, updateFn=None):
      width,height=img.size
      camera=scene.camera
      camera.setResolution(width, height)
      for j in range(height):
          for i in range(width):
              ray=camera.ijRay(i,j)
              color=raycolor(scene,ray,Interval(),3)
              img.setPixel((i,j),color.quantize(255))
          if updateFn:
              updateFn()
  </code></pre>
  
  <p>The following code is my attempt to break the image into 4 areas and edit the 'img' by moving the for loops into a separate method and passing it all the necessary variables. Then I labeled each process I wanted to run and used .start() for them and .join() to allow them all to finish. Unfortunately the 'img' originally passed to the raytrace method remains blank. </p>
  
  <pre><code># tracer1: Simple ray-tracing viewer with camera looking down z axis and
  #          viewing plane on the xy plane.
  
  from __future__ import division, print_function
  
  from util import *
  from multiprocessing import Process
  from image import Image
  
  def raytrace(scene, img, updateFn=None):
      width,height=img.size
      camera=scene.camera
      camera.setResolution(width, height)
      w=width//2
      h=height//2
      a=Process(target=part,args=(scene,img,camera,0,0,w,h,updateFn))
      a.start()
      b=Process(target=part,args=(scene,img,camera,w,0,width,h,updateFn))
      b.start()
      c=Process(target=part,args=(scene,img,camera,0,h,w,height,updateFn))
      c.start()
      d=Process(target=part,args=(scene,img,camera,w,h,width,height,updateFn))
      d.start()
      a.join()
      b.join()
      c.join()
      d.join()
  
  def part(scene,img, camera,swidth,sheight,ewidth,eheight,updateFn):
      for j in range(sheight,eheight+1):
          for i in range(swidth,ewidth+1):
              ray=camera.ijRay(i,j)
              color=raycolor(scene,ray,Interval(),3)
              img.setPixel((i,j),color.quantize(255))
          if updateFn:
              updateFn()
  </code></pre>
  
  <p>Any thoughts?</p>