<html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <title>mmdgear</title> <link href="../tbxdok.css" rel="stylesheet"> </head> <body> <table class="topNav"> <tr> <td class="index"> [<a href="../mmdemos/mmdflow.html"><tt>mmdflow</tt></a>] [<a href="index.html">Up</a>] [<a href="../mmdemos/mmdholecenter.html"><tt>mmdholecenter</tt></a>] </td> <td class="title">Demonstrations</td> </tr> </table> <h1>mmdgear <br> <span class="subtitle">Detect the teeth of a gear </span> </h1> <div class="descr"> <H2>Description</H2> <div class="H2"> <p> The input image is a binary image of a gear. The opening top-hat is used to detect the gear teeth. Finally, the teeth detected are labeled. </p> </div> </div> <div class="script"> <H2>Demo Script</H2> <div class="H2"> <div class="slide"> <H3>Reading</H3> <div class="H3"> <p> <p> The binary image of a gear is read. </p> <div class="example"> <div class="listing"> <pre class="user">>>> a = mmreadgray('gear.tif');</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(a);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="139" src="../images/img_mmdgear_001.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdgear_001.jpg">a</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>Opening and subtraction</H3> <div class="H3"> <p> <p> Opening of the input image by an Euclidean disk of radius 20. The sequence opening-subtraction is called opening top-hat. The opening top-hat could be executed in a single command: c = <span class="fun">mmopenth</span>(a, <span class="fun">mmsedisk</span>(20)); </p> <div class="example"> <div class="listing"> <pre class="user">>>> b = mmopen(a,mmsedisk(20));</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(b);</pre> <pre class="computer"></pre> <pre class="user">>>> c = mmsubm(a,b);</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(c);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="139" src="../images/img_mmdgear_002.jpg"></td> <td><img width="139" src="../images/img_mmdgear_003.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdgear_002.jpg">b</a></td> <td><a href="../images/img_mmdgear_003.jpg">c</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>Labeling and counting</H3> <div class="H3"> <p> <p> The teeth detected are labeled. The maximum pixel value in the labeled image gives the number of connected objects (n. of teeth). </p> <div class="example"> <div class="listing"> <pre class="user">>>> d = mmlabel(c);</pre> <pre class="computer"></pre> <pre class="user">>>> nteeth=mmstats(d,'max')</pre> <pre class="computer"></pre> <pre class="user">>>> mmlblshow(d,'border');</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="139" src="../images/img_mmdgear_004.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdgear_004.jpg">d,'border'</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> </div> </div> <center> <table class="botNav"> <tr> <td class="index"> [<a href="../mmdemos/mmdflow.html"><tt>mmdflow</tt></a>] [<a href="index.html">Up</a>] [<a href="../mmdemos/mmdholecenter.html"><tt>mmdholecenter</tt></a>] </td> <td rowspan="2" class="xhtml"><a href="http://www.python.org"><img width="55" alt="Python" height="22" src="../PythonPoweredSmall.gif"></a></td> </tr> <tr> <td class="copyright">Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center.</td> </tr> </table> </center> </body> </html>