diff --git a/Image-Processing/Multi Filters Include Negative/README.md b/Image-Processing/Multi Filters Include Negative/README.md new file mode 100644 index 00000000..a4ed791e --- /dev/null +++ b/Image-Processing/Multi Filters Include Negative/README.md @@ -0,0 +1,99 @@ +# Multi Filters Include Negative + +The multi filters provides eleven differents filters to apply on images. It includes the Blur effect, Contour, Detail, Edge enhance and the Edge enhance more, Emboss, Find_egdes, Sharpen, Smooth and the Smooth_more and the Negative effect + +## Installing dependences + +First of all, we should check if we are using an updated version of pip, with this line: + + `python3 -m pip install --upgrade pip` + +Now, we need to install Pillow library to support images on Python: + + `python3 -m pip install --upgrade Pillow` + +Then, the opencv library help us with computer vision, providing us with functions to apply filters: + + `pip install opencv-python` + +Others dependences that we are going to need are matplotlib, to display the images and for that we need to install numpy: + + `pip install numpy` + +and then install matplotlib: + + `matplotlib: python -m pip install -U matplotlib` + +note that matplotlib may install numpy as a dependence, but is a good practice to do it manually + +## Running + +To get the program running we use the command below: + + `python filters.py [NAME OF FILE IMAGE]` + +It will show us the image we chosen and open a menu with the filters, from which we got to write a number corresponding to the filter we would like + +## Example + +Let's try out with a normal image of an apple +

+ +

+ +Applying each of the filters, we get the following results: + +1 - Blur filter +

+ +

+ +2 - Contour filter +

+ +

+ +3 - Detail filter +

+ +

+ +4 - Edge enhance filter +

+ +

+ +5 - Edge enhance more filter +

+ +

+ +6 - Emboss filter +

+ +

+ +7 - Find_egdes filter +

+ +

+ +8 - Sharpen filter +

+ +

+ +9 - Smooth filter +

+ +

+ +10 - Smooth_more filter +

+ +

+ +11 - Negative filter +

+ +

