Imaging

Having a problem solving pattern to apply to similar problems is generally a good thing. For establishing an image processing how about the following.

for nx in range( 0, nw ) :

  for ny in range( 0, nh ) :

# get the dimensions of the original

ow = original.width

oh = original.height

 

# determine the dimensions of the new image

nw = ...

nh = ...

 

# create a new blank image to hold the transformation

new_image = Image.new( 'RGB', (nw, nh) )

 

# consider every (x, y) location in the new image

for nx in range( 0, nw ) :

  for ny in range( 0, nh ) :

  # get the new image coordinate to be colored

  ncoordinate = (nx, ny)

 

  # determine the pixel value for ncoordinate

  ...

  npixel = ...

 

  # set the pixel at ncoordinate

  new_image.putpixel( ncoordinate, npixel )

 

# return the transformation

return new