diff --git a/Image-Processing/Cartoonify Image/Cartoonify.py b/Image-Processing/Cartoonify Image/Cartoonify.py new file mode 100644 index 00000000..c27d7b94 --- /dev/null +++ b/Image-Processing/Cartoonify Image/Cartoonify.py @@ -0,0 +1,37 @@ +# Importing Libraries +import cv2 +import numpy as np +from skimage import io + +# Class Defination +class Cartoon: + def __init__(self): + img = io.imread("images/sunset.jpg") + # 1) Edges Image + gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + gray = cv2.medianBlur(gray, 5) + edges = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 9, 7) + + # 2) Color Image + color = cv2.bilateralFilter(img, 10, 300, 300) + RGB_img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) + + # 3) Cartoon Image + cartoon = cv2.bitwise_and(color, color, mask=edges) + cartoon_img = cv2.cvtColor(cartoon, cv2.COLOR_BGR2RGB) + + # Re-sizeing Image + resize = cv2.resize(RGB_img, (600, 450)) + resize2 = cv2.resize(cartoon_img, (600, 450)) + self.resize = resize + self.resize2 = resize2 + +# Displaying Image +# Creating an object of class Cartoon +c1 = Cartoon() +c1.resize +c1.resize2 +cv2.imshow("Original_Image", c1.resize) +cv2.imshow("Cartoonified_Image", c1.resize2) +cv2.waitKey(0) +cv2.destroyAllWindows() diff --git a/Image-Processing/Cartoonify Image/README.md b/Image-Processing/Cartoonify Image/README.md new file mode 100644 index 00000000..40728e8c --- /dev/null +++ b/Image-Processing/Cartoonify Image/README.md @@ -0,0 +1,15 @@ +

Cartoonify Image

+ +The code converts your original image i.e. the image which you have given as input, to cartoonified image.
+When you run Cartoonify.py, both the input image and output image will be displayed.
+It can be further implemented for pencil-sketch, color-pencil-sketch, water-color image, sepia effect, oldifying, etc. + +

Results:

+ +

Original Image

+

+

+ +

Cartoonified Image

+

+

diff --git a/Image-Processing/Cartoonify Image/images/Cartoonified Image.PNG b/Image-Processing/Cartoonify Image/images/Cartoonified Image.PNG new file mode 100644 index 00000000..265b2ff3 Binary files /dev/null and b/Image-Processing/Cartoonify Image/images/Cartoonified Image.PNG differ diff --git a/Image-Processing/Cartoonify Image/images/Original Image.PNG b/Image-Processing/Cartoonify Image/images/Original Image.PNG new file mode 100644 index 00000000..c1b79ffb Binary files /dev/null and b/Image-Processing/Cartoonify Image/images/Original Image.PNG differ diff --git a/Image-Processing/Cartoonify Image/images/sunset.jpg b/Image-Processing/Cartoonify Image/images/sunset.jpg new file mode 100644 index 00000000..92bd2cab Binary files /dev/null and b/Image-Processing/Cartoonify Image/images/sunset.jpg differ