\ No newline at end of file diff --git a/Image-Processing/Multi Filters Include Negative/apple.jpg b/Image-Processing/Multi Filters Include Negative/apple.jpg new file mode 100644 index 00000000..3b11cab4 Binary files /dev/null and b/Image-Processing/Multi Filters Include Negative/apple.jpg differ diff --git a/Image-Processing/Multi Filters Include Negative/filters.py b/Image-Processing/Multi Filters Include Negative/filters.py new file mode 100644 index 00000000..ef1a588b --- /dev/null +++ b/Image-Processing/Multi Filters Include Negative/filters.py @@ -0,0 +1,64 @@ +from PIL import Image +from PIL import ImageFilter +import matplotlib.pyplot as plt +import negative_image +import cv2 +import sys +import os + +# Loading images +if len(sys.argv) == 2: + fn_with_ext = sys.argv[1] + filename, file_extension = os.path.splitext(sys.argv[1]) +else: + print("No input image given, so loading default image, lena.jpg \n") + print("Correct Usage: python grabcut.py \n") + +# Insert path here +img = Image.open(fn_with_ext) +img = img.convert('RGB') + +plt.imshow(img) +plt.show() + +# List of Filters (is selected in menu option) +filters = [ImageFilter.BLUR, ImageFilter.CONTOUR, ImageFilter.DETAIL, ImageFilter.EDGE_ENHANCE, ImageFilter.EDGE_ENHANCE_MORE, ImageFilter.EMBOSS, ImageFilter.FIND_EDGES, ImageFilter.SHARPEN, ImageFilter.SMOOTH, ImageFilter.SMOOTH_MORE] + +while True: + try: + print("MENU OF FILTERS IMAGE APPLICATION", end=" ") + print("(CHOOSE A OPTION BELLOW TO FILTER AN IMAGE):") + + print("1- BLUR") + print("2- CONTOUR") + print("3- DETAIL") + print("4- EDGE_ENHANCE") + print("5- EDGE_ENHANCE_MORE") + print("6- EMBOSS") + print("7- FIND_EDGES") + print("8- SHARPEN") + print("9- SMOOTH") + print("10- SMOOTH_MORE") + print("11- NEGATIVE") + print("Ctr+D FOR EXIT") + + opt = None + while True: + try: + opt = int(input()) + if (opt >= 1 and opt <= 11): + break + except ValueError: + print("PLEASE, DIGIT A INTEGER NUMBER BETWEEN 1 AND 11") + + if (opt >= 1 and opt <= 10): + img1 = img.filter(filters[opt-1]) + img1.save(f"./images/{filename}_{opt}_converted{file_extension}", "JPEG") + else: + img1 = negative_image.negative(fn_with_ext) + cv2.imwrite(f"./images/{filename}_{opt}_converted{file_extension}", img1) + + plt.imshow(img1) + plt.show() + except EOFError: + break \ No newline at end of file diff --git a/Image-Processing/Multi Filters Include Negative/images/apple_10_converted.jpg b/Image-Processing/Multi Filters Include Negative/images/apple_10_converted.jpg new file mode 100644 index 00000000..8a77a7df Binary files /dev/null and b/Image-Processing/Multi Filters Include Negative/images/apple_10_converted.jpg differ diff --git a/Image-Processing/Multi Filters Include Negative/images/apple_11_converted.jpg b/Image-Processing/Multi Filters Include Negative/images/apple_11_converted.jpg new file mode 100644 index 00000000..cc1404a6 Binary files /dev/null and b/Image-Processing/Multi Filters Include Negative/images/apple_11_converted.jpg differ diff --git a/Image-Processing/Multi Filters Include Negative/images/apple_1_converted.jpg b/Image-Processing/Multi Filters Include Negative/images/apple_1_converted.jpg new file mode 100644 index 00000000..5ea71dc5 Binary files /dev/null and b/Image-Processing/Multi Filters Include Negative/images/apple_1_converted.jpg differ diff --git a/Image-Processing/Multi Filters Include Negative/images/apple_2_converted.jpg b/Image-Processing/Multi Filters Include Negative/images/apple_2_converted.jpg new file mode 100644 index 00000000..85aebb24 Binary files /dev/null and b/Image-Processing/Multi Filters Include Negative/images/apple_2_converted.jpg differ diff --git a/Image-Processing/Multi Filters Include Negative/images/apple_3_converted.jpg b/Image-Processing/Multi Filters Include Negative/images/apple_3_converted.jpg new file mode 100644 index 00000000..3c3d9924 Binary files /dev/null and b/Image-Processing/Multi Filters Include Negative/images/apple_3_converted.jpg differ diff --git a/Image-Processing/Multi Filters Include Negative/images/apple_4_converted.jpg b/Image-Processing/Multi Filters Include Negative/images/apple_4_converted.jpg new file mode 100644 index 00000000..53b8bcb2 Binary files /dev/null and b/Image-Processing/Multi Filters Include Negative/images/apple_4_converted.jpg differ diff --git a/Image-Processing/Multi Filters Include Negative/images/apple_5_converted.jpg b/Image-Processing/Multi Filters Include Negative/images/apple_5_converted.jpg new file mode 100644 index 00000000..e5d2d060 Binary files /dev/null and b/Image-Processing/Multi Filters Include Negative/images/apple_5_converted.jpg differ diff --git a/Image-Processing/Multi Filters Include Negative/images/apple_6_converted.jpg b/Image-Processing/Multi Filters Include Negative/images/apple_6_converted.jpg new file mode 100644 index 00000000..f49d53c3 Binary files /dev/null and b/Image-Processing/Multi Filters Include Negative/images/apple_6_converted.jpg differ diff --git a/Image-Processing/Multi Filters Include Negative/images/apple_7_converted.jpg b/Image-Processing/Multi Filters Include Negative/images/apple_7_converted.jpg new file mode 100644 index 00000000..219115e9 Binary files /dev/null and b/Image-Processing/Multi Filters Include Negative/images/apple_7_converted.jpg differ diff --git a/Image-Processing/Multi Filters Include Negative/images/apple_8_converted.jpg b/Image-Processing/Multi Filters Include Negative/images/apple_8_converted.jpg new file mode 100644 index 00000000..73ee6907 Binary files /dev/null and b/Image-Processing/Multi Filters Include Negative/images/apple_8_converted.jpg differ diff --git a/Image-Processing/Multi Filters Include Negative/images/apple_9_converted.jpg b/Image-Processing/Multi Filters Include Negative/images/apple_9_converted.jpg new file mode 100644 index 00000000..cb105c84 Binary files /dev/null and b/Image-Processing/Multi Filters Include Negative/images/apple_9_converted.jpg differ diff --git a/Image-Processing/Multi Filters Include Negative/negative_image.py b/Image-Processing/Multi Filters Include Negative/negative_image.py new file mode 100644 index 00000000..fddeeed1 --- /dev/null +++ b/Image-Processing/Multi Filters Include Negative/negative_image.py @@ -0,0 +1,8 @@ +import cv2 + +def negative(image): + img_bgr = cv2.imread(image, 1) + + img_neg = 255 - img_bgr + + return img_neg \ No newline at end of file