Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
15de28b0
Commit
15de28b0
authored
Jul 04, 2011
by
Alexander Mordvintsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
turing.py sample added
parent
6be9fbfa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
turing.py
samples/python2/turing.py
+50
-0
No files found.
samples/python2/turing.py
0 → 100644
View file @
15de28b0
'''
Multiscale Turing Patterns generator.
Inspired by http://www.jonathanmccabe.com/Cyclic_Symmetric_Multi-Scale_Turing_Patterns.pdf
'''
import
numpy
as
np
import
cv2
,
cv
from
common
import
draw_str
w
,
h
=
512
,
512
a
=
np
.
zeros
((
h
,
w
,
1
),
np
.
float32
)
cv2
.
randu
(
a
,
np
.
array
([
0
]),
np
.
array
([
1
]))
a
.
shape
=
(
h
,
w
)
def
process_scale
(
a_lods
,
lod
):
d
=
a_lods
[
lod
]
-
cv2
.
pyrUp
(
a_lods
[
lod
+
1
])
for
i
in
xrange
(
lod
):
d
=
cv2
.
pyrUp
(
d
)
v
=
cv2
.
GaussianBlur
(
d
*
d
,
(
3
,
3
),
0
)
return
np
.
sign
(
d
),
v
print
'Generating AVI file. Press ESC to stop.'
out
=
cv2
.
VideoWriter
(
'turing.avi'
,
cv
.
CV_FOURCC
(
*
'DIB '
),
30.0
,
(
w
,
h
),
False
)
scale_num
=
6
frame_num
=
1000
for
frame_i
in
xrange
(
frame_num
):
a_lods
=
[
a
]
for
i
in
xrange
(
scale_num
):
a_lods
.
append
(
cv2
.
pyrDown
(
a_lods
[
-
1
]))
ms
,
vs
=
[],
[]
for
i
in
xrange
(
1
,
scale_num
):
m
,
v
=
process_scale
(
a_lods
,
i
)
ms
.
append
(
m
)
vs
.
append
(
v
)
mi
=
np
.
argmin
(
vs
,
0
)
a
+=
np
.
choose
(
mi
,
ms
)
*
0.025
a
=
(
a
-
a
.
min
())
/
a
.
ptp
()
out
.
write
(
a
)
vis
=
a
.
copy
()
draw_str
(
vis
,
(
20
,
20
),
'frame
%
d /
%
d'
%
(
frame_i
+
1
,
frame_num
))
cv2
.
imshow
(
'a'
,
vis
)
if
cv2
.
waitKey
(
5
)
==
27
:
break
else
:
print
'done'
cv2
.
waitKey
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment