当前位置:网站首页>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
边栏推荐
- [IELTS speaking] Anna's oral learning records Part3
- Rainbow version 5.6 was released, adding a variety of installation methods and optimizing the topology operation experience
- Rainbow combines neuvector to practice container safety management
- Kotlin combines flatmap for filtering and zip merge operators
- Domain specific language / DSL in kotlin
- One click installation of highly available Nacos clusters in rainbow
- Transformation function map and flatmap in kotlin
- Use of out covariance and in inversion in kotlin
- Avatary's livedriver trial experience
- 单场带货涨粉10万,农村主播竟将男装卖爆单?
猜你喜欢
Splunk子查询模糊匹配csv中字段值为*
Avatary's livedriver trial experience
JS复制图片到剪切板 读取剪切板
Automatic upgrading of database structure in rainbow
探索STEAM艺术设计中的创造力
eBPF Cilium实战(1) - 基于团队的网络隔离
Vulnerability recurrence easy_ tornado
Wang Zijian: is the NFT of Tencent magic core worth buying?
拓维信息使用 Rainbond 的云原生落地实践
饥荒云服管理脚本
随机推荐
Call pytorch API to complete linear regression
BiSeNet的特点
Caractéristiques de bisenet
JS copy picture to clipboard read clipboard
Use of out covariance and in inversion in kotlin
Register of assembly language by Wang Shuang
【雅思口语】安娜口语学习记录 Part2
Analysis of maker education in innovative education system
Splunk查询csv lookup table数据动态查询
One click installation of highly available Nacos clusters in rainbow
Bayes' law
buureservewp(2)
Analyzing the influence of robot science and technology development concept on Social Research
BiSeNet的特點
Leetcode simple question: find the K beauty value of a number
Four items that should be included in the management system of integral mall
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
Learn how to compile basic components of rainbow from the source code
CDC (change data capture technology), a powerful tool for real-time database synchronization
ZCMU--1492: Problem D(C语言)