{"id":278,"date":"2009-07-20T13:39:12","date_gmt":"2009-07-20T17:39:12","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/2009\/07\/20\/a-new-look-for-connected-component-labeling-in-r2009a-part-3\/"},"modified":"2019-10-28T15:39:42","modified_gmt":"2019-10-28T19:39:42","slug":"a-new-look-for-connected-component-labeling-in-r2009a-part-3","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2009\/07\/20\/a-new-look-for-connected-component-labeling-in-r2009a-part-3\/","title":{"rendered":"A new look for connected component labeling in R2009a &#8211; Part 3"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p>I wrote <a href=\"https:\/\/blogs.mathworks.com\/steve\/2009\/07\/13\/a-new-look-for-connected-component-labeling-in-r2009a-part-2\/\">last week<\/a> about new features in R2009a related to connected component labeling.  There are two new functions, <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009a\/toolbox\/images\/bwconncomp.html\"><tt>bwconncomp<\/tt><\/a> and <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009a\/toolbox\/images\/labelmatrix.html\"><tt>labelmatrix<\/tt><\/a>, as well as additional syntaxes for an existing function, <tt>regionprops<\/tt>.  The features were designed to reduce the amount of memory required to measure geometric properties of connected components\r\n      (objects) in binary images. In many cases the computational speed is improved as well.\r\n   <\/p>\r\n   <p>We were concerned that existing users would not discover and use the new features. If users did not change their code, then\r\n      they would not benefit from the memory and speed improvements.\r\n   <\/p>\r\n   <p>So we asked the MATLAB M-Lint team for help.  M-Lint is the MATLAB code analysis tool that is behind those helpful suggestions\r\n      that the MATLAB Editor makes about your code.  We asked the team to detect the code pattern where the output of <tt>bwlabel<\/tt> is passed as the first input argument to <tt>regionprops<\/tt>. I showed this coding pattern in <a href=\"https:\/\/blogs.mathworks.com\/steve\/2009\/07\/06\/a-new-look-for-connected-component-labeling-in-r2009a\/\">Part 1<\/a>.  Here's what the MATLAB Editor now shows for the script is used to create Part 1:\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2009\/bwconncomp_c_screenshot_1.png\"> <\/p>\r\n   <p>If you hover over the underlined \"L\" with your mouse, a short message pops up:<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2009\/bwconncomp_c_screenshot_2.png\"> <\/p>\r\n   <p>And if you click on the short message, you get a full explanation of how to change your code:<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2009\/bwconncomp_c_screenshot_3.png\"> <\/p>\r\n   <p>As I mentioned in Part 1, the feedback of blog readers was influential in increasing the priority of this issue.  I thank\r\n      you for your many comments on my previous blogs about <tt>bwlabel<\/tt> and <tt>regionprops<\/tt>.\r\n   <\/p>\r\n   <p>If you get a chance to use the new features, let us know what you think by commenting on this post.<\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_751aa9670e8a4a3e951f2cc54e5de5a4() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='751aa9670e8a4a3e951f2cc54e5de5a4 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 751aa9670e8a4a3e951f2cc54e5de5a4';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Steve Eddins';\r\n        copyright = '';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_751aa9670e8a4a3e951f2cc54e5de5a4()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.8<br><\/p>\r\n<\/div>\r\n<!--\r\n751aa9670e8a4a3e951f2cc54e5de5a4 ##### SOURCE BEGIN #####\r\n%%\r\n% I wrote <https:\/\/blogs.mathworks.com\/steve\/2009\/07\/13\/a-new-look-for-connected-component-labeling-in-r2009a-part-2\/ \r\n% last week> about new features in R2009a related to connected\r\n% component labeling.  There are two new functions, \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2009a\/toolbox\/images\/bwconncomp.html \r\n% |bwconncomp|> and\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2009a\/toolbox\/images\/labelmatrix.html \r\n% |labelmatrix|>, as well as additional syntaxes for an existing function,\r\n% |regionprops|.  The features were designed to reduce the amount of memory\r\n% required to measure geometric properties of connected components (objects) in\r\n% binary images. In many cases the computational speed is improved as well.\r\n%\r\n% We were concerned that existing users would not discover and use the new\r\n% features. If users did not change their code, then they would not benefit from\r\n% the memory and speed improvements.\r\n%\r\n% So we asked the MATLAB M-Lint team for help.  M-Lint is the MATLAB code\r\n% analysis tool that is behind those helpful suggestions that the MATLAB Editor\r\n% makes about your code.  We asked the team to detect the code pattern where the\r\n% output of |bwlabel| is passed as the first input argument to |regionprops|.\r\n% I showed this coding pattern in \r\n% <https:\/\/blogs.mathworks.com\/steve\/2009\/07\/06\/a-new-look-for-connected-component-labeling-in-r2009a\/ \r\n% Part 1>.  Here's what the MATLAB Editor now\r\n% shows for the script is used to create Part 1:\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/2009\/bwconncomp_c_screenshot_1.png>>\r\n%\r\n% If you hover over the underlined \"L\" with your move, a short message pops up:\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/2009\/bwconncomp_c_screenshot_2.png>>\r\n%\r\n% And if you click on the short message, you get a full explanation of how to\r\n% change your code:\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/2009\/bwconncomp_c_screenshot_3.png>>\r\n%\r\n% As I mentioned in Part 1, the feedback of blog readers was influential in\r\n% increasing the priority of this issue.  I thank you for your many comments on\r\n% my previous blogs about |bwlabel| and |regionprops|.\r\n%\r\n% If you get a chance to use the new features, let us know what you think by\r\n% commenting on this post.\r\n##### SOURCE END ##### 751aa9670e8a4a3e951f2cc54e5de5a4\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   I wrote last week about new features in R2009a related to connected component labeling.  There are two new functions, bwconncomp and labelmatrix, as well as additional syntaxes for an existing... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2009\/07\/20\/a-new-look-for-connected-component-labeling-in-r2009a-part-3\/\">read more >><\/a><\/p>","protected":false},"author":42,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[561,563,168],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/278"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/comments?post=278"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/278\/revisions"}],"predecessor-version":[{"id":3643,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/278\/revisions\/3643"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}