<html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <title>mmdpieces</title> <link href="../tbxdok.css" rel="stylesheet"> </head> <body> <table class="topNav"> <tr> <td class="index"> [<a href="../mmdemos/mmdpcb.html"><tt>mmdpcb</tt></a>] [<a href="index.html">Up</a>] [<a href="../mmdemos/mmdpotatoes.html"><tt>mmdpotatoes</tt></a>] </td> <td class="title">Demonstrations</td> </tr> </table> <h1>mmdpieces <br> <span class="subtitle">Classify two dimensional pieces. </span> </h1> <div class="descr"> <H2>Description</H2> <div class="H2"> <p> The input image is a binary image typically found in industrial automation applications. It has three types of objects: rings, nails and T-pins. Our procedure for identification of these classes of objects is based on thickening, thinning and reconstruction. </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 the pieces is read. </p> <div class="example"> <div class="listing"> <pre class="user">>>> a = mmreadgray('pieces_bw.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="229" src="../images/img_mmdpieces_001.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_001.jpg">a</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>Contour noise reduction</H3> <div class="H3"> <p> <p> An homotopic thickening is applied to reduce contour noise. </p> <div class="example"> <div class="listing"> <pre class="user">>>> seA = mmimg2se(mmbinary([[0,1,0],[1,0,1],[0,0,0]]))</pre> <pre class="computer"></pre> <pre class="user">>>> seB = mmimg2se(mmbinary([[0,0,0],[0,1,0],[0,0,0]]))</pre> <pre class="computer"></pre> <pre class="user">>>> iAB = mmse2hmt(seA,seB);</pre> <pre class="computer"></pre> <pre class="user">>>> print mmintershow(iAB)</pre> <pre class="computer">. 1 . 1 0 1 . . .</pre> <pre class="user">>>> b = mmthick(a, iAB);</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(b);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="229" src="../images/img_mmdpieces_002.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_002.jpg">b</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>Skeleton</H3> <div class="H3"> <p> <p> The homotopic skeleton by thinning is created. </p> <div class="example"> <div class="listing"> <pre class="user">>>> c = mmthin(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="229" src="../images/img_mmdpieces_003.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_003.jpg">c</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>Skeleton pruning</H3> <div class="H3"> <p> <p> The open lines of the skeleton are pruned by the end point thinning. The remaining skeleton components will be loops, identifying the rings. </p> <div class="example"> <div class="listing"> <pre class="user">>>> d = mmthin(c,mmendpoints());</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(c,d);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="229" src="../images/img_mmdpieces_004.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_004.jpg">c,d</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>Detect rings</H3> <div class="H3"> <p> <p> Extraction of the rings by reconstruction of the thicked image from the filtered skeleton. </p> <div class="example"> <div class="listing"> <pre class="user">>>> e = mminfrec(d,b);</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(e);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="229" src="../images/img_mmdpieces_005.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_005.jpg">e</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>Rings in the input image</H3> <div class="H3"> <p> <p> Restriction of the objects detected to the input-image. </p> <div class="example"> <div class="listing"> <pre class="user">>>> f = mmintersec(a,e);</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(f);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="229" src="../images/img_mmdpieces_006.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_006.jpg">f</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>Skeleton of the remaining objects</H3> <div class="H3"> <p> <p> It eliminates the skeleton of the rings. </p> <div class="example"> <div class="listing"> <pre class="user">>>> g = mmsubm(c,e);</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(g);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="229" src="../images/img_mmdpieces_007.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_007.jpg">g</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>End points filtering</H3> <div class="H3"> <p> <p> It removes sucessively 4 end-points to let T junctions just on T-pins. </p> <div class="example"> <div class="listing"> <pre class="user">>>> h = mmthin(g, mmendpoints(), 4);</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(h);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="229" src="../images/img_mmdpieces_008.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_008.jpg">h</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>T-pins markers</H3> <div class="H3"> <p> <p> It detects triple points, applying the union of matchings with two templates. These points will identify (mark) the T-pins. </p> <div class="example"> <div class="listing"> <pre class="user">>>> seA1 = mmimg2se(mmbinary([[0,1,0],[0,1,0],[1,0,1]]))</pre> <pre class="computer"></pre> <pre class="user">>>> seB1 = mmimg2se(mmbinary([[0,0,0],[1,0,1],[0,1,0]]))</pre> <pre class="computer"></pre> <pre class="user">>>> seA2 = mmimg2se(mmbinary([[0,1,0],[1,1,1],[0,0,0]]))</pre> <pre class="computer"></pre> <pre class="user">>>> seB2 = mmimg2se(mmbinary([[1,0,1],[0,0,0],[0,1,0]]))</pre> <pre class="computer"></pre> <pre class="user">>>> i1 = mmsupcanon(h, mmse2hmt(seA1,seB1));</pre> <pre class="computer"></pre> <pre class="user">>>> i2 = mmsupcanon(h, mmse2hmt(seA2,seB2));</pre> <pre class="computer"></pre> <pre class="user">>>> i = mmunion(i1,i2);</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(h,mmdil(i,mmsedisk(2)));</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="229" src="../images/img_mmdpieces_009.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_009.jpg">h,mmdil(i,mmsedisk(2))</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>Detect T-pins</H3> <div class="H3"> <p> <p> Detection of the T-pins by reconstruction of the ticked image from the T-pin markers. </p> <div class="example"> <div class="listing"> <pre class="user">>>> j = mminfrec(i,b,mmsebox());</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(j);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="229" src="../images/img_mmdpieces_010.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_010.jpg">j</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>T-pins in the input image</H3> <div class="H3"> <p> <p> Restriction of the objects detect to the input image </p> <div class="example"> <div class="listing"> <pre class="user">>>> k = mmintersec(a,j);</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(k);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="229" src="../images/img_mmdpieces_011.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_011.jpg">k</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>Detect nails</H3> <div class="H3"> <p> <p> The nails are imediatly detected by the subtration of the images of the rings and T-pints from the input image. </p> <div class="example"> <div class="listing"> <pre class="user">>>> l = mmsubm(mmsubm(a,f),k);</pre> <pre class="computer"></pre> <pre class="user">>>> mmshow(l);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="229" src="../images/img_mmdpieces_012.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_012.jpg">l</a></td> <td class="spare"></td> </tr> </tbody> </table> </div> </p> </div> </div> <div class="slide"> <H3>Color composition</H3> <div class="H3"> <p> <p> The result of the classification is presented in a pseudo color image. </p> <div class="example"> <div class="listing"> <pre class="user">>>> m = mmgray(f,'uint8',1);</pre> <pre class="computer"></pre> <pre class="user">>>> n = mmgray(k,'uint8',2);</pre> <pre class="computer"></pre> <pre class="user">>>> o = mmgray(l,'uint8',3);</pre> <pre class="computer"></pre> <pre class="user">>>> p = mmunion(m,n,o);</pre> <pre class="computer"></pre> <pre class="user">>>> mmlblshow(p);</pre> <pre class="computer"></pre> </div> <table class="images"> <tbody align="center"> <tr class="image" valign="bottom"> <td><img width="229" src="../images/img_mmdpieces_013.jpg"></td> <td class="spare"></td> </tr> <tr class="title" valign="baseline"> <td><a href="../images/img_mmdpieces_013.jpg">p</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/mmdpcb.html"><tt>mmdpcb</tt></a>] [<a href="index.html">Up</a>] [<a href="../mmdemos/mmdpotatoes.html"><tt>mmdpotatoes</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>