# Pages Audrey Lyman Project 4

In this task, we manipulated a picture's color and background in order to gain experience with pixmaps, creating Andy Warhol style pictures.

The first task required us to create a function that could place a picture anywhere on a pixmap. My code is below:

def putPixmap( dst, src, x, y ):

for i in range( src.getHeight() ):

for j in range( src.getWidth() ):

(r, g, b) = src.getPixel( j, i )

dst.setPixel( x + j, y + i, (r, g, b) )

return

Next, we had to create multiple functions that edited the colors of a pixmap and then use four of them to create a larger collage. My collage is below:

As an extension, I created larger collages, shown below:

In the first image, I used a 2 x 4 grid by multiplying the smaller pixmap's width by 4 and height by 2, and then inserting the pictures based off the width and height of those next to it. The second is the same concept, but a 3 x 3 grid of pixmaps. (you can see the lower part of my screen because the big pixmap took up the whole length of the monitor...)

The final task was to change the original background color (blue) without changing the rest of the picture. My result is below:

I did this by standardizing what pixels changed color based on how "blue" they were. Some of my code is below:
if b > (r*3):
pm.setPixel(x,y,(0,100,0))

For another extension, I put myself in outer space. I just added in another pixmap variable to my filter code, shown below:

def background(pm, new):
for y in range( pm.getHeight() ):
for x in range( pm.getWidth() ):
(r,g,b) = pm.getPixel(x,y) if b > (2*r): (rb,gb,bb) = new.getPixel(x,y) pm.setPixel(x, y, (rb,gb,bb) )    return
def background(pm, new):

for y in range( pm.getHeight() ):

for x in range( pm.getWidth() ):

(r,g,b) = pm.getPixel(x,y)

if b > (2*r):

(rb,gb,bb) = new.getPixel(x,y)

pm.setPixel(x, y, (rb,gb,bb) )

return

I learned a lot about pixels and pixmaps and how easily manipulated they are, based off their qualities (where they are on a pixmap, what color they are, etc). This project opened the door to many possibilities for manipulating pictures and now I can recognize/know how others do this when I come across manipulated pictures in the future.

Labels