def main():
    """
    () -> NoneType
    Main Program that load image(s) from file(s) and performs transformations!
    """

    #Loads the original image
    original_img = image.load_from_file('crayons.png')
    obamanation = image.load_from_file('obama.png')
    stopschild = image.load_from_file('stop_sign.png')
    blaetter = image.load_from_file('leaves.png')

    #Assign a bunch of variables and transforms more than Optimus Prime
    color_cycled = color_cycle(original_img)
    grayscaled = grayscale(original_img)
    negated = negative(original_img)
    brightered = brightness(original_img)
    contrasted = increase_contrast(original_img)
    posterized = posterize(original_img)
    obamafied = obamafy(obamanation)
    redded = key_out_red(stopschild, blaetter)

    #displays all images
    image.display_images(color_cycled, grayscaled, negated, brightered, contrasted, posterized)
    image.display_images(obamafied, redded)
#Leo Ascenzi
import image
img = image.load_from_file('secret_message.png')
ns = ""
w = img.width()
h = img.height()
for y in range(h):
    for x in range(w):
        r, g, b = img.get_rgb(x, y)
        if r == 13:
            ns = ns + chr((g+b))
print ns


        
Example #3
0
import image

img = image.load_from_file('crayons.png')
negative = image.copy_image(img)

w = img.width()
h = img.height()

for x in range(w):      # converts image to negative
    for y in range(h):
        r, g, b = img.get_rgb(x, y)
        negative.set_rgb(x, y, abs(r - 255), abs(g - 255), abs(b - 255))
    
image.save_to_file(negative, 'negative.png')
image.display_images(img, negative)
 
#Leo Ascenzi
import image
img = image.load_from_file('landmark_puzzle.png')

h = img.height()
w = img.width()
for x in range(w):
    for y in range(h):
        r, g, b = img.get_rgb(x,y)
        img.set_rgb(x, y,0,g*25,0)

image.display_images(img)
Example #5
0
# Collaborators (if any):  
# Feedback: What was the hardest part of this assignment?
#   obamafy
# Feedback: Any suggestions for improving the assignment?	
#   great assignment
# ----------------------------------------------------------

import image

brightness_change = int(raw_input("Enter how much you want to change the brightness: ")) # establishes user input early on for a later image conversion

# -------------------------------
# 1.  Grayscale problem
# -------------------------------

img = image.load_from_file('crayons.png')
grayscale = image.copy_image(img)

w = img.width()
h = img.height()

for x in range(w):
    for y in range(h):
        r, g, b = img.get_rgb(x, y)
        grayscale.set_rgb(x, y, (r + g + b)/3, (r + g + b)/3, (r + g + b)/3)   # sets the grayscale value to the average of the red, green and blue values for each pixel
    

image.save_to_file(grayscale, 'grayscale.png')

print
#Leo Ascenzi
import image

spring = image.load_from_file('spring.png')
winter = image.load_from_file('winter.png')
img = image.new_image(728, 546)

h = img.height()
w = img.width()
for y in range(h):
    for x in range(w):
        if x % 2 == 0:
            r, g, b = winter.get_rgb(x, y)
            img.set_rgb(x, y, r, g, b)
            r, g, b = spring.get_rgb(x, y)
            img.set_rgb(x, y, r, g, b)

image.display_images(img)
Example #7
0
import image

img = image.load_from_file('obama.png')
obamafy = image.copy_image(img)

w = img.width()
h = img.height()

for x in range(w):     # obamafies the image 
    for y in range(h):
        r, g, b = img.get_rgb(x, y)
        if (r + g + b)/3 < 60:
            obamafy.set_rgb(x, y, 0, 51, 76)
        elif (r + g + b)/3 < 121:
            obamafy.set_rgb(x, y, 217,26,33)
        elif (r + g + b)/3 <= 182:
            obamafy.set_rgb(x, y, 112, 150, 158)
        else:
            obamafy.set_rgb(x, y, 252, 227, 166)
            
image.save_to_file(obamafy, 'obamafy.png')
image.display_images(img, obamafy)
#Leo Ascenzi
import image
img = image.load_from_file('crayons.png')
w = img.width()
h = img.height()

print "The original dimensions of the image are: %s x %s" % (w, h)
w1 = int(raw_input("Width?: "))
h1 = int(raw_input("Height?: "))
imgs = image.new_image(w1, h1)
multx = float(w1) / w
multy = float(h1) / h

for y in range(h1):
    for x in range(w1):
        r, g, b = img.get_rgb(int(x / multx), int(y / multy))
        imgs.set_rgb(x, y, r, g, b)

image.display_images(imgs)