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()
def filter_func(label): reset() global color, gray if (label == 'Clarendon'): color = filters.Clarendon(img) elif (label == 'Gingham'): color = filters.Gingham(img) elif (label == 'Reyes'): color = filters.Reyes(img) elif (label == 'Amaro'): color = filters.Amaro(img) elif (label == 'Inkwell'): ink = filters.Inkwell(img) elif (label == 'Nahville'): color = filters.Nashville(img) elif (label == 'Toaster'): color = filters.Toaster(img) elif (label == '1977'): color = filters._1977(img) elif (label == 'Kelvin'): color = filters.Kelvin(img) else: color = filters.Original(img, shue.val / 10, ssat.val / 10, scont.val / 10, sbright.val - 50) if (radio.value_selected == 'color' and label != 'Inkwell'): l.set_data(color[:, :, ::-1]) else: if (label != 'Inkwell'): gray = filters.grayscale(color[:, :, ::-1]) l.set_data(gray) l.set_cmap('gray') else: l.set_data(ink) l.set_cmap('gray') fig.canvas.draw_idle()
def main(): #Ask what image the user wants to edit filename = input("Enter the name of the image file to edit: ") #Load the image from the specified filename img = filters.load_img(filename) #Ask which filter the user wants to use filter_choice = input( "Which filter would you like: obamicon, brighten, grayscale, or invert? " ) #Apply chosen filter if filter_choice == "obamicon": new_img = filters.obamicon(img) elif filter_choice == "brighten": new_img = filters.brighten(img) elif filter_choice == "invert": new_img = filters.invert_colors(img) elif filter_choice == "grayscale": new_img = filters.grayscale(img) else: print("Sorry, that is not an option.") #Save the final filtered Image filters.save_img(new_img, "recolored.jpg")
def main(): file = input("What file are you trying to edit: ") img = filters.load_img(file) new_img = filters.obamicon(img) gray_img = filters.grayscale(new_img) filters.save_img(gray_img, "recolored.jpg")
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
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
def update(val): global color color = filters.brightness_contrast(img, scont.val / 10, sbright.val - 50) color = filters.hue_saturation(color, shue.val / 10, ssat.val / 10) if (radio.value_selected == 'color'): l.set_data(color[:, :, ::-1]) else: global gray gray = filters.grayscale(color[:, :, ::-1]) l.set_data(gray) l.set_cmap('gray') fig.canvas.draw_idle()
def main(): # Ask what image the user wants to edit filename = input("Enter the name of the image file to edit: ") # Load the image from the specified file img = filters.load_img(filename) # Apply filters! newimg = filters.obamicon(img) newimg = filters.grayscale(newimg) # Save the final image filters.save_img(newimg, "recolored.jpg")
def main(): filename = input("Enter the name of the image file to edit: ") img = filters.load_img(filename) newimg = filters.obamicon(img) newimg = filters.grayscale(newimg) blue = (30, 85, 115) anotherimg = filters.emphasize(img, blue, 50) blueimg = filters.add_color(img, blue) lastimg = filters.invert(blueimg) filters.save_img(newimg, "recolored1.jpg")
def main(): file = input("What file are you trying to edit: ") img = filters.load_img(file) new_img = filters.obamicon(img) gray_img = filters.grayscale(new_img) blue = (30, 85, 115) emph_img = filters.emphasize(img, blue, 50) blue_img = filters.add_color(img, blue) invert_img = filters.invert(blue_img) filters.save_img(gray_img, "recolored.jpg") filters.save_img(emph_img, "emph.jpg") filters.save_img(blue_img, "blue.jpg") filters.save_img(invert_img, "invert.jpg")
def main(): filename = input("Enter the name of the image file to edit: ") img = filters.load_img(filename) obamicon_image = filters.obamicon(img) filters.save_img(obamicon_image, "recolored.jpg") grayscale_image = filters.grayscale(img) filters.save_img(grayscale_image, "grayscale.jpg") inverted_image = filters.invert(img) filters.save_img(inverted_image, "inverted.jpg") bluescale_image = filters.blue_recolor(img) filters.save_img(bluescale_image, "blue_recolor.jpg")
def main(): filename = input("Enter the name of the file you want to edit:") #use load_img function from the file "filters". "img" is the image from the file in "filename" img= filters.load_img(filename) #makes the image into gray scale newim = filters.grayscale(img) filters.save_img(newim, "grayviolin.jpg") #makes image into light blue, red, dark blue, and yellow newimage = filters.obamicon(img) filters.save_img(newimage, "obamiconviolin.jpg") #makes image into inverted colors image2 = filters.invertcolors(img) filters.save_img(image2, "invertedviolin.jpg") #else: just shows picture, if not grayscaled im = filters.show_img(img) filters.save_img(im, "violin.jpg")
def main(): filename = input("Enter the name of the image file to edit: ") img = filters.load_img(filename) filters.save_img(img, "newPic1.jpg") print("'O'bamicon, 'G'rayscale, 'P'urple?") while True: user_input = input() if user_input == "O": newimg = filters.obamicon(img) filters.save_img(newimg, "recolored.jpg") break if user_input == "G": newimg = filters.grayscale(img) filters.save_img(newimg, "recolored.jpg") break if user_input == "P": newimg = filters.purple(img) filters.save_img(newimg, "recolored.jpg") break
def main(): filename = input("Enter the name of the file you want to open: ") opened_image = filters.load_img(filename) # original image filters.show_img(opened_image) filters.save_img(opened_image, "image.jpeg") # obama filter obama_filter_image = filters.obamicon(opened_image) filters.show_img(obama_filter_image) filters.save_img(obama_filter_image, "obama.jpeg") # invert colors inverted_colors_image = filters.invertColors(opened_image) filters.show_img(inverted_colors_image) filters.save_img(inverted_colors_image, "inverted_colors.jpeg") # grayscale grayscale_image = filters.grayscale(opened_image) filters.show_img(grayscale_image) filters.save_img(grayscale_image, "grayscale.jpeg")
def main(): # Ask what image the user wants to edit filename = input("Enter the name of the image file to edit: ") # Load the image from the specified file img = filters.load_img(filename) # Apply filters! newimg = filters.bq.jpg(img) newimg = filters.grayscale(newimg) blue = (30, 85, 115) anotherimg = filters.emphasize(img, blue, 50) blueimg = filters.add_color(img, blue) lastimg = filters.invert(blueimg) # Save the final images filters.save_img(newimg, "recolored1.jpg") filters.save_img(anotherimg, "recolored2.jpg") filters.save_img(blueimg, "recolored3.jpg") filters.save_img(lastimg, "recolored4.jpg")
def process_image(image): grayscaleImage = grayscale(image) blurredImage = gaussian_blur(image, 11) edgesImage = canny(blurredImage, 40, 50) height = image.shape[0] width = image.shape[1] vertices = np.array( [[ [3*width/4, 3*height/5], [width/4, 3*height/5], [40, height], [width - 40, height] ]], dtype=np.int32 ) regionInterestImage = region_of_interest(edgesImage, vertices) #test_roi = region_of_interest(edgesImage, vertices) #cv2.imshow('Region Of Interest', test_roi) lineMarkedImage = hough_lines(regionInterestImage, 1, np.pi/180, 40, 30, 200) return weighted_img(lineMarkedImage, image)
def main(): filename = input("Enter the name of the image file to edit") img = filters.load_img(filename) newimg = filters.grayscale(img) filters.save_img(newimg, "recolored.jpg")
def main(): im = filters.load_img("hdcitylights.jpg") filtered_im = filters.grayscale(im) filters.show_img(filtered_im)
import numpy as np import cv2 import matplotlib.pyplot as plt from matplotlib.widgets import Slider, Button, RadioButtons import filters fig, ax = plt.subplots() plt.subplots_adjust(left=0.02, bottom=0.30, right=0.50) img = cv2.imread('flowers.jpg') color = img.copy() gray = filters.grayscale(img) l = plt.imshow(color[:, :, ::-1]) axcolor = 'lightgoldenrodyellow' axcont = plt.axes([0.55, 0.85, 0.38, 0.03], facecolor=axcolor) axbright = plt.axes([0.55, 0.80, 0.38, 0.03], facecolor=axcolor) axhue = plt.axes([0.55, 0.75, 0.38, 0.03], facecolor=axcolor) axsat = plt.axes([0.55, 0.70, 0.38, 0.03], facecolor=axcolor) scont = Slider(axcont, 'Contrast', 0, 20, valinit=10) sbright = Slider(axbright, 'Brightness', 0, 100, valinit=50) shue = Slider(axhue, 'Hue', 0, 20, valinit=10) ssat = Slider(axsat, 'Saturation', 0, 20, valinit=10) filtax = plt.axes([0.50, 0.02, 0.45, 0.65], facecolor=axcolor) filt = RadioButtons(filtax, ('None', 'Clarendon', 'Gingham', 'Reyes', 'Amaro', 'Inkwell', 'Nashville', 'Toaster', '1977', 'Kelvin'), active=0)
import filters import image_io image_matrix = image_io.read_file("images/shrek1.jpg") grayscale_matrix = filters.grayscale(image_matrix) image_io.write_to_file( "/home/oluwatosin/csci_100/lab_9/outputs/shrek1_image.png", grayscale_matrix) image_matrix2 = image_io.read_file("images/shrek2.jpg") reds_matrix = filters.red_stripes(image_matrix2) image_io.write_to_file( "/home/oluwatosin/csci_100/lab_9/outputs/shrek2_image.png", reds_matrix) image_matrix3 = image_io.read_file("images/shrek3.jpg") invert = filters.invert_colors(image_matrix3) image_io.write_to_file( "/home/oluwatosin/csci_100/lab_9/outputs/shrek3_image.png", invert) image_matrix4 = image_io.read_file("images/shrek4.jpg") flip = filters.flip(image_matrix4) image_io.write_to_file( "/home/oluwatosin/csci_100/lab_9/outputs/shrek4_image.png", flip) image_matrix5 = image_io.read_file("images/shrek5.jpg") sepia = filters.sepia(image_matrix5) image_io.write_to_file( "/home/oluwatosin/csci_100/lab_9/outputs/shrek5_image.png", sepia) image_matrix6 = image_io.read_file("images/shrek6.jpg") threshold = filters.threshold(image_matrix6)