<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module telemetry.util.image_util</title>
<meta charset="utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="telemetry.html"><font color="#ffffff">telemetry</font></a>.<a href="telemetry.util.html"><font color="#ffffff">util</font></a>.image_util</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="../telemetry/util/image_util.py">telemetry/util/image_util.py</a></font></td></tr></table>
<p><tt>Provides implementations of basic image processing functions.<br>
<br>
Implements basic image processing functions, such as reading/writing images,<br>
cropping, finding the bounding box of a color and diffing images.<br>
<br>
When numpy is present, image_util_numpy_impl is used for the implementation of<br>
this interface. The old bitmap implementation (image_util_bitmap_impl) is used<br>
as a fallback when numpy is not present.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="base64.html">base64</a><br>
<a href="telemetry.internal.util.external_modules.html">telemetry.internal.util.external_modules</a><br>
</td><td width="25%" valign=top><a href="telemetry.internal.image_processing.image_util_numpy_impl.html">telemetry.internal.image_processing.image_util_numpy_impl</a><br>
<a href="telemetry.internal.image_processing.image_util_numpy_impl.html">telemetry.internal.image_processing.image_util_numpy_impl</a><br>
</td><td width="25%" valign=top><a href="numpy.html">numpy</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-AreEqual"><strong>AreEqual</strong></a>(image1, image2, tolerance<font color="#909090">=0</font>, likely_equal<font color="#909090">=True</font>)</dt><dd><tt>Determines whether two images are identical within a given tolerance.<br>
Setting likely_equal to False enables short-circuit equality testing, which<br>
is about 2-3x slower for equal images, but can be image height times faster<br>
if the images are not equal.</tt></dd></dl>
<dl><dt><a name="-Channels"><strong>Channels</strong></a>(image)</dt><dd><tt>Number of color channels in the image.</tt></dd></dl>
<dl><dt><a name="-Crop"><strong>Crop</strong></a>(image, left, top, width, height)</dt><dd><tt>Crops the current image down to the specified box.</tt></dd></dl>
<dl><dt><a name="-Diff"><strong>Diff</strong></a>(image1, image2)</dt><dd><tt>Returns a new image that represents the difference between this image<br>
and another image.</tt></dd></dl>
<dl><dt><a name="-FromBase64Png"><strong>FromBase64Png</strong></a>(base64_png)</dt><dd><tt>Create an image from raw PNG data encoded in base64.</tt></dd></dl>
<dl><dt><a name="-FromPng"><strong>FromPng</strong></a>(png_data)</dt><dd><tt>Create an image from raw PNG data.</tt></dd></dl>
<dl><dt><a name="-FromPngFile"><strong>FromPngFile</strong></a>(path)</dt><dd><tt>Create an image from a PNG file.<br>
<br>
Args:<br>
path: The path to the PNG file.</tt></dd></dl>
<dl><dt><a name="-FromRGBPixels"><strong>FromRGBPixels</strong></a>(width, height, pixels, bpp<font color="#909090">=3</font>)</dt><dd><tt>Create an image from an array of rgb pixels.<br>
<br>
Ignores alpha channel if present.<br>
<br>
Args:<br>
width, height: int, the width and height of the image.<br>
pixels: The flat array of pixels in the form of [r,g,b[,a],r,g,b[,a],...]<br>
bpp: 3 for RGB, 4 for RGBA.</tt></dd></dl>
<dl><dt><a name="-GetBoundingBox"><strong>GetBoundingBox</strong></a>(image, color, tolerance<font color="#909090">=0</font>)</dt><dd><tt>Finds the minimum box surrounding all occurrences of bgr |color|.<br>
<br>
Ignores the alpha channel.<br>
<br>
Args:<br>
color: RbgaColor, bounding box color.<br>
tolerance: int, per-channel tolerance for the bounding box color.<br>
<br>
Returns:<br>
(top, left, width, height), match_count</tt></dd></dl>
<dl><dt><a name="-GetColorHistogram"><strong>GetColorHistogram</strong></a>(image, ignore_color<font color="#909090">=None</font>, tolerance<font color="#909090">=0</font>)</dt><dd><tt>Computes a histogram of the pixel colors in this image.<br>
Args:<br>
ignore_color: An RgbaColor to exclude from the bucket counts.<br>
tolerance: A tolerance for the ignore_color.<br>
<br>
Returns:<br>
A ColorHistogram namedtuple with 256 integers in each field: r, g, and b.</tt></dd></dl>
<dl><dt><a name="-GetPixelColor"><strong>GetPixelColor</strong></a>(image, x, y)</dt><dd><tt>Returns a RgbaColor for the pixel at (x, y).</tt></dd></dl>
<dl><dt><a name="-Height"><strong>Height</strong></a>(image)</dt><dd><tt>Height of the image.</tt></dd></dl>
<dl><dt><a name="-Pixels"><strong>Pixels</strong></a>(image)</dt><dd><tt>Flat RGB pixel array of the image.</tt></dd></dl>
<dl><dt><a name="-Width"><strong>Width</strong></a>(image)</dt><dd><tt>Width of the image.</tt></dd></dl>
<dl><dt><a name="-WritePngFile"><strong>WritePngFile</strong></a>(image, path)</dt><dd><tt>Write an image to a PNG file.<br>
<br>
Args:<br>
image: an image object.<br>
path: The path to the PNG file. Must end in 'png' or an<br>
AssertionError will be raised.</tt></dd></dl>
</td></tr></table>
</body></html>