135 lines
7.5 KiB
HTML
135 lines
7.5 KiB
HTML
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<title>Displaying images and video — pyqtgraph v1.8 documentation</title>
|
|
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: '',
|
|
VERSION: '1.8',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
<link rel="top" title="pyqtgraph v1.8 documentation" href="index.html" />
|
|
<link rel="next" title="Line, Fill, and Color" href="style.html" />
|
|
<link rel="prev" title="Plotting in pyqtgraph" href="plotting.html" />
|
|
</head>
|
|
<body>
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="genindex.html" title="General Index"
|
|
accesskey="I">index</a></li>
|
|
<li class="right" >
|
|
<a href="py-modindex.html" title="Python Module Index"
|
|
>modules</a> |</li>
|
|
<li class="right" >
|
|
<a href="style.html" title="Line, Fill, and Color"
|
|
accesskey="N">next</a> |</li>
|
|
<li class="right" >
|
|
<a href="plotting.html" title="Plotting in pyqtgraph"
|
|
accesskey="P">previous</a> |</li>
|
|
<li><a href="index.html">pyqtgraph v1.8 documentation</a> »</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body">
|
|
|
|
<div class="section" id="displaying-images-and-video">
|
|
<h1>Displaying images and video<a class="headerlink" href="#displaying-images-and-video" title="Permalink to this headline">¶</a></h1>
|
|
<p>Pyqtgraph displays 2D numpy arrays as images and provides tools for determining how to translate between the numpy data type and RGB values on the screen. If you want to display data from common image and video file formats, you will need to load the data first using another library (PIL works well for images and built-in numpy conversion).</p>
|
|
<p>The easiest way to display 2D or 3D data is using the <a class="reference internal" href="functions.html#pyqtgraph.image" title="pyqtgraph.image"><tt class="xref py py-func docutils literal"><span class="pre">pyqtgraph.image()</span></tt></a> function:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">pyqtgraph</span> <span class="kn">as</span> <span class="nn">pg</span>
|
|
<span class="n">pg</span><span class="o">.</span><span class="n">image</span><span class="p">(</span><span class="n">imageData</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>This function will accept any floating-point or integer data types and displays a single <a class="reference internal" href="widgets/imageview.html#pyqtgraph.ImageView" title="pyqtgraph.ImageView"><tt class="xref py py-class docutils literal"><span class="pre">ImageView</span></tt></a> widget containing your data. This widget includes controls for determining how the image data will be converted to 32-bit RGBa values. Conversion happens in two steps (both are optional):</p>
|
|
<ol class="arabic simple">
|
|
<li>Scale and offset the data (by selecting the dark/light levels on the displayed histogram)</li>
|
|
<li>Convert the data to color using a lookup table (determined by the colors shown in the gradient editor)</li>
|
|
</ol>
|
|
<p>If the data is 3D (time, x, y), then a time axis will be shown with a slider that can set the currently displayed frame. (if the axes in your data are ordered differently, use numpy.transpose to rearrange them)</p>
|
|
<p>There are a few other methods for displaying images as well:</p>
|
|
<ul class="simple">
|
|
<li>The <a class="reference internal" href="widgets/imageview.html#pyqtgraph.ImageView" title="pyqtgraph.ImageView"><tt class="xref py py-class docutils literal"><span class="pre">ImageView</span></tt></a> class can also be instantiated directly and embedded in Qt applications.</li>
|
|
<li>Instances of <a class="reference internal" href="graphicsItems/imageitem.html#pyqtgraph.ImageItem" title="pyqtgraph.ImageItem"><tt class="xref py py-class docutils literal"><span class="pre">ImageItem</span></tt></a> can be used inside a GraphicsView.</li>
|
|
<li>For higher performance, use <a class="reference internal" href="widgets/rawimagewidget.html#pyqtgraph.RawImageWidget" title="pyqtgraph.RawImageWidget"><tt class="xref py py-class docutils literal"><span class="pre">RawImageWidget</span></tt></a>.</li>
|
|
</ul>
|
|
<p>Any of these classes are acceptable for displaying video by calling setImage() to display a new frame. To increase performance, the image processing system uses scipy.weave to produce compiled libraries. If your computer has a compiler available, weave will automatically attempt to build the libraries it needs on demand. If this fails, then the slower pure-python methods will be used instead.</p>
|
|
<p>For more information, see the classes listed above and the ‘VideoSpeedTest’, ‘ImageItem’, ‘ImageView’, and ‘HistogramLUT’ <a class="reference internal" href="introduction.html#examples"><em>Examples</em></a>.</p>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar">
|
|
<div class="sphinxsidebarwrapper">
|
|
<h4>Previous topic</h4>
|
|
<p class="topless"><a href="plotting.html"
|
|
title="previous chapter">Plotting in pyqtgraph</a></p>
|
|
<h4>Next topic</h4>
|
|
<p class="topless"><a href="style.html"
|
|
title="next chapter">Line, Fill, and Color</a></p>
|
|
<h3>This Page</h3>
|
|
<ul class="this-page-menu">
|
|
<li><a href="_sources/images.txt"
|
|
rel="nofollow">Show Source</a></li>
|
|
</ul>
|
|
<div id="searchbox" style="display: none">
|
|
<h3>Quick search</h3>
|
|
<form class="search" action="search.html" method="get">
|
|
<input type="text" name="q" size="18" />
|
|
<input type="submit" value="Go" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
<p class="searchtip" style="font-size: 90%">
|
|
Enter search terms or a module, class or function name.
|
|
</p>
|
|
</div>
|
|
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="genindex.html" title="General Index"
|
|
>index</a></li>
|
|
<li class="right" >
|
|
<a href="py-modindex.html" title="Python Module Index"
|
|
>modules</a> |</li>
|
|
<li class="right" >
|
|
<a href="style.html" title="Line, Fill, and Color"
|
|
>next</a> |</li>
|
|
<li class="right" >
|
|
<a href="plotting.html" title="Plotting in pyqtgraph"
|
|
>previous</a> |</li>
|
|
<li><a href="index.html">pyqtgraph v1.8 documentation</a> »</li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer">
|
|
© Copyright 2011, Luke Campagnola.
|
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
|
|
</div>
|
|
</body>
|
|
</html> |