Last active
December 1, 2021 12:33
-
-
Save HilarioJuniorNengare/0b0c8cf4d33684b0af36f2b3d7798b65 to your computer and use it in GitHub Desktop.
This file contains 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
# include the cv2 module with literal name cv | |
import cv2 as cv | |
def main(): | |
# paste absolute path of source image inside the single quotes | |
img = cv.imread(r" ") | |
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) | |
gray = cv.medianBlur(gray, 5) | |
mask = cv.adaptiveThreshold( | |
gray, 255, cv.ADAPTIVE_THRESH_MEAN_C, cv.THRESH_BINARY, 9, 9) | |
# mask = cv.threshold(img, 157, 255, cv.THRESH_TOZERO) | |
# cartoonisation part | |
color = cv.bilateralFilter(img, 9, 250, 250) | |
cartoon = cv.bitwise_and(color, color, mask=mask) | |
cv.imshow("image", img) | |
cv.imshow("Edited", mask) | |
cv.waitKey(0) | |
cv.destroyAllWindows() | |
return 0 | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment