当前位置:网站首页>Opencv learning note 5 - gradient calculation / edge detection
Opencv learning note 5 - gradient calculation / edge detection
2022-07-07 08:23:00 【I am a little rice】
To get the outline , An image can be expanded first and then corroded , Then the result of expansion minus the result of corrosion .
1. Sobel
operator
dst = cv2.Sobel(src, ddepth, dx, dy, ksize)
ddepth
: The depth of the imagedx
nucleusdy
Horizontal and vertical directions respectivelyksize
yesSobel
Operator size
image1 = cv2.imread('./ro.png')
plt.imshow(image1);
image1 = cv2.imread('./ro.png')
plt.imshow(image1);
image2 = cv2.Sobel(image1, cv2.CV_64F, 1, 0, ksize=3)
plt.imshow(image2);
The convolution calculation from white to black is positive , The convolution calculation from black to white is negative , All negative numbers will be truncated to 0
, So take the absolute value
Calculation x
Direction gradient
image2 = cv2.Sobel(image1, cv2.CV_64F, 1, 0, ksize=3)
image2 = cv2.convertScaleAbs(image2)
plt.imshow(image2);
Calculation x
Direction gradient
image3 = cv2.Sobel(image1, cv2.CV_64F, 0, 1, ksize=3)
image3 = cv2.convertScaleAbs(image3)
plt.imshow(image3);
Get the outline of the image
image4 = cv2.addWeighted(image2, 0.5, image3, 0.5, 0)
plt.imshow(image4);
Try another picture
import cv2
import matplotlib.pyplot as plt
image = cv2.imread('image.png')
image2 = cv2.Sobel(image, cv2.CV_64F, 1, 0, ksize=3)
image2 = cv2.convertScaleAbs(image2)
image3 = cv2.Sobel(image, cv2.CV_64F, 0, 1, ksize=3)
image3 = cv2.convertScaleAbs(image3)
image4 = cv2.addWeighted(image2, 0.5, image3, 0.5, 0)
image4 = cv2.cvtColor(image4, cv2.COLOR_BGR2RGB)
plt.imshow(image4);
2. Scharr
operator
The usage is the same , But the calculated value will be relatively large , Will be more sensitive
3. laplacian
operator
边栏推荐
- Explore creativity in steam art design
- CTF-WEB shrine模板注入nmap的基本使用
- Leetcode simple question: find the K beauty value of a number
- Xcit learning notes
- Make LIVELINK's initial pose consistent with that of the mobile capture actor
- CCTV is so warm-hearted that it teaches you to write HR's favorite resume hand in hand
- Give full play to the wide practicality of maker education space
- Pytoch (VI) -- model tuning tricks
- Rainbow combines neuvector to practice container safety management
- DeiT学习笔记
猜你喜欢
Ebpf cilium practice (1) - team based network isolation
The largest 3 same digits in the string of leetcode simple question
Game attack and defense world reverse
[quick start of Digital IC Verification] 13. SystemVerilog interface and program learning
Unityhub cracking & unity cracking
Interactive book delivery - signed version of Oracle DBA work notes
Lua programming learning notes
Quick analysis of Intranet penetration helps the foreign trade management industry cope with a variety of challenges
船载雷达天线滑环的使用
Learn how to compile basic components of rainbow from the source code
随机推荐
藏书馆App基于Rainbond实现云原生DevOps的实践
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
Vulnerability recurrence easy_ tornado
ZCMU--1492: Problem D(C语言)
Full text query classification
【雅思口语】安娜口语学习记录 Part3
Blob object introduction
PVTV2--Pyramid Vision TransformerV2学习笔记
【Go ~ 0到1 】 第七天 获取时间戳,时间比较,时间格式转换,Sleep与定时器
Excel import function of jeesite form page
Domain specific language / DSL in kotlin
Avatary's livedriver trial experience
The reified keyword in kotlin is used for generics
SSM 整合
eBPF Cilium实战(2) - 底层网络可观测性
【无标题】
Leetcode medium question my schedule I
Caractéristiques de bisenet
Obsidan之数学公式的输入
The use of generics and vararg variable parameters in kotlin