Beispiel #1
0
def main(filename="bdbh.gif"):
    image = Image(filename)
    image.draw()
    #
    blackandWhite(image)
    #
    image.draw()
Beispiel #2
0
def main():
    filename = input("Enter the image file name: ")
    image = Image(filename)
    grayscale(image)
    image.draw()
    sepia(image)
    image.draw()
Beispiel #3
0
def main(filename="smokey.gif"):
    image = Image(filename)
    print("Close the image window to continue.")
    image.draw()
    grayscale(image)
    print("Close the image window to quit.")
    image.draw()
def testSharpen (name = "smokey.gif", degree = 50, amount = 20):
    """Makes image appear crisper."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    image2 = sharpen(image, degree, amount)
    image2.draw()
Beispiel #5
0
def main():
    filename = input("Enter the image file name: ")
    image = Image(filename)
    print("Close the window to view the changes to the image.")
    image.draw()
    newimage = enlarge(image, 2)
    newimage.draw()
def main():
    colors = [(255, 0, 0), (255, 255, 0), (0, 255, 0), (0, 255, 255),
              (0, 0, 255), (255, 0, 255)]

    img = Image(500, 200)
    rainbow(img, colors)
    img.draw()
Beispiel #7
0
def main(filename="example.gif"):
    image = Image(filename)
    print("Close to continue.")
    image.draw()
    grayscale(image)
    print("Close window to quit.")
    image.draw()
Beispiel #8
0
def main():
    filename = input("Enter the image file name: ")
    image = Image(filename)
    #lighten(image, 20) example
    #darken(image2, 64) example
    colorFilter(image3, (255, 0, 0)) #example
    image.draw()
Beispiel #9
0
def main(filename="smokey.gif"):
    image = Image(filename)
    print "Close the image window to continue. "
    image.draw()
    blackAndWhite(image)
    print "Close the image window to quit. "
    image.draw()
Beispiel #10
0
    def convertFile(self):
        try:
            if self._pictureThere:

                # Converts the argument image to black and white
                from images import Image
                image = Image(self._textField.getText())
                blackPixel = (0, 0, 0)
                whitePixel = (255, 255, 255)
                for y in range(image.getHeight()):
                    for x in range(image.getWidth()):
                        (r, g, b) = image.getPixel(x, y)
                        average = (r + g + b) / 3
                        if average < 128:
                            image.setPixel(x, y, blackPixel)
                        else:
                            image.setPixel(x, y, whitePixel)
                image.draw()
            else:
                print("uhhhhhhhh no image there")

        except Exception:
            self.messageBox(
                title="ERROR",
                message=
                "THERE IS NO FILE INPUTTED. \n PLEASE ENTER A FILE NAME.")
Beispiel #11
0
def main(filename = "smokey.gif"):
    image = Image(filename)
    print "Close the image window to continue. "
    image.draw()
    grayscale(image)
    print "Close the image window to quit. "
    image.draw()
def main(filename = "smokey.gif"):
    image = Image(filename)
    print "Close the image window to continue. "
    image.draw()
    blackAndWhite(image)
    print "Close the image window to quit. "
    image.draw()
def main(filename):
    image = Image(filename)
    print('Close the image window to continue. ')
    image.draw()
    invertImage(image)
    print('Close the image window to quit. ')
    image.draw()
Beispiel #14
0
def testSharpen(name="smokey.gif", degree=50, amount=20):
    """Makes image appear crisper."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    image2 = sharpen(image, degree, amount)
    image2.draw()
Beispiel #15
0
def main(filename="example.gif"):
    image = Image(filename)
    print("Close to continue.")
    image.draw()
    color = (82, 50, 168)
    posterize(image, color)
    print("Close window to quit.")
    image.draw()
Beispiel #16
0
def testGrayscale(name="smokey.gif"):
    """Loads and draws an image, converts it to pyschologically correct
    grayscale, and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    grayscale(image)
    image.draw()
Beispiel #17
0
def testDetect(name = "smokey.gif", amount = 20):
    """Loads and draws an image, then
    detects edges and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    image2 = detectEdges(image, amount)
    image2.draw()
Beispiel #18
0
def testGrayscale(name = "smokey.gif"):
    """Loads and draws an image, converts it to pyschologically correct
    grayscale, and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    grayscale(image)
    image.draw()
Beispiel #19
0
def testSepia (name = "smokey.gif"):
    """Loads and draws an image, converts it to grayscale, then converts it to
    sepia, and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    sepia(image)
    image.draw()
Beispiel #20
0
def testSepia(name="smokey.gif"):
    """Loads and draws an image, converts it to grayscale, then converts it to
    sepia, and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    sepia(image)
    image.draw()
def testBlackAndWhite(name="smokey.gif"):
    """Loads and draws an image, then
    converts it to black and white and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    blackAndWhite(image)
    image.draw()
Beispiel #22
0
def testPosterize(name = "smokey.gif", triple = (0,0,0)):
    """Loads and draws an image, then converts it to a color
    of the user's choosing and white, and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    posterize(image, triple)
    image.draw()
def testDetect(name="smokey.gif", amount=20):
    """Loads and draws an image, then
    detects edges and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    image2 = detectEdges(image, amount)
    image2.draw()
Beispiel #24
0
def main():
    filename = input("Enter the image file name: ")
    red = int(input("Enter an integer [0..255] for red: "))
    green = int(input("Enter an integer [0..255] for green: "))
    blue = int(input("Enter an integer [0..255] for blue: "))
    image = Image(filename)
    posterize(image, (red, green, blue))
    image.draw()
