def loadButtonAction():
     """Callback function for the Load button"""
     nonlocal currentFile
     filename = chooseInputFile()
     currentFile = filename
     if filename != "":
         img = GImage(filename)
         width = len(img.getPixelArray())
         height = len(img.getPixelArray()[0])
         max_dim = max(width, height)
         sf = 750 / max_dim
         if max_dim > 750:
             img.scale(sf)
         
         setImage(img)
         clearMessage()
Exemple #2
0
def greenScreen(image):
    array = image.getPixelArray()
    height = len(array)
    width = len(array[0])

    filename = chooseInputFile()
    if filename != "":
        newImage = GImage(filename)
        newarray = newImage.getPixelArray()

    for i in range(height):
        for j in range(width):
            if isntGreen(newarray[i][j]):
                array[i][j] = newarray[i][j]

    return GImage(array)
Exemple #3
0
def greenScreen(image):
    """Creates a new GImage from the original one by replacing pixels in the
    original one with pixels in another chosen picture when the pixel of 
    the chosen picture is not green."""
    array = image.getPixelArray()
    new_filename = chooseInputFile()
    new_image = GImage(new_filename)
    new_array = new_image.getPixelArray()

    for i in range(min(len(array), len(new_array))):
        for j in range(min(len(array[0]), len(new_array[0]))):
            if not (bin(new_array[i][j])[18:26] > 2 * max(
                    bin(new_array[i][j])[10:18],
                    bin(new_array[i][j])[26:34])):
                array[i][j] = new_array[i][j]

    return GImage(array)
Exemple #4
0
 def loadButtonAction():
     """Callback function for the Load button"""
     filename = chooseInputFile()
     if filename != "":
         setImage(GImage(filename))
Exemple #5
0
 def greenScreenAction():
     '''Callback function for the GreenScreen button'''
     if currentImage is not None:
         filename = chooseInputFile()
         if filename != '':
             setImage(greenScreen(currentImage, GImage(filename)))