korsygfhrtzangaiide
Elepffwdsff
/
usr
/
share
/
doc
/
python-docs-2.7.5
/
html
/
library
/
Upload FileeE
HOME
<!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>21.2. imageop — Manipulate raw image data — Python 2.7.5 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: '2.7.5', 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> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.5 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.5 documentation" href="../index.html" /> <link rel="up" title="21. Multimedia Services" href="mm.html" /> <link rel="next" title="21.3. aifc — Read and write AIFF and AIFC files" href="aifc.html" /> <link rel="prev" title="21.1. audioop — Manipulate raw audio data" href="audioop.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </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="aifc.html" title="21.3. aifc — Read and write AIFF and AIFC files" accesskey="N">next</a> |</li> <li class="right" > <a href="audioop.html" title="21.1. audioop — Manipulate raw audio data" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="mm.html" accesskey="U">21. Multimedia Services</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-imageop"> <span id="imageop-manipulate-raw-image-data"></span><h1>21.2. <a class="reference internal" href="#module-imageop" title="imageop: Manipulate raw image data. (deprecated)"><tt class="xref py py-mod docutils literal"><span class="pre">imageop</span></tt></a> — Manipulate raw image data<a class="headerlink" href="#module-imageop" title="Permalink to this headline">¶</a></h1> <p class="deprecated"> <span class="versionmodified">Deprecated since version 2.6: </span>The <a class="reference internal" href="#module-imageop" title="imageop: Manipulate raw image data. (deprecated)"><tt class="xref py py-mod docutils literal"><span class="pre">imageop</span></tt></a> module has been removed in Python 3.</p> <p>The <a class="reference internal" href="#module-imageop" title="imageop: Manipulate raw image data. (deprecated)"><tt class="xref py py-mod docutils literal"><span class="pre">imageop</span></tt></a> module contains some useful operations on images. It operates on images consisting of 8 or 32 bit pixels stored in Python strings. This is the same format as used by <tt class="xref py py-func docutils literal"><span class="pre">gl.lrectwrite()</span></tt> and the <a class="reference internal" href="imgfile.html#module-imgfile" title="imgfile: Support for SGI imglib files. (deprecated) (IRIX)"><tt class="xref py py-mod docutils literal"><span class="pre">imgfile</span></tt></a> module.</p> <p>The module defines the following variables and functions:</p> <dl class="exception"> <dt id="imageop.error"> <em class="property">exception </em><tt class="descclassname">imageop.</tt><tt class="descname">error</tt><a class="headerlink" href="#imageop.error" title="Permalink to this definition">¶</a></dt> <dd><p>This exception is raised on all errors, such as unknown number of bits per pixel, etc.</p> </dd></dl> <dl class="function"> <dt id="imageop.crop"> <tt class="descclassname">imageop.</tt><tt class="descname">crop</tt><big>(</big><em>image</em>, <em>psize</em>, <em>width</em>, <em>height</em>, <em>x0</em>, <em>y0</em>, <em>x1</em>, <em>y1</em><big>)</big><a class="headerlink" href="#imageop.crop" title="Permalink to this definition">¶</a></dt> <dd><p>Return the selected part of <em>image</em>, which should be <em>width</em> by <em>height</em> in size and consist of pixels of <em>psize</em> bytes. <em>x0</em>, <em>y0</em>, <em>x1</em> and <em>y1</em> are like the <tt class="xref py py-func docutils literal"><span class="pre">gl.lrectread()</span></tt> parameters, i.e. the boundary is included in the new image. The new boundaries need not be inside the picture. Pixels that fall outside the old image will have their value set to zero. If <em>x0</em> is bigger than <em>x1</em> the new image is mirrored. The same holds for the y coordinates.</p> </dd></dl> <dl class="function"> <dt id="imageop.scale"> <tt class="descclassname">imageop.</tt><tt class="descname">scale</tt><big>(</big><em>image</em>, <em>psize</em>, <em>width</em>, <em>height</em>, <em>newwidth</em>, <em>newheight</em><big>)</big><a class="headerlink" href="#imageop.scale" title="Permalink to this definition">¶</a></dt> <dd><p>Return <em>image</em> scaled to size <em>newwidth</em> by <em>newheight</em>. No interpolation is done, scaling is done by simple-minded pixel duplication or removal. Therefore, computer-generated images or dithered images will not look nice after scaling.</p> </dd></dl> <dl class="function"> <dt id="imageop.tovideo"> <tt class="descclassname">imageop.</tt><tt class="descname">tovideo</tt><big>(</big><em>image</em>, <em>psize</em>, <em>width</em>, <em>height</em><big>)</big><a class="headerlink" href="#imageop.tovideo" title="Permalink to this definition">¶</a></dt> <dd><p>Run a vertical low-pass filter over an image. It does so by computing each destination pixel as the average of two vertically-aligned source pixels. The main use of this routine is to forestall excessive flicker if the image is displayed on a video device that uses interlacing, hence the name.</p> </dd></dl> <dl class="function"> <dt id="imageop.grey2mono"> <tt class="descclassname">imageop.</tt><tt class="descname">grey2mono</tt><big>(</big><em>image</em>, <em>width</em>, <em>height</em>, <em>threshold</em><big>)</big><a class="headerlink" href="#imageop.grey2mono" title="Permalink to this definition">¶</a></dt> <dd><p>Convert a 8-bit deep greyscale image to a 1-bit deep image by thresholding all the pixels. The resulting image is tightly packed and is probably only useful as an argument to <a class="reference internal" href="#imageop.mono2grey" title="imageop.mono2grey"><tt class="xref py py-func docutils literal"><span class="pre">mono2grey()</span></tt></a>.</p> </dd></dl> <dl class="function"> <dt id="imageop.dither2mono"> <tt class="descclassname">imageop.</tt><tt class="descname">dither2mono</tt><big>(</big><em>image</em>, <em>width</em>, <em>height</em><big>)</big><a class="headerlink" href="#imageop.dither2mono" title="Permalink to this definition">¶</a></dt> <dd><p>Convert an 8-bit greyscale image to a 1-bit monochrome image using a (simple-minded) dithering algorithm.</p> </dd></dl> <dl class="function"> <dt id="imageop.mono2grey"> <tt class="descclassname">imageop.</tt><tt class="descname">mono2grey</tt><big>(</big><em>image</em>, <em>width</em>, <em>height</em>, <em>p0</em>, <em>p1</em><big>)</big><a class="headerlink" href="#imageop.mono2grey" title="Permalink to this definition">¶</a></dt> <dd><p>Convert a 1-bit monochrome image to an 8 bit greyscale or color image. All pixels that are zero-valued on input get value <em>p0</em> on output and all one-value input pixels get value <em>p1</em> on output. To convert a monochrome black-and-white image to greyscale pass the values <tt class="docutils literal"><span class="pre">0</span></tt> and <tt class="docutils literal"><span class="pre">255</span></tt> respectively.</p> </dd></dl> <dl class="function"> <dt id="imageop.grey2grey4"> <tt class="descclassname">imageop.</tt><tt class="descname">grey2grey4</tt><big>(</big><em>image</em>, <em>width</em>, <em>height</em><big>)</big><a class="headerlink" href="#imageop.grey2grey4" title="Permalink to this definition">¶</a></dt> <dd><p>Convert an 8-bit greyscale image to a 4-bit greyscale image without dithering.</p> </dd></dl> <dl class="function"> <dt id="imageop.grey2grey2"> <tt class="descclassname">imageop.</tt><tt class="descname">grey2grey2</tt><big>(</big><em>image</em>, <em>width</em>, <em>height</em><big>)</big><a class="headerlink" href="#imageop.grey2grey2" title="Permalink to this definition">¶</a></dt> <dd><p>Convert an 8-bit greyscale image to a 2-bit greyscale image without dithering.</p> </dd></dl> <dl class="function"> <dt id="imageop.dither2grey2"> <tt class="descclassname">imageop.</tt><tt class="descname">dither2grey2</tt><big>(</big><em>image</em>, <em>width</em>, <em>height</em><big>)</big><a class="headerlink" href="#imageop.dither2grey2" title="Permalink to this definition">¶</a></dt> <dd><p>Convert an 8-bit greyscale image to a 2-bit greyscale image with dithering. As for <a class="reference internal" href="#imageop.dither2mono" title="imageop.dither2mono"><tt class="xref py py-func docutils literal"><span class="pre">dither2mono()</span></tt></a>, the dithering algorithm is currently very simple.</p> </dd></dl> <dl class="function"> <dt id="imageop.grey42grey"> <tt class="descclassname">imageop.</tt><tt class="descname">grey42grey</tt><big>(</big><em>image</em>, <em>width</em>, <em>height</em><big>)</big><a class="headerlink" href="#imageop.grey42grey" title="Permalink to this definition">¶</a></dt> <dd><p>Convert a 4-bit greyscale image to an 8-bit greyscale image.</p> </dd></dl> <dl class="function"> <dt id="imageop.grey22grey"> <tt class="descclassname">imageop.</tt><tt class="descname">grey22grey</tt><big>(</big><em>image</em>, <em>width</em>, <em>height</em><big>)</big><a class="headerlink" href="#imageop.grey22grey" title="Permalink to this definition">¶</a></dt> <dd><p>Convert a 2-bit greyscale image to an 8-bit greyscale image.</p> </dd></dl> <dl class="data"> <dt id="imageop.backward_compatible"> <tt class="descclassname">imageop.</tt><tt class="descname">backward_compatible</tt><a class="headerlink" href="#imageop.backward_compatible" title="Permalink to this definition">¶</a></dt> <dd><p>If set to 0, the functions in this module use a non-backward compatible way of representing multi-byte pixels on little-endian systems. The SGI for which this module was originally written is a big-endian system, so setting this variable will have no effect. However, the code wasn’t originally intended to run on anything else, so it made assumptions about byte order which are not universal. Setting this variable to 0 will cause the byte order to be reversed on little-endian systems, so that it then is the same as on big-endian systems.</p> </dd></dl> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="audioop.html" title="previous chapter">21.1. <tt class="docutils literal"><span class="pre">audioop</span></tt> — Manipulate raw audio data</a></p> <h4>Next topic</h4> <p class="topless"><a href="aifc.html" title="next chapter">21.3. <tt class="docutils literal"><span class="pre">aifc</span></tt> — Read and write AIFF and AIFC files</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/imageop.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" /> <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="aifc.html" title="21.3. aifc — Read and write AIFF and AIFC files" >next</a> |</li> <li class="right" > <a href="audioop.html" title="21.1. audioop — Manipulate raw audio data" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="mm.html" >21. Multimedia Services</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2019, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Jul 03, 2019. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>