コード例 #1
0
def main():

    print("1 = Grayscale")
    print("2 = Negative")
    print("3 = RGB Mask")
    print("4 = Sepia")
    print("5 = Lower Brightness")
    print("6 = Increase Brightness")
    print("7 = Blur")
    print("8 = Emboss\n")

    choice = int(input("Please choose a filter : "))
    c_file = str(input("Please type the path of your file : "))

    if (choice == 1):
        filters.grayscale(get_file_data(c_file))
    elif (choice == 2):
        filters.negative(get_file_data(c_file))
    elif (choice == 3):
        filters.rgb_mask(get_file_data(c_file))
    elif (choice == 4):
        filters.sepia(get_file_data(c_file))
    elif (choice == 5):
        filters.low_bright(get_file_data(c_file))
    elif (choice == 6):
        filters.up_bright(get_file_data(c_file))
    elif (choice == 7):
        filters.blur(get_file_data(c_file))
    elif (choice == 8):
        filters.emboss(get_file_data(c_file))
    else:
        print("Please enter a correct number !")
        main()
コード例 #2
0
def applyFilter(f):
    global image, workingImage, app

    if(workingImage == None):
        app.loadFile()

    width, height = workingImage["size"][0], workingImage["size"][1]
    pixels = workingImage["pixels"]

    if(f == "g"):
        pixels = filters.grayscale(pixels)
    elif(f == "t"):
        minT, maxT = app.minThreshold.get(), app.maxThreshold.get()
        pixels = filters.grayscale(pixels, lmin=minT, lmax=maxT)
    elif(f == "b"):
        pixels = filters.blur(pixels, width, height)
    elif(f == "n"):
        pixels = filters.negative(pixels)
    elif(f == "s"):
        pixels = filters.sepia(pixels)
    elif(f == "no"):
        level, intensity = app.noiseLevel.get(), app.noiseIntensity.get()
        pixels = filters.noise(pixels, level, intensity)
    elif(f == "rn"):
        aggressiveness = app.noiseAggressiveness.get()
        pixels = filters.removeNoise(pixels, width, height, aggressiveness)
    elif(f == "d"):
        pixels = filters.difference(pixels, width, height)
    elif(f == "c"):
        pixels = filters.applyMask(pixels, width)
    elif(f == "bd"):
        pixels = filters.borderDetection(pixels, width)
    elif(f == "od"):
        coordinates = app.mouseCoords
        color = (0,0,255)
        pixels, dmp1, dmp2 = filters.objectDetection(pixels, width, height, coordinates, color)
    else:
        pass
    saveImageChanges(pixels)
    app.updateCanvas()
    print "Done!"
    return
コード例 #3
0
def applyFilter(f):
    global image, lastImage, app
    if(f == "o"):
        i = image
    else:        
        i = "tmp.png"
        a, width, height, pixels = imageToPixels(lastImage)
        if(f == "g"):
            pixels = filters.grayscale(pixels)
        elif(f == "t"):
            minT, maxT = app.minThreshold.get(), app.maxThreshold.get()
            pixels = filters.grayscale(pixels, lmin=minT, lmax=maxT)
        elif(f == "b"):
            pixels = filters.blur(pixels, width, height)
        elif(f == "n"):
            pixels = filters.negative(pixels)
        elif(f == "s"):
            pixels = filters.sepia(pixels)
        elif(f == "no"):
            level, intensity = app.noiseLevel.get(), app.noiseIntensity.get()
            pixels = filters.noise(pixels, level, intensity)
        elif(f == "rn"):
            aggressiveness = app.noiseAggressiveness.get()
            pixels = filters.removeNoise(pixels, width, height, aggressiveness)
        elif(f == "d"):
            pixels = filters.difference(pixels, width, height)
        elif(f == "c"):
            pixels = filters.applyMask(pixels, width)
        elif(f == "bd"):
            pixels = filters.borderDetection(pixels, width)
        elif(f == "od"):
            coordinates = app.mouseCoords
            color = (0,0,255)
            pixels, dmp1, dmp2 = filters.objectDetection(pixels, width, height, coordinates, color)
        else:
            pass
        saveImage((width, height), pixels, i)
    lastImage = i
    app.updateCanvas(i)
    print "Done!"
    return
コード例 #4
0
if __name__ == "__main__":

    image_loaded = False

    print(show_menu())
    while True:
        user_input = input(": ")
        if user_input == "L":
            img = get_image()
            show(img)
            image_loaded = True
        elif user_input == "N":
            if not image_loaded:
                print("No image loaded")
                continue
            filters.negative(img)
            show(img)
        elif user_input == "G":
            if not image_loaded:
                print("No image loaded")
                continue
            filters.weighted_grayscale(img)
            show(img)
        elif user_input == "X":
            if not image_loaded:
                print("No image loaded")
                continue
            filters.extreme_contrast(img)
            show(img)
        elif user_input == "S":
            if not image_loaded: