With the learning of this column, you can quickly master how to use Opencv. Please note that for more learning content, please refer to the official documentation. This column is written for novices who are more interested in visual direction, and lead them to do a good job. The basic framework allows them to quickly learn how to call functions through this framework to do the projects they are interested in. At the same time, I am also updating my Opencv project practice column, you can learn together.
Subscribe to this column, (2 messages) Opencv project combat_Summer is the blog of iced black tea - CSDN Blog
MAIN
import cv2
import numpy as np
img = cv2.imread("Resources/lena.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,150,200)
imgDilation = cv2.dilate(imgCanny,kernel,iterations=1)
imgEroded = cv2.erode(imgDilation,kernel,iterations=1)
cv2.imshow("Gray Image",imgGray)
cv2.imshow("Blur Image",imgBlur)
cv2.imshow("Canny Image",imgCanny)
cv2.imshow("Dilation Image",imgDilation)
cv2.imshow("Eroded Image",imgEroded)
cv2.waitKey(0)
Grayscale Image
imgGray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
Convert the original RGB format image to grayscale space, and the pixels only have light and dark degrees.
Gaussian Blur
imgBlur = cv2.GaussianBlur(imgGray,(7,7),0)
We add Gaussian blur, and we can clearly find the difference between it and the grayscale image, which is indeed blurry.
Canny Edge detection
imgCanny = cv2.Canny(img,150,200)
Canny detection is better than other detections in edge detection.
Image Dilation
imgDilation = cv2.dilate(imgCanny,kernel,iterations=1)
This is the expansion of image processing. Under the modification of the image after Canny detection, its edge lines become thicker
Eroded Image
imgEroded = cv2.erode(imgDilation,kernel,iterations=1)
Under the expanded picture, image erosion is performed.
I believe that you have initially learned about the five basic functions of Opencv, which are quite common in our actual combat projects. Welcome to my community, and we will learn together. Iced Tea Community-CSDN Community Cloud