Pycharm open CV learning 3

Eddie Chen
May 28, 2021

--

基本模式功能

How do we make picture colorful to black&white

  1. make a file to restore the picture
  2. your need to make file(resouces)
  3. saving pic “2.png” in the resources
import cv2

img = cv2.imread("resources/2.png")
imgGray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

cv2.imshow("G img",imgGray)

cv2.waitKey(0)

How to make Blur pic

you just need add some code

import cv2

img = cv2.imread("resources/2.png")
imgGray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
imgBlur = cv2.GaussianBlur(imgGray,(7,7),0)

cv2.imshow("G img",imgGray)
cv2.imshow("blur img",imgBlur)
cv2.waitKey(0)

make canny code (cure line)

import cv2

img = cv2.imread("resources/2.png")
imgGray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
imgBlur = cv2.GaussianBlur(imgGray,(7,7),0)
imgCanny = cv2.Canny(img,50,50)

cv2.imshow("G img",imgGray)
cv2.imshow("blur img",imgBlur)
cv2.imshow("canny img",imgCanny)
cv2.waitKey(0)
import cv2
import numpy as np

img = cv2.imread("resources/2.png")

kernel = np.ones((5,5),np.uint8)
imgGray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
imgBlur = cv2.GaussianBlur(imgGray,(7,7),0)
imgCanny = cv2.Canny(img,50,50)
imgDialation = cv2.dilate(imgCanny,kernel,iterations=10)

cv2.imshow("G img",imgGray)
cv2.imshow("blur img",imgBlur)
cv2.imshow("canny img",imgCanny)
cv2.imshow("Dialtation img",imgDialation)
cv2.waitKey(0)

you can change eage to big

--

--

No responses yet