Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
ZX1aoF
opencv_tutorial
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
opencv_tutorial
/
test05_blur.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
41 lines (31 loc) · 1.92 KB
main
Breadcrumbs
opencv_tutorial
/
test05_blur.py
Copy path
Top
File metadata and controls
Code
Blame
41 lines (31 loc) · 1.92 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 图形的滤波
import
cv2
image
=
cv2
.
imread
(
"plane.jpg"
)
# 使用高斯滤波器
gauss
=
cv2
.
GaussianBlur
(
image
, (
5
,
5
),
0
)
# 使用均值滤波器
median
=
cv2
.
medianBlur
(
image
,
5
)
cv2
.
imshow
(
"image"
,
image
)
cv2
.
imshow
(
"gauss"
,
gauss
)
cv2
.
imshow
(
"median"
,
median
)
cv2
.
waitKey
()
'''
高斯滤波(Gaussian Blur)和均值滤波(Mean Blur)都是图像处理中常用的平滑技术,它们用于减少图像噪声、模糊图像边缘或细节,以及进行图像预处理。
选择使用哪种滤波方法取决于具体的应用场景和需求。
均值滤波:
简单易实现,对所有像素的邻域内的像素值求平均。
对于去除随机噪声(如椒盐噪声)效果较好。
对图像的边缘和细节的模糊程度较高,可能导致图像质量下降。
高斯滤波:
使用高斯分布作为权重,对邻域内的像素进行加权平均。
对图像的边缘和细节的模糊程度较低,通常能更好地保留图像的结构信息。
实现相对复杂,需要计算高斯核的权重。
在实际应用中,高斯滤波通常更受欢迎,因为它在平滑图像的同时能更好地保留图像的边缘和细节。
然而,如果处理速度是一个关键因素,均值滤波由于其简单性可能会更快。此外,对于某些特定的噪声类型,均值滤波可能更有效。
在决定使用哪种滤波方法时,可以考虑以下因素:
图像内容:如果图像中包含重要的边缘信息,高斯滤波可能更合适。
噪声类型:如果主要是随机噪声,均值滤波可能更有效。
实现复杂度:如果需要快速实现,均值滤波可能更简单。
性能要求:如果对图像质量有较高要求,高斯滤波通常能提供更好的结果。
在某些情况下,也可以结合使用这两种滤波方法,或者尝试其他类型的滤波器,如双边滤波(Bilateral Filter),它在平滑图像的同时能更好地保留边缘。
'''
You can’t perform that action at this time.