FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
opencv_tutorials/python/code_025/opencv_025.py at master · HZHCoder1990/opencv_tutorials · GitHub
HZHCoder1990
/
opencv_tutorials
Public
forked from
JimmyHHua/opencv_tutorials
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
opencv_tutorials
/
python
/
code_025
/
opencv_025.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (36 loc) · 1.07 KB
Breadcrumbs
opencv_tutorials
/
python
/
code_025
/
opencv_025.py
Copy path
File metadata and controls
53 lines (36 loc) · 1.07 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
41
42
43
44
45
46
47
import
cv2
as
cv
import
cv2
as
cv
import
numpy
as
np
def
add_salt_pepper_noise
(
image
):
h
,
w
=
image
.
shape
[:
2
]
nums
=
10000
rows
=
np
.
random
.
randint
(
0
,
h
,
nums
,
dtype
=
np
.
int
)
cols
=
np
.
random
.
randint
(
0
,
w
,
nums
,
dtype
=
np
.
int
)
for
i
in
range
(
nums
):
if
i
%
2
==
1
:
image
[
rows
[
i
],
cols
[
i
]]
=
(
255
,
255
,
255
)
else
:
image
[
rows
[
i
],
cols
[
i
]]
=
(
0
,
0
,
0
)
return
image
def
gaussian_noise
(
image
):
noise
=
np
.
zeros
(
image
.
shape
,
image
.
dtype
)
m
=
(
15
,
15
,
15
)
s
=
(
30
,
30
,
30
)
cv
.
randn
(
noise
,
m
,
s
)
dst
=
cv
.
add
(
image
,
noise
)
cv
.
imshow
(
"gaussian noise"
,
dst
)
return
dst
src
=
cv
.
imread
(
"./test.png"
)
cv
.
imshow
(
"input"
,
src
)
h
,
w
=
src
.
shape
[:
2
]
src
=
gaussian_noise
(
src
)
result1
=
cv
.
blur
(
src
, (
5
,
5
))
cv
.
imshow
(
"result-1"
,
result1
)
result2
=
cv
.
GaussianBlur
(
src
, (
5
,
5
),
0
)
cv
.
imshow
(
"result-2"
,
result2
)
result3
=
cv
.
medianBlur
(
src
,
5
)
cv
.
imshow
(
"result-3"
,
result3
)
result4
=
cv
.
fastNlMeansDenoisingColored
(
src
,
None
,
15
,
15
,
10
,
30
)
cv
.
imshow
(
"result-4"
,
result4
)
cv
.
waitKey
(
0
)
cv
.
destroyAllWindows
()
Back
|
FazBrowse Home
|
New Git URL