Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
total_control_app
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Drechsler
total_control_app
Commits
9b046dd7
Commit
9b046dd7
authored
May 17, 2019
by
Martin Drechsler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
imageview example added
parent
0d88326f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
0 deletions
+72
-0
imageview_example.py
examples/imageview_example.py
+72
-0
No files found.
examples/imageview_example.py
0 → 100644
View file @
9b046dd7
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 16 22:28:58 2019
@author: martindrech
"""
# -*- coding: utf-8 -*-
"""
Demonstrates very basic use of ImageItem to display image data inside a ViewBox.
"""
## Add path to library (just for examples; you do not need this)
from
pyqtgraph.Qt
import
QtCore
,
QtGui
import
numpy
as
np
import
pyqtgraph
as
pg
import
pyqtgraph.ptime
as
ptime
def
_twoD_gaussian
(
lim
=
10
,
sigma
=
1
,
x0
=
0
,
y0
=
0
):
N
=
600
x
,
y
=
np
.
meshgrid
(
np
.
linspace
(
-
lim
,
lim
,
N
),
np
.
linspace
(
-
lim
,
lim
,
N
))
d
=
np
.
sqrt
((
x
-
x0
)
**
2
+
(
y
-
y0
)
**
2
)
g
=
np
.
exp
(
-
((
d
)
**
2
/
(
2.0
*
sigma
**
2
)))
noise
=
np
.
random
.
normal
(
size
=
(
N
,
N
))
/
10
return
g
+
noise
app
=
QtGui
.
QApplication
([])
## Create window with ImageView widget
win
=
QtGui
.
QMainWindow
()
win
.
resize
(
800
,
800
)
imv
=
pg
.
ImageView
()
win
.
setCentralWidget
(
imv
)
win
.
show
()
win
.
setWindowTitle
(
'pyqtgraph example: ImageView'
)
## Create random image
data
=
np
.
asarray
([
_twoD_gaussian
()
for
i
in
range
(
50
)])
i
=
0
updateTime
=
ptime
.
time
()
fps
=
0
def
updateData
():
global
img
,
data
,
i
,
updateTime
,
fps
## Display the data
imv
.
setImage
(
data
[
i
],
autoHistogramRange
=
False
,
autoLevels
=
False
,
autoRange
=
False
)
i
=
(
i
+
1
)
%
data
.
shape
[
0
]
QtCore
.
QTimer
.
singleShot
(
1
,
updateData
)
now
=
ptime
.
time
()
fps2
=
1.0
/
(
now
-
updateTime
)
updateTime
=
now
fps
=
fps
*
0.9
+
fps2
*
0.1
#print "%0.1f fps" % fps
updateData
()
## Start Qt event loop unless running in interactive mode.
if
__name__
==
'__main__'
:
import
sys
if
(
sys
.
flags
.
interactive
!=
1
)
or
not
hasattr
(
QtCore
,
'PYQT_VERSION'
):
QtGui
.
QApplication
.
instance
()
.
exec_
()
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