This repository was archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 212
Added Cartoonify Image Code #220
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a1dd103
Merge pull request #1 from ankitdobhal/master
sharur7 b32d45b
Cartoonifying_Image
sharur7 2d9c1ad
Create README.md
sharur7 96f4d6c
Update README.md
sharur7 c0883ba
Update README.md
sharur7 104e0ab
Update README.md
sharur7 4a8c2c0
Update README.md
sharur7 e4e3fe6
Update Cartoonify.py
sharur7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# 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) | ||
sharur7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
|
||
|
||
sharur7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# 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() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.