Pycharm Shapes
How to convert a color picture to gray scale or pencil sketch using python :
Biognorics® Gnos® Gnorics® ELFS® logos are registered trademarks. Copyright Autognorics© Inc. iHackRobot®. All Rights Reserved.
Patent Pending. 2000 © ® ==================================================================
import cv2
image = cv2.imread (r"C:\ .... \zeroo.jpg")
scale_percent = 20
width = int(image.shape[1] * scale_percent / 100)
height = int(image.shape[0] * scale_percent / 100)
dsize = (width, height)
resized = cv2.resize(image, dsize, interpolation = cv2.INTER_AREA)
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
inverted_image = 210 - gray_image
blurred = cv2.GaussianBlur(inverted_image, (21, 21), 0)
inverted_blurred = 255 - blurred
pencil_sketch = cv2.divide(gray_image, inverted_blurred, scale=256.0)
zero = cv2.resize(pencil_sketch, dsize, interpolation = cv2.INTER_AREA)
cv2.imshow("Original Image", resized)
cv2.imshow("Pencil Sketch ", zero)
cv2.waitKey(0)
import cv2
import numpy as np
def click_event(event, x, y, flags, params):
if event == cv2.EVENT_LBUTTONDOWN:
points.append((x, y))
cv2.circle(img, (x, y), 4,(0, 255, 0), -1)
if len(points) >= 2:
cv2.line(img, points[-1], points[-2],(0, 255, 255), 5)
cv2.imshow('image', img)
img = np.zeros((512, 512, 3), np.uint8)
points = []
cv2.imshow('image', img)
cv2.setMouseCallback('image', click_event)
cv2.waitKey(0)
cv2.destroyAllWindows()
import cv2
import numpy as np
# img=np.full((100,100,3),255,np.uint8)
img=np.full((400,400,3),255,np.uint8)
img_resize = cv2.resize(img, (400, 400))
pt1 = (30, 30)
pt2 = (200, 120)
color = (0, 0, 255)
color2 = (12, 43, 200)
thickness = 3
# cv2.line(img,(30,30),(70,70),(0,0,255),2)
cv2.line(img_resize, pt1, pt2, color2, thickness)
cv2.line(img, pt1, pt2, color, thickness)
cv2.imshow("Line",img)
cv2.imshow("Model Image", img_resize)
cv2.waitKey(0)
import cv2
import numpy as np
# img=np.full((100,100,3),255,np.uint8)
img=np.full((400,400,3),255,np.uint8)
# img_resize = cv2.resize(img, (400, 400))
points = [[50, 10], [50, 100], [100, 60], [60, 10], [60, 60], [100, 221]]
points = np.array(points)
points = points.reshape((-1, 1, 2))
pt1 = (50, 10)
pt2 = (200, 120)
color = (0, 0, 255)
thickness = 3
isClosed = False
# cv2.line(img,(30,30),(70,70),(0,0,255),2)
cv2.line(img, pt1, pt2, color, thickness)
cv2.imshow("Line",img)
image = cv2.polylines(img, [points], isClosed, color, thickness)
cv2.imshow("image", image)
cv2.waitKey(0)
Disclaimer: We shall not be liable for any loss or damage of whatever nature - direct, indirect, consequential, or otherwise - which may arise as a result of your use of any information on this website. However, if you are interested in using any of the projects for personal or educational purposes, please inform the author by email for guidance and technical support.
Public Domain Notice: Copyright (c) 1988. All rights reserved. This article is part of a book entitled Autognorics. Copies are welcome to be shared or distributed publicly as long proper citations are observed. Please cite as follows: Inscription by Design, Joey Lawsin, 1988, USA.
==================================================================
Patent Pending. 2000 © ®
A L.A.W.S.I.N. Educational Production
Comments
Post a Comment