1 2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 3<html><head><title>Python: module telemetry.util.image_util</title> 4<meta charset="utf-8"> 5</head><body bgcolor="#f0f0f8"> 6 7<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> 8<tr bgcolor="#7799ee"> 9<td valign=bottom> <br> 10<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 11><td align=right valign=bottom 12><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> 13 <p><tt>Provides implementations of basic image processing functions.<br> 14 <br> 15Implements basic image processing functions, such as reading/writing images,<br> 16cropping, finding the bounding box of a color and diffing images.<br> 17 <br> 18When numpy is present, image_util_numpy_impl is used for the implementation of<br> 19this interface. The old bitmap implementation (image_util_bitmap_impl) is used<br> 20as a fallback when numpy is not present.</tt></p> 21<p> 22<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 23<tr bgcolor="#aa55cc"> 24<td colspan=3 valign=bottom> <br> 25<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> 26 27<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> 28<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="base64.html">base64</a><br> 29<a href="telemetry.internal.util.external_modules.html">telemetry.internal.util.external_modules</a><br> 30</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> 31<a href="telemetry.internal.image_processing.image_util_numpy_impl.html">telemetry.internal.image_processing.image_util_numpy_impl</a><br> 32</td><td width="25%" valign=top><a href="numpy.html">numpy</a><br> 33</td><td width="25%" valign=top></td></tr></table></td></tr></table><p> 34<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 35<tr bgcolor="#eeaa77"> 36<td colspan=3 valign=bottom> <br> 37<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> 38 39<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> 40<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> 41Setting likely_equal to False enables short-circuit equality testing, which<br> 42is about 2-3x slower for equal images, but can be image height times faster<br> 43if the images are not equal.</tt></dd></dl> 44 <dl><dt><a name="-Channels"><strong>Channels</strong></a>(image)</dt><dd><tt>Number of color channels in the image.</tt></dd></dl> 45 <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> 46 <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> 47and another image.</tt></dd></dl> 48 <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> 49 <dl><dt><a name="-FromPng"><strong>FromPng</strong></a>(png_data)</dt><dd><tt>Create an image from raw PNG data.</tt></dd></dl> 50 <dl><dt><a name="-FromPngFile"><strong>FromPngFile</strong></a>(path)</dt><dd><tt>Create an image from a PNG file.<br> 51 <br> 52Args:<br> 53 path: The path to the PNG file.</tt></dd></dl> 54 <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> 55 <br> 56Ignores alpha channel if present.<br> 57 <br> 58Args:<br> 59 width, height: int, the width and height of the image.<br> 60 pixels: The flat array of pixels in the form of [r,g,b[,a],r,g,b[,a],...]<br> 61 bpp: 3 for RGB, 4 for RGBA.</tt></dd></dl> 62 <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> 63 <br> 64Ignores the alpha channel.<br> 65 <br> 66Args:<br> 67 color: RbgaColor, bounding box color.<br> 68 tolerance: int, per-channel tolerance for the bounding box color.<br> 69 <br> 70Returns:<br> 71 (top, left, width, height), match_count</tt></dd></dl> 72 <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> 73Args:<br> 74 ignore_color: An RgbaColor to exclude from the bucket counts.<br> 75 tolerance: A tolerance for the ignore_color.<br> 76 <br> 77Returns:<br> 78 A ColorHistogram namedtuple with 256 integers in each field: r, g, and b.</tt></dd></dl> 79 <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> 80 <dl><dt><a name="-Height"><strong>Height</strong></a>(image)</dt><dd><tt>Height of the image.</tt></dd></dl> 81 <dl><dt><a name="-Pixels"><strong>Pixels</strong></a>(image)</dt><dd><tt>Flat RGB pixel array of the image.</tt></dd></dl> 82 <dl><dt><a name="-Width"><strong>Width</strong></a>(image)</dt><dd><tt>Width of the image.</tt></dd></dl> 83 <dl><dt><a name="-WritePngFile"><strong>WritePngFile</strong></a>(image, path)</dt><dd><tt>Write an image to a PNG file.<br> 84 <br> 85Args:<br> 86 image: an image object.<br> 87 path: The path to the PNG file. Must end in 'png' or an<br> 88 AssertionError will be raised.</tt></dd></dl> 89</td></tr></table> 90</body></html>