Пример #1
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
Пример #2
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