Beispiel #25
0
def testBlackAndWhite(name = "smokey.gif"):
    """Loads and draws an image, then
    converts it to black and white and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    blackAndWhite(image)
    image.draw()
Beispiel #26
0
def testPosterize(name="smokey.gif", triple=(0, 0, 0)):
    """Loads and draws an image, then converts it to a color
    of the user's choosing and white, and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    posterize(image, triple)
    image.draw()
def testPosterize(name="smokey.gif"):
    """Loads and draws an image, then
    converts it to black and white and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    posterize(image, (0, 0, 255))
    image.draw()
    image.save(filename="posterize_" + name)
def testRotateRight(name="smokey.gif"):
    """Loads and draws an image, then
    rotates it 90 degrees to the right and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    image2 = rotateRight(image)
    image2.draw()
    image2.save(filename="rotateRight_" + name)
def testColorScale(name="smokey.gif"):
    """Loads and draws an image, then applies colorscale
    to the image and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    colorscale(image, (randint(0, 255), randint(0, 255), randint(0, 255)))
    image.draw()
    image.save(filename="colorscale_" + name)
def testSharpen(name="smokey.gif"):
    """Loads and draws an image, then sharpens
    the image and redraws it."""
    image = Image(name)
    print("Close the image window to see the transformation")
    image.draw()
    image2 = sharpen(image, 20, 50)
    image2.draw()
    image2.save(filename="sharpen_" + name)
Beispiel #31
0
def main():
    filename = input("Type the image you would like to use ")
    image = Image(filename)
    grayscale(image)
    print("Close the image window to continue. ")
    image.draw()
    sepia(image)
    print("Close the image window to quit. ")
    image.draw()
Beispiel #32
0
def main(filename = "smokey.gif"):
    image = Image(filename)
    print "Close the image window to continue. "
    image.draw()
    image2 = shrink(image, 2)
    print "Close the image window to continue. "
    image2.draw()
    image3 = shrink(image, 3)
    print "Close the image window to continue. "
    image3.draw()
    print "Close the image window to quit. "
Beispiel #33
0
def main(filename="smokey.gif"):
    image = Image(filename)
    print "Close the image window to continue. "
    image.draw()
    image2 = detectEdges(image, 10)
    print "Close the image window to continue. "
    image2.draw()
    image3 = detectEdges(image, 20)
    print "Close the image window to continue. "
    image3.draw()
    print "Close the image window to quit. "
Beispiel #34
0
def main(filename="smokey.gif"):
    image = Image(filename)
    print "Close the image window to continue. "
    image.draw()
    image2 = shrink(image, 2)
    print "Close the image window to continue. "
    image2.draw()
    image3 = shrink(image, 3)
    print "Close the image window to continue. "
    image3.draw()
    print "Close the image window to quit. "
Beispiel #35
0
def main(filename = "smokey.gif"):
    image = Image(filename)
    print "Close the image window to continue. "
    image.draw()
    image2 = detectEdges(image, 10)
    print "Close the image window to continue. "
    image2.draw()
    image3 = detectEdges(image, 20)
    print "Close the image window to continue. "
    image3.draw()
    print "Close the image window to quit. "
def main():
    filename = input("Enter the image file name: ")
    image = Image(filename)
    # Invert image
    invert(image)
    image.draw()
    # Covert to greyscale, then invert
    """grayscale(image)
    invert(image)
    image.draw()"""
    # Convert to black and white, then invert
    """blackAndWhite(image)
def main():
    filename = input(
        "Please enter the filename you wish to use (Must be a GIF file) >>")
    image = Image(filename)
    print("Close the image window to continue.")
    #draw orig image file
    image.draw()
    #indicate that the next phase is happening
    print("Processing image...")
    #send orig file data into the blackandwhite function
    blackAndWhite(image)
    print("Close the new image window to quit.")
    #draws the black and white version of the image
    image.draw()
Beispiel #38
0
def sepia():
    picture = Image("smokey.gif")

    for y in range(picture.getHeight()):
        for x in range(picture.getWidth()):
            (r, g, b) = picture.getPixel(x, y)

            newR = (0.393 * r + 0.769 * g + 0.189 * b)
            newG = (0.349 * r + 0.686 * g + 0.168 * b)
            newB = (0.272 * r + 0.534 * g + 0.131 * b)

            if newR > 255: newR = 255
            if newG > 255: newG = 255
            if newB > 255: newB = 255

            picture.setPixel(x, y, (newR, newG, newB))

    picture.draw()
def main(filename):
    image = Image(filename)
    print('Close the image window to continue. ')
    image.draw()
    greyscale(image)
    print('Close the image window to continue. ')
    image.draw()
    sepia(image)
    print('Close the image window to quit. ')
    image.draw()
Beispiel #40
0
from images import Image

image = Image("smokey.gif")
image.draw()

print(image.getWidth())

print(image.getHeight())

print(image)

print(image.getPixel(0, 0))

image = Image(150, 150)
image.draw()
blue = (0, 0, 255)
y = image.getHeight() // 2
for x in range(image.getWidth()):
    image.setPixel(x, y - 1, blue)
    image.setPixel(x, y, blue)
    image.setPixel(x, y + 1, blue)
image.draw()

image.save("horizontal.gif")