当前位置:网站首页>Opencv learning Day6
Opencv learning Day6
2022-07-26 00:16:00 【SKYWALKERS_ two thousand three hundred and ninety-seven】
Open operation and closed operation
import cv2
import numpy as np
img = cv2.imread('qing.jpg')
# open : Corrode first , Re expansion
kernel = np.ones((5, 5), np.uint8)
opening = cv2.morphologyEx(img,cv2.MORPH_OPEN, kernel)
cv2.imshow('opening', opening)
# close : Inflate first , Corrode again
kernel = np.ones((5, 5), np.uint8)
closing = cv2.morphologyEx(img,cv2.MORPH_CLOSE, kernel)
cv2.imshow('closing', closing)
cv2.waitKey(0)
cv2.destroyAllWindows()
Gradient operation
Actually, it is the expansion operation minus the corrosion operation , Can get the boundary
import cv2
import numpy as np
img = cv2.imread('qing.jpg')
kernel = np.ones((9, 9),np.uint8)# Determine the scope of each corrosion
erosion = cv2.erode(img,kernel,iterations = 1)#iterations For the number of iterations , More iterations , The deeper the corrosion
dilate = cv2.dilate(erosion,kernel,iterations = 1)#iterations For the number of iterations , More iterations , The deeper the corrosion
res = np.hstack((dilate,erosion))
cv2.imshow('res', res)
gradient = cv2.morphologyEx(img,cv2.MORPH_GRADIENT, kernel)
cv2.imshow('gradient', gradient)
cv2.waitKey(0)
cv2.destroyAllWindows()


Bowler hat and black box
formal hat : Raw input - The result of the open operation is
Black box : Closed operation - Raw input
import cv2
import numpy as np
img = cv2.imread('qing.jpg')
kernel = np.ones((21, 21),np.uint8)# Determine the scope of each corrosion
tophat = cv2.morphologyEx(img,cv2.MORPH_TOPHAT, kernel)
cv2.imshow('tophat', tophat)
blackhat = cv2.morphologyEx(img, cv2.MORPH_BLACKHAT, kernel)
cv2.imshow('blackhat', blackhat)
cv2.waitKey(0)
cv2.destroyAllWindows()


边栏推荐
- 牛市还没有结束,还有下半场 2021-05-18
- letfaw
- Recent impressions about bull market and defi 2021-05-17
- IP核:PLL
- Representation and implementation of stack (C language)
- SHIB(柴犬币)一月涨幅数百倍,百倍币需具备哪些核心要素?2021-05-09
- NVIDIA可编程推理加速器TensorRT学习笔记(三)——加速推理
- This time, thoroughly understand promise principle
- CountDownLatch
- Android solves the risk of database injection vulnerability
猜你喜欢

07_ue4进阶_发射火球扣mp值和攻击扣血机制

NVIDIA cudnn learning

Duplicate disk: recommended system - negative sampling strategy

栈的表示和实现(C语言)

Redirection and request forwarding

Js理解之路:什么是原型链

NVIDIA programmable reasoning accelerator tensorrt learning notes (III) -- Accelerating reasoning

Leetcode high frequency question 66. add one, give you an array to represent numbers, then add one to return the result

牛市还没有结束,还有下半场 2021-05-18

Piziheng embedded: the method of making source code into lib Library under MCU Xpress IDE and its difference with IAR and MDK
随机推荐
试除法--3的幂
07_ue4进阶_发射火球扣mp值和攻击扣血机制
Linked list related methods
"Demons dance", is the bull market over? 2021-05-13
matlab实时作出串口输出数据的图像
MySQL——数据库日志
OPENCV学习DAY6
Binary tree -- 257. All paths of binary tree
网站服务器停止响应是什么意思?
牛血清蛋白修饰酚酸类及生物碱类小分子/偶联微球的蛋白/牛红细胞SOD的研究
Leetcode question brushing series -- 931. Minimum sum of descent path
STM32 lighting procedure
Leetcode high frequency question 66. add one, give you an array to represent numbers, then add one to return the result
“群魔乱舞”,牛市是不是结束了?2021-05-13
Piziheng embedded: the method of making source code into lib Library under MCU Xpress IDE and its difference with IAR and MDK
STM32 timer
Understanding of "dbdnet: a deep boosting strategy for imagedenoising"
LeetCode高频题66. 加一,给你一个数组表示数字,则加1返回结果
Android solves the risk of database injection vulnerability
Binary tree 101. Symmetric binary tree