<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-16879618</id><updated>2012-01-08T10:34:35.084+08:00</updated><category term='LabVIEW'/><category term='Video Processing'/><category term='Vision'/><title type='text'>what I know about IMAGE Processing</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-16879618.post-113205165871700733</id><published>2009-04-13T18:46:00.002+08:00</published><updated>2009-04-13T22:55:39.170+08:00</updated><title type='text'>Contents by Date</title><content type='html'>&lt;p&gt;Do find the following links (on the right of the subjects) for compatible SCILAB code (&lt;span style="color:#ff0000;"&gt;last update - &lt;strong&gt;13 April 2009&lt;/strong&gt;&lt;/span&gt;). Examples coverted are highlighted in &lt;strong&gt;&lt;span style="color:#33ff33;"&gt;GREEN&lt;/span&gt;&lt;/strong&gt;. &lt;/p&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2009/02/video-processing-from-offline-to-online.html"&gt;Video Processing: From Offline to Online&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2007/05/download-examples-by-author-new-2352007.html"&gt;Download Examples by Author&lt;/a&gt;&lt;strong&gt;&lt;span style="COLOR: rgb(255,0,0)"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2007/05/maple-for-image-processing-ii.html"&gt;Maple for Image Processing (II)&lt;/a&gt;&lt;strong&gt;&lt;span style="COLOR: rgb(255,0,0)"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/05/measuring-object-length-with-reference.html"&gt;Measuring Object Length (with a Reference Object)&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/04/character-recognition-example.html"&gt;Character Recognition Example: An Explanation On the Simple Concept Used in This Demo&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/02/hough-transform-for-hyperbola.html"&gt;Hough Transform For Hyperbola Detection - with known eccentricity&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/02/hough-transform-for-circle-detection.html"&gt;&lt;strong&gt;Hough Transform For Circle Detection - with unknown radius (II)&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;span style="color:#33ff33;"&gt;(&lt;/span&gt;&lt;/strong&gt;&lt;a href="http://scilab-imageprocessing.blogspot.com/2009/04/hough-transform-for-circle-detection_5591.html"&gt;&lt;strong&gt;&lt;span style="color:#33ff33;"&gt;compatible code in SCILAB&lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;span style="color:#33ff33;"&gt;)&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/02/fill-area-between-2-lines.html"&gt;Fill The Area Between 2 Lines&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/converting-pixels-to-line.html"&gt;Converting Pixels to Line&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/detecting-objects-motion-in-2.html"&gt;Detecting Objects' Motion in 2 Subsequence Images&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/hough-transform-for-circle-detection_23.html"&gt;&lt;strong&gt;Hough Transform For Circle Detection - with unknown radius (I)&lt;/strong&gt;&lt;/a&gt; &lt;span style="color:#33ff33;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;a href="http://scilab-imageprocessing.blogspot.com/2009/04/hough-transform-for-circle-detection_5899.html"&gt;&lt;span style="color:#33ff33;"&gt;&lt;strong&gt;compatible code in SCILAB&lt;/strong&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="color:#33ff33;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/hough-transform-for-circle-detection_18.html"&gt;&lt;strong&gt;Hough Transform For Circle Detection - with known radius (II)&lt;/strong&gt;&lt;/a&gt; &lt;span style="color:#33ff33;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;a href="http://scilab-imageprocessing.blogspot.com/2009/04/hough-transform-for-circle-detection_13.html"&gt;&lt;span style="color:#33ff33;"&gt;&lt;strong&gt;compatible code in SCILAB&lt;/strong&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="color:#33ff33;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/hough-transform-for-circle-detection.html"&gt;&lt;strong&gt;&lt;span style="color:#3366ff;"&gt;Hough Transform For Circle Detection - with known radius (I)&lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;span style="color:#33ff33;"&gt; (&lt;/span&gt;&lt;/strong&gt;&lt;a href="http://scilab-imageprocessing.blogspot.com/2009/04/hough-transform-for-circle-detection.html"&gt;&lt;strong&gt;&lt;span style="color:#33ff33;"&gt;compatible code in SCILAB&lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;span style="color:#33ff33;"&gt;)&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/simple-code-for-hough-transform.html"&gt;Simple Code for Hough Transform&lt;/a&gt; (Coming Next)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/signature-of-binary-objects.html"&gt;Signature of Binary Objects&lt;/a&gt; &lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/12/object-detection-using-hough-transform_06.html"&gt;Object Detection using Hough Transform (II)&lt;/a&gt; &lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/12/object-detection-using-hough-transform.html"&gt;Object Detection using Hough Transform (I)&lt;/a&gt; &lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/11/maple-for-image-processing.html"&gt;Maple for Image Processing?&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/11/which-software-to-use.html"&gt;Which Software to Use?&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/11/drawing-circles-around-round-object.html"&gt;Drawing Circles Around Round Object&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/11/drawing-transparent-object.html"&gt;Drawing Transparent Object&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/11/detecting-objects-shapeiii-triangle.html"&gt;Detecting Objects' Shape(III) : Triangle Object&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/10/detecting-objects-shapeii-square.html"&gt;Detecting Objects' Shape(II) : Square Object&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/10/detecting-objects-shapei-round-object.html"&gt;Detecting Objects' Shape(I) : Round Object&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/10/playing-with-edge-detection.html"&gt;Playing with “Edge Detection”&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/10/panoramic-picture-creation.html"&gt;Panoramic Picture Creation&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/10/character-recognition-example.html"&gt;Character Recognition Example (III):Training a Simple NN for classification&lt;/a&gt; (Coming Soon)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/09/character-recognition-example.html"&gt;Character Recognition Example (II):Automating Image Pre-processing&lt;/a&gt; (Coming Soon)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/09/character-recognition-example-i-image.html"&gt;Character Recognition Example (I): Image Pre-processing&lt;/a&gt; (Coming Soon)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/09/detecting-object-in-image.html"&gt;Detecting Object in an Image&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/09/drawing-shapes-by-overwriting-pixel.html"&gt;Drawing Shapes by Overwriting Pixel Value&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/09/what-is-image-compression.html"&gt;What is Image Compression?&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;Useful Resources:-&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;li&gt;Useful software could be found from the link at the sidebar &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Useful keyword to seacrh for this blogs: &lt;em&gt;image processing, image analysis, edge detection, matlab, maple, mathematica, mathcad&lt;/em&gt;&lt;/li&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113205165871700733?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113205165871700733/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113205165871700733' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113205165871700733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113205165871700733'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/09/contents-by-date.html' title='Contents by Date'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-1614200418265675578</id><published>2009-04-03T13:38:00.002+08:00</published><updated>2009-04-03T13:39:21.175+08:00</updated><title type='text'>Migrating to SCILAB</title><content type='html'>Hi all,&lt;br /&gt;&lt;br /&gt;I'm currently migrating to SCILAB for image processing, stay tuned at &lt;a href="http://scilab-imageprocessing.blogspot.com/"&gt;http://scilab-imageprocessing.blogspot.com/&lt;/a&gt; for the SCILAB version of this page.&lt;br /&gt;&lt;br /&gt;CL&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-1614200418265675578?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/1614200418265675578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=1614200418265675578' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/1614200418265675578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/1614200418265675578'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2009/04/migrating-to-scilab.html' title='Migrating to SCILAB'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-9213281575239041495</id><published>2009-02-24T16:06:00.003+08:00</published><updated>2009-02-24T16:11:17.581+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LabVIEW'/><category scheme='http://www.blogger.com/atom/ns#' term='Video Processing'/><category scheme='http://www.blogger.com/atom/ns#' term='Vision'/><title type='text'>Video Processing: From Offline to Online</title><content type='html'>I’ve chance to use LabVIEW for image and video processing, while having fear in converting from the software I used to, I found a lot of fun and excitement playing around with the LabVIEW Vision Development Module and Vision Assistant.&lt;br /&gt;Here how it goes:&lt;br /&gt;1. Using LabVIEW Vision for offline Image Processing &lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_VpjiJfC4dGQ/SaOrA4oLEnI/AAAAAAAAACg/2YfE98er6HI/s1600-h/img1.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5306272817661809266" style="WIDTH: 400px; CURSOR: hand; HEIGHT: 119px" alt="" src="http://4.bp.blogspot.com/_VpjiJfC4dGQ/SaOrA4oLEnI/AAAAAAAAACg/2YfE98er6HI/s400/img1.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_VpjiJfC4dGQ/SaOrBK78CpI/AAAAAAAAACo/d4FZVSGqzfA/s1600-h/img2.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5306272822576548498" style="WIDTH: 400px; CURSOR: hand; HEIGHT: 309px" alt="" src="http://2.bp.blogspot.com/_VpjiJfC4dGQ/SaOrBK78CpI/AAAAAAAAACo/d4FZVSGqzfA/s400/img2.jpg" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt; &lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;2. Having a little bit modification, it could be turned to real-time using webcam.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_VpjiJfC4dGQ/SaOrBPB-aTI/AAAAAAAAACw/onky07twBVU/s1600-h/img3.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5306272823675611442" style="WIDTH: 400px; CURSOR: hand; HEIGHT: 161px" alt="" src="http://4.bp.blogspot.com/_VpjiJfC4dGQ/SaOrBPB-aTI/AAAAAAAAACw/onky07twBVU/s400/img3.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://2.bp.blogspot.com/_VpjiJfC4dGQ/SaOrBLaI5EI/AAAAAAAAAC4/8USAZ_VxUh4/s1600-h/img4.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5306272822703219778" style="WIDTH: 400px; CURSOR: hand; HEIGHT: 251px" alt="" src="http://2.bp.blogspot.com/_VpjiJfC4dGQ/SaOrBLaI5EI/AAAAAAAAAC4/8USAZ_VxUh4/s400/img4.jpg" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;Required Components: LabVIEW, Vision Module, USB WebCam&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-9213281575239041495?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/9213281575239041495/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=9213281575239041495' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/9213281575239041495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/9213281575239041495'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2009/02/video-processing-from-offline-to-online.html' title='Video Processing: From Offline to Online'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_VpjiJfC4dGQ/SaOrA4oLEnI/AAAAAAAAACg/2YfE98er6HI/s72-c/img1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113246942799568869</id><published>2007-05-23T23:38:00.003+08:00</published><updated>2009-02-24T16:14:46.338+08:00</updated><title type='text'>Contents by Categories</title><content type='html'>&lt;p&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;Most of the examples in this blog using Matlab as the programming tool for this moment, &lt;/span&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;however, other software examples will be uploaded in the future. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;The following list is the full content by categories, and it will be updated everytime a new post is posted. The full content sorted by date could be found by clicking on the link at the side panel of this page or at the bottom of every page.&lt;/p&gt;&lt;p&gt;p/s : Matlab is the registered trademark of The Mathworks Inc. The link to the page could be found at the side panel as well.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;&lt;u&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/u&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;&lt;u&gt;&lt;strong&gt;LabVIEW Examples:-&lt;/strong&gt;&lt;/u&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2009/02/video-processing-from-offline-to-online.html"&gt;Video Processing: From Offline to Online&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;&lt;u&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/u&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;&lt;u&gt;&lt;strong&gt;Downloads:-&lt;/strong&gt;&lt;/u&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2007/05/download-examples-by-author-new-2352007.html"&gt;Download Examples by Author&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;&lt;u&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/u&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;&lt;u&gt;&lt;strong&gt;General:-&lt;/strong&gt;&lt;/u&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2007/05/maple-for-image-processing-ii.html"&gt;Maple for Image Processing (II)&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/11/maple-for-image-processing.html"&gt;Maple for Image Processing?&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/11/which-software-to-use.html"&gt;Which Software to Use?&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/09/what-is-image-compression.html"&gt;What is Image Compression?&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;Adding Object on Images:-&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/02/fill-area-between-2-lines.html"&gt;Fill The Area Between 2 Lines&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/converting-pixels-to-line.html"&gt;Converting Pixels to Line&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/11/drawing-circles-around-round-object.html"&gt;Drawing Circles Around Round Object&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/11/drawing-transparent-object.html"&gt;Drawing Transparent Object&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/09/drawing-shapes-by-overwriting-pixel.html"&gt;Drawing Shapes by Overwriting Pixel Value&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;&lt;strong&gt;&lt;u&gt;Object Detection:-&lt;/u&gt;&lt;/strong&gt; &lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/05/measuring-object-length-with-reference.html"&gt;Measuring Object Length (with a Reference Object)&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/02/hough-transform-for-hyperbola.html"&gt;Hough Transform For Hyperbola Detection - with known eccentricity&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/02/hough-transform-for-circle-detection.html"&gt;Hough Transform For Circle Detection - with unknown radius (II)&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/detecting-objects-motion-in-2.html"&gt;Detecting Objects' Motion in 2 Subsequence Images&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/hough-transform-for-circle-detection_23.html"&gt;Hough Transform For Circle Detection - with unknown radius (I)&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/hough-transform-for-circle-detection_18.html"&gt;Hough Transform For Circle Detection - with known radius (II)&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/hough-transform-for-circle-detection.html"&gt;Hough Transform For Circle Detection - with known radius (I)&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/simple-code-for-hough-transform.html"&gt;Simple Code for Hough Transform&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/01/signature-of-binary-objects.html"&gt;Signature of Binary Objects&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/12/object-detection-using-hough-transform_06.html"&gt;Object Detection using Hough Transform (II)&lt;/a&gt; &lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/12/object-detection-using-hough-transform.html"&gt;Object Detection using Hough Transform (I)&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/11/detecting-objects-shapeiii-triangle.html"&gt;Detecting Objects' Shape(III) : Triangle Object&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/10/detecting-objects-shapeii-square.html"&gt;Detecting Objects' Shape(II) : Square Object&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/10/detecting-objects-shapei-round-object.html"&gt;Detecting Objects' Shape(I) : Round Object&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/09/detecting-object-in-image.html"&gt;Detecting Object in an Image&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;Character Recognition:-&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2006/04/character-recognition-example.html"&gt;Character Recognition Example: An Explanation On the Simple Concept Used in This Demo&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/10/character-recognition-example.html"&gt;Character Recognition Example (III):Training a Simple NN for classification&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/09/character-recognition-example.html"&gt;Character Recognition Example (II):Automating Image Pre-processing&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/09/character-recognition-example-i-image.html"&gt;Character Recognition Example (I): Image Pre-processing&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;Other Examples:-&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/10/playing-with-edge-detection.html"&gt;Playing with “Edge Detection”&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://basic-eng.blogspot.com/2005/10/panoramic-picture-creation.html"&gt;Panoramic Picture Creation&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;Useful Resources:-&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;Useful software could be found from the link at the sidebar&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Useful keyword to seacrh for this blogs: &lt;em&gt;image processing, image analysis, edge detection, matlab, maple, mathematica, mathcad&lt;/em&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="COLOR: rgb(153,51,51)"&gt;Code Udpates/Error Corrections:-&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="COLOR: rgb(0,0,0)"&gt;Do notes that for all the Circle Det&lt;/li&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113246942799568869?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113246942799568869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113246942799568869' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113246942799568869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113246942799568869'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/05/contents-by-categories-updated-on.html' title='Contents by Categories'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-6284441270937511094</id><published>2007-05-23T21:16:00.001+08:00</published><updated>2008-05-30T22:43:53.957+08:00</updated><title type='text'>Download Examples by Author</title><content type='html'>For those who are not aware, most of the examples descript here had been post in MATLAB Central:&lt;br /&gt;&lt;br /&gt;1. &lt;a class="boldplain" href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8779&amp;amp;objectType=FILE"&gt;Speech Analysis using LPC&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2. &lt;a class="boldplain" href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8676&amp;amp;objectType=FILE"&gt;Character Recognition Example (III):Training a Simple NN for classification&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;3. &lt;a class="boldplain" href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=2322&amp;amp;objectType=FILE"&gt;Simple DIP demos&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;4. &lt;a class="boldplain" href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=6192&amp;amp;objectType=FILE"&gt;Video Surveillance Using MATLAB and Image Acquisition Toolbox&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;5. &lt;a class="boldplain" href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=2384&amp;amp;objectType=FILE"&gt;Icon Menu&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;6. &lt;a class="boldplain" href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8612&amp;amp;objectType=FILE"&gt;Character Recognition Example (I&amp;amp;II): Pre-processing of Image&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;7. &lt;a class="boldplain" href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=9275&amp;amp;objectType=FILE"&gt;Simple Shape Detection using Hough Transform&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;8. &lt;a class="boldplain" href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=3886&amp;amp;objectType=FILE"&gt;DTMF generator using TI C6711 DSK&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;9. &lt;a class="boldplain" href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=2357&amp;amp;objectType=FILE"&gt;Using RTW and Compiler&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;10. &lt;a class="boldplain" href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=9898&amp;amp;objectType=FILE"&gt;Hough Transform for Circle Detection (GUI)&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;11. &lt;a class="boldplain" href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8984&amp;amp;objectType=FILE"&gt;Drawing Transparent Object on Image&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-6284441270937511094?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/6284441270937511094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=6284441270937511094' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/6284441270937511094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/6284441270937511094'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2007/05/download-examples-by-author-new-2352007.html' title='Download Examples by Author'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-4840965439917412790</id><published>2007-05-11T21:25:00.000+08:00</published><updated>2007-05-11T21:32:19.886+08:00</updated><title type='text'>Maple for Image Processing (II)</title><content type='html'>&lt;span style="font-family:arial;color:#993333;"&gt;&lt;u&gt;More Functions for Image Processing in Symbolic Tools&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Found more image processing functions in Maple 11, however, doesn't have much time to explore much.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.maplesoft.com/applications/app_center_view.aspx?AID=2059&amp;CID=10&amp;amp;SCID=149"&gt;&lt;span style="font-family:arial;"&gt;http://www.maplesoft.com/applications/app_center_view.aspx?AID=2059&amp;CID=10&amp;amp;SCID=149&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Well, since this is the first article after one year, at least it is a new start. :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-4840965439917412790?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/4840965439917412790/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=4840965439917412790' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/4840965439917412790'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/4840965439917412790'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2007/05/maple-for-image-processing-ii.html' title='Maple for Image Processing (II)'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-114856168521718052</id><published>2006-05-25T20:26:00.000+08:00</published><updated>2006-05-25T21:08:38.443+08:00</updated><title type='text'>Measuring Object Length (with a Reference Object)</title><content type='html'>It has been a long long time I've not update this blog due to my new notebook modem spoiled just after I bought it! The support staff came 3 times and now I am waiting for a replacement model...&lt;br /&gt;&lt;br /&gt;Further more, life become more and more busy, and sometimes I really out of idea what to post here. :P&lt;br /&gt;&lt;br /&gt;Until I receive some e-mail from some reader...&lt;br /&gt;&lt;br /&gt;This is rather a simple example to measure a length of an object in an image. We could easily get the reading in pixels, and with a reference, we could just use a simple mathematic to compute the lenght in some standard unit.&lt;br /&gt;&lt;br /&gt;Let's see this simple example:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;1. Reading image and show the true color image.&lt;br /&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;clear all;clc;&lt;br /&gt;I = imread('pic29.tif');&lt;br /&gt;imshow (I);&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/pic29.1.jpg" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;2. Assuming that we know the length of the red object (as reference) which is 5 cm, locate the red object with simple command and find the length in pixels:&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="left"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: left" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/pic1.0.jpg" border="0" /&gt; Ired_labeled = bwlabel(Ired);&lt;br /&gt;Ired_props = regionprops(Ired_labeled);&lt;br /&gt;Ired_length_in_pixel = Ired_props.BoundingBox(3);&lt;br /&gt;disp(Ired_length_in_pixel);&lt;br /&gt;&lt;br /&gt;212&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;3. To measure the length of the green object, extract the object:&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 5px; CURSOR: hand; TEXT-ALIGN: left" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/pic2.jpg" border="0" /&gt;Igreen_labeled = bwlabel(Igreen);&lt;br /&gt;Igreen_props = regionprops(Igreen_labeled);&lt;br /&gt;Igreen_length_in_pixel = Igreen_props.BoundingBox(3);&lt;br /&gt;disp(Igreen_length_in_pixel);&lt;br /&gt;&lt;br /&gt;146&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;4. Calculate the length of green object in cm&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Igreen_length_in_cm = Igreen_length_in_pixel/Ired_length_in_pixel*5;&lt;br /&gt;disp(Igreen_length_in_cm);&lt;br /&gt;&lt;br /&gt;3.4434 &lt;/p&gt;&lt;p align="left"&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-114856168521718052?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/114856168521718052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=114856168521718052' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/114856168521718052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/114856168521718052'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/05/measuring-object-length-with-reference.html' title='Measuring Object Length (with a Reference Object)'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-114432593221783361</id><published>2006-04-06T20:11:00.000+08:00</published><updated>2007-03-21T20:07:05.420+08:00</updated><title type='text'>Character Recognition Example: An Explanation On the Simple Concept Used in This Demo</title><content type='html'>After I posted these series of examples, I’ve received a few comments from readers. Some of them using different version of software and can’t run the program successfully, some were happy with the simple code in which they had applied it to some other application, while a few readers were asking for more explanations on how these code work.&lt;br /&gt;&lt;br /&gt;Well, I believe I’ve answered the doubt on the different version issue, but not the doubt on more details explanations. Here, I tried to draft a few paragraph to explain the concept hidden behind the code, and hope it helps to answer the readers who ask me about it though email.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;1. Image Preprocessing&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The image is first being converted to grayscale image follow by the threshing technique, which make the image become binary image. The binary image is then go through connectivity test in order to check for the maximum connected component, which is, the box of the form. After locating the box, the individual characters are then cropped into different sub images that are the raw data for the following feature extraction routine.&lt;br /&gt;&lt;br /&gt;The size of the sub-images are not fixed since they are expose to noises which will affect the cropping process to be vary from one to another. This will causing the input of the network become not standard and hence, prohibit the data from feeding through the network. To solve this problem, the sub-images have been resize to 50 by 70 and then by finding the average value in each 10 by 10 blocks, the image can be down to 5 by 7 matrices, with fuzzy value, and become 35 inputs for the network. However, before resize the sub-images, another process must be gone through to eliminate the white space in the boxes.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;2. Feature Extraction&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The sub-images have to be cropped sharp to the border of the character in order to standardize the sub-images. The image standardization is done by finding the maximum row and column with 1s and with the peak point, increase and decrease the counter until meeting the white space, or the line with all 0s. This technique is shown in figure below where a character “S” is being cropped and resize.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig1.6.jpg"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig1.5.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The image pre-processing is then followed by the image resize again to meet the network input requirement, 5 by 7 matrices, where the value of 1 will be assign to all pixel where all 10 by 10 box are filled with 1s, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.4.jpg" border="0" /&gt;Finally, the 5 by 7 matrices is concatenated into a stream so that it can be feed into network 35 input neurons. The input of the network is actually the negative image of the figure, where the input range is 0 to 1, with 0 equal to black and 1 indicate white, while the value in between show the intensity of the relevant pixel.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;3. Neural Network Training &lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;Well, I have just met a lecturer in my country and we had a short discussion on the NN for classification purpose. Both of us agree that while using simple FF-BP-NN for classification, the more important thing is the pre-processing of the data. “Rubbish-in, rubbish-out”, always true… So if you were to use NN after this process, it should be quite straight forward after you get the features, which is 5 by 7 = 35 values.&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-114432593221783361?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/114432593221783361/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=114432593221783361' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/114432593221783361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/114432593221783361'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/04/character-recognition-example.html' title='Character Recognition Example: An Explanation On the Simple Concept Used in This Demo'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-114044074233062737</id><published>2006-02-21T20:59:00.000+08:00</published><updated>2006-02-21T21:02:25.096+08:00</updated><title type='text'>Hough Transform For Hyperbola Detection - with known eccentricity</title><content type='html'>&lt;p&gt;&lt;/p&gt;&lt;p&gt;More Hough Transform examples!&lt;br /&gt;&lt;br /&gt;In last few examples, the Hough Transform are used to detect different shape, such as line and circle. For the circle detection, examples of circles with known radius detection and circles with unknown radius detection have been illustrated.&lt;br /&gt;&lt;br /&gt;Besides, different techniques of implemeting the code are shown, as in "for" loops and vectorized code.&lt;br /&gt;&lt;br /&gt;In this example, example of how the Hough Transform could be used for hyperbola detection would be demonstrated.&lt;br /&gt;&lt;br /&gt;Firstly, let's see the equation of the hyperbola:&lt;br /&gt;&lt;br /&gt;(x-xo)^2/a^2 - (y-yo)^2/b^2 = 1&lt;br /&gt;&lt;br /&gt;Let's start with a simple example to find the asymptotes and the crossing point of a hyperbola with known eccentricity, e^2 = a^2 + b^2, and to simplified the problem, let's make the a = b = 29.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;1. Reading image and the convert to binary image. After that, the location of the value '1' is found using 'find' function. (the image is in white background and black object, so the '~' is used to get the negative image.&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;clear all;clc;&lt;br /&gt;I = imread('pic27.bmp');&lt;br /&gt;I =im2bw(I);&lt;br /&gt;imshow(I);&lt;br /&gt;I = ~I;&lt;br /&gt;[y,x]=find(I);&lt;br /&gt;[sy,sx]=size(I);&lt;br /&gt;imshow(I);&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig1.12.png" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;2. Find all the require information for the transformatin. the 'totalpix' is the numbers of '1' in the image&lt;/u&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;totalpix = length(x);&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;3. Preallocate memory for the Hough Matrix. In this case, the a and b are known as 29 (in pixels).&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;HM = zeros(sy,sx);&lt;br /&gt;a = 29;&lt;br /&gt;b = 29;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;4. Performing Hough Transform to transform the x-y domain to xo-yo domain. &lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;sx style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.16.png" alt="" border="0"&gt;yo = 1:sy;&lt;br /&gt;&lt;br /&gt;for cnt = 1:totalpix&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;% a. Four lines of equation here to detect the hyperbola shapes in 4&lt;br /&gt;% different direction&lt;br /&gt;xo(:,1) = round(x(cnt) + sqrt(a.^2.*(((y(cnt)-yo).^2/(b.^2))+1)));&lt;br /&gt;xo(:,2) = round(x(cnt) - sqrt(a.^2.*(((y(cnt)-yo).^2/(b.^2))+1)));&lt;br /&gt;xo(:,3) = round(x(cnt) + sqrt(a.^2.*(((y(cnt)-yo).^2/(b.^2))-1)));&lt;br /&gt;xo(:,4) = round(x(cnt) - sqrt(a.^2.*(((y(cnt)-yo).^2/(b.^2))-1)));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;% b. Since there are 4 equations, Hough Matrix must consists of the&lt;br /&gt;% combination for 4 equation.&lt;br /&gt;for cnt3 = 1:4&lt;br /&gt;for cnt2 = 1:sy &lt;/p&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig4.1.png"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/fig4.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;HM(cnt2,xo(cnt2,cnt3)) = HM(cnt2,xo(cnt2,cnt3)) + 1; &lt;/p&gt;end&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;5. Showing the Hough Matrix&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;imshow(HM,[]);&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.17.png" border="0" /&gt; &lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;sx)&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;6. Finding the asymptotes and the crossing point of a hyperbola&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;[maxval, maxind] = max(max(HM));&lt;br /&gt;[Yo,Xo] = find(HM==maxval);&lt;br /&gt;imshow(I); hold on;&lt;br /&gt;plot(mean(Xo),mean(Yo),'xr')&lt;br /&gt;c1 = mean(Yo) - mean(Xo);hold on;&lt;br /&gt;plot(1:100, [1:100] + c1);&lt;br /&gt;c2 = mean(Yo) + mean(Xo); hold on;&lt;br /&gt;plot(1:100, -[1:100] + c2);&lt;br /&gt;&lt;br /&gt;Y = 1:sy;&lt;br /&gt;X = -sqrt(((Y-mean(Yo)).^2/a.^2 + 1).*b.^2) + mean(Xo);&lt;br /&gt;hold on;&lt;br /&gt;plot(X,real(Y),'r');&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig3.16.png" border="0" /&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-114044074233062737?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/114044074233062737/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=114044074233062737' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/114044074233062737'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/114044074233062737'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/02/hough-transform-for-hyperbola.html' title='Hough Transform For Hyperbola Detection - with known eccentricity'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113922024494050253</id><published>2006-02-06T21:55:00.000+08:00</published><updated>2006-02-06T21:09:25.943+08:00</updated><title type='text'>Hough Transform For Circle Detection - with unknown radius (II)</title><content type='html'>The detection of circle with unknown radius has been shown in previous post - &lt;a href="http://basic-eng.blogspot.com/2006/01/hough-transform-for-circle-detection_23.html"&gt;Hough Transform For Circle Detection - with unknown radius (I)&lt;/a&gt; , by using a lot of "for" loops.&lt;br /&gt;&lt;br /&gt;This example shows the same function with "vectorized" code, which run 25% faster than the previous code, in a Pentium M 1.5 GHz computer with 512 M RAM.&lt;br /&gt;&lt;br /&gt;Let's see how to perform this:&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;1. Reading image and the convert to binary image. After that, the location of the value '1' is found using 'find' function. (Assume the image is already preprocess, if not, the 'edge' function might help)&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;clear all;clc;&lt;br /&gt;I = imread('pic26.bmp');&lt;br /&gt;I =im2bw(I);&lt;br /&gt;[y,x]=find(I);&lt;br /&gt;[sy,sx]=size(I);&lt;br /&gt;imshow(I);&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig1.21.png"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig1.11.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;2. Find all the require information for the transformation. The 'totalpix' is the numbers of '1' in the image.&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;totalpix = length(x);&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;3. Pre-allocate memory for the Hough Matrix and other variables. The ‘R’ is known in the range from 1 to 50, so we reserve 50 "layers" for the HM matrix.&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;HM = zeros(sy*sx*50,1);&lt;br /&gt;R = 1:50;&lt;br /&gt;R2(1,1,:) = R.^2;&lt;br /&gt;R2 = repmat(R2,[sy,totalpix,1]);&lt;br /&gt;y = repmat(y',[sy,1,50]);&lt;br /&gt;x = repmat(x',[sy,1,50]);&lt;br /&gt;b = 1:sy;&lt;br /&gt;b = repmat(b',[1,totalpix,50]);&lt;br /&gt;a = zeros(sy,totalpix);&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;4. Performing Hough Transform. Do notice that no "for" loops are used here.&lt;/span&gt;&lt;br /&gt;&lt;/u&gt;&lt;br /&gt;a. Find the a parameter&lt;br /&gt;&lt;br /&gt;a = (round(x - sqrt(R2 - (y - b).^2)));&lt;br /&gt;&lt;br /&gt;b. Find the location of ‘a’ and ‘b’, as well as the valid value both.&lt;br /&gt;&lt;br /&gt;[xx,yy,zz]=find((imag(a)==0 &amp; a&gt;0));&lt;br /&gt;b = b(imag(a)==0 &amp; a&gt;0);&lt;br /&gt;a = a(imag(a)==0 &amp; a&gt;0);&lt;br /&gt;&lt;br /&gt;c. Find the indices and remap it to different layers&lt;br /&gt;&lt;br /&gt;ind = sub2ind([sy,sx],b,a);&lt;br /&gt;ind = ind + (ceil(yy/totalpix)-1)*sx*sy;&lt;br /&gt;&lt;br /&gt;d. Construct the Hough Matrix of 50 layers&lt;br /&gt;&lt;br /&gt;val = ones(length(ind),1);&lt;br /&gt;data=accumarray(ind,val);&lt;br /&gt;HM(1:length(data)) = data;&lt;br /&gt;HM2 = reshape(HM,[sy,sx,50]);&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;5. Find for the maximum value for each layer, or in other words, the layer with maximum value will indicate the corresponding ‘R’ for the circle. &lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;for cnt = 1:50&lt;br /&gt;H(cnt) = max(max(HM2(:,:,cnt)));&lt;br /&gt;end&lt;br /&gt;plot(H,'*-');&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig2.23.png"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.15.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;6. Extract the information from the layer with maximum value, and overlap with the original image.&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;[maxval, maxind] = max(H);&lt;br /&gt;[B,A] = find(HM2(:,:,maxind)==maxval);&lt;br /&gt;imshow(I); hold on;&lt;br /&gt;plot(mean(A),mean(B),'xr')&lt;br /&gt;text(mean(A),mean(B),num2str(maxind),'color','green')&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig3.15.png" border="0" /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;7. This example use the vectorized code, and the speed of the program is 25 % faster than the previous example using "for" loops.&lt;/span&gt;&lt;/u&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113922024494050253?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113922024494050253/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113922024494050253' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113922024494050253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113922024494050253'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/02/hough-transform-for-circle-detection.html' title='Hough Transform For Circle Detection - with unknown radius (II)'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113881435522977047</id><published>2006-02-02T01:07:00.000+08:00</published><updated>2006-02-02T02:18:49.016+08:00</updated><title type='text'>Fill The Area Between 2 Lines</title><content type='html'>This example shows how to fill the area between 2 lines with color.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;1. Assuming we have two lines on a plot&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;x1 = 0:10;&lt;br /&gt;y1 = 2*x+3;&lt;br /&gt;y2 = 2*x+7;&lt;br /&gt;plot(x,y1);&lt;br /&gt;hold on;&lt;br /&gt;plot(x,y2);&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig1.18.png"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig1.3.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;2. One of the simple way to fill the are between 2 lines is:&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;a. Find 4 points for the 2 lines - start point and end point, assuming 2 lines are within certain boundary, so the x vector will be (do note that the points must be defined in order, either clock-wise or anti clock-wise):&lt;br /&gt;&lt;br /&gt;x = [0 10 10 0];&lt;br /&gt;&lt;br /&gt;b. Replacing x in to y1 and y2 to get y vector:&lt;br /&gt;&lt;br /&gt;y = [3 23 27 7];&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#993333;"&gt;3. Use the "fill" or "patch" function to fill the area between 2 lines.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;patch(x,y,'r')&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.2.jpg" border="0" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113881435522977047?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113881435522977047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113881435522977047' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113881435522977047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113881435522977047'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/02/fill-area-between-2-lines.html' title='Fill The Area Between 2 Lines'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113861422026359308</id><published>2006-01-30T17:37:00.000+08:00</published><updated>2006-01-30T22:15:22.626+08:00</updated><title type='text'>Converting Pixels to Line</title><content type='html'>Converting pixels to line could be a complicated job. A simple example is shown to serve as the basis of a complicated problem.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;1. Reading image&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;clear all;clc;&lt;br /&gt;I = imread('pic24.jpg');&lt;br /&gt;I = im2bw(I);&lt;br /&gt;imshow(I);&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/fig1.1.jpg" border="0" /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;2. Finding all the pixels with the value of '1'&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;[y,x] = find(I==1);&lt;br /&gt;imshow(I);&lt;br /&gt;hold on;&lt;br /&gt;plot(x,y);&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig2.18.png"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.11.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;3. Use the "polyfit" function to fit polynomial to data, in our case, since it is a straight line, we use 1st order polynomial or a linear equation Y = M*X + C&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;p = polyfit(x,y,1);&lt;br /&gt;disp(p);&lt;br /&gt;&lt;br /&gt;-0.7873 158.3164&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;4. Find the image size and create the X and Y based on the coefficients of "p".&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;sz = size(I);&lt;br /&gt;X = 1:sz(2);&lt;br /&gt;Y = p(1) * X + p(2);&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;5. Display the result&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;imshow(I);&lt;br /&gt;hold on;&lt;br /&gt;plot(X,Y);&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig3.12.png" border="0" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113861422026359308?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113861422026359308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113861422026359308' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113861422026359308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113861422026359308'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/01/converting-pixels-to-line.html' title='Converting Pixels to Line'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113854087604545821</id><published>2006-01-29T20:35:00.000+08:00</published><updated>2006-12-29T00:19:12.660+08:00</updated><title type='text'>Detecting Objects' Motion in 2 Subsequence Images</title><content type='html'>I've been posting examples of Hough Transform since last month, and now is the time to switch to other examples.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;1. Reading image and comparing 2 images side by side&lt;/span&gt;&lt;br /&gt;&lt;/u&gt;&lt;br /&gt;clear all;clc;&lt;br /&gt;Ia = imread('pic23a.jpg');&lt;br /&gt;Ib = imread('pic23b.jpg');&lt;br /&gt;subplot(121);imshow(Ia);&lt;br /&gt;subplot(122);imshow(Ib);&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/pic23b.jpg"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/pic23b.jpg" border="0" /&gt;&lt;/a&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/pic23a.1.jpg"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/pic23a.0.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/pic23a.1.jpg"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;2. Finding the location of green object in 2 images&lt;/span&gt;&lt;br /&gt;&lt;/u&gt;&lt;br /&gt;a. Set the threshold value for green color&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/pic4.png"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/pic4.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;p/s: I can't make the "&amp;" appear in text, so the text aboved is in image format.&lt;br /&gt;&lt;br /&gt;b. Find the location of the green object&lt;br /&gt;&lt;br /&gt;[y1,x1] = find(Ia_green==1);&lt;br /&gt;[y2,x2] = find(Ib_green==1);&lt;br /&gt;&lt;br /&gt;c. Find the centroid of the green object&lt;br /&gt;&lt;br /&gt;x1 = round(mean(x1));&lt;br /&gt;y1 = round(mean(y1));&lt;br /&gt;x2 = round(mean(x2));&lt;br /&gt;y2 = round(mean(y2));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;3. Putting 2 images together and show the movement of the objects&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;/u&gt;&lt;br /&gt;figure;&lt;br /&gt;imshow(Ia); hold on;&lt;br /&gt;imshow(Ib);&lt;br /&gt;alpha(.5);&lt;br /&gt;plot(x1,y1,'r*');&lt;br /&gt;plot(x2,y2,'ro');&lt;br /&gt;plot([x1,x2],[y1,y2]);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/pic3.png" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The '*' indicates the start point of the object while the 'o' is the stop point of the object. Other objects' movement could be found by modifying the step number 2.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113854087604545821?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113854087604545821/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113854087604545821' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113854087604545821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113854087604545821'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/01/detecting-objects-motion-in-2.html' title='Detecting Objects&apos; Motion in 2 Subsequence Images'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113801731341505891</id><published>2006-01-23T19:47:00.000+08:00</published><updated>2006-01-23T19:55:13.430+08:00</updated><title type='text'>Hough Transform For Circle Detection - with unknown radius (I)</title><content type='html'>In previous 2 examples, the generalized Hough Transform has been applied to find for the circle with known radius. We were using the circle equation --&gt; (x-a)^2 + (y-b)^2 = R^2 to map the pixel to a-b domain.&lt;br /&gt;&lt;br /&gt;For detection circle with unknown radius, another parameter need to be make as variable, which is, the radius R.&lt;br /&gt;&lt;br /&gt;Let's see how to perform this:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;1. Reading image and the convert to binary image. After that, the location of the value '1' is found using 'find' function. (assume the image is already preprocess, if not, the 'edge' function might help)&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;clear all;clc;&lt;br /&gt;I = imread('pic22.bmp');&lt;br /&gt;I =im2bw(I);&lt;br /&gt;[y,x]=find(I);&lt;br /&gt;[sy,sx]=size(I);&lt;br /&gt;imshow(I);&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/fig1.6.png" border="0" /&gt;&lt;br /&gt;&lt;span style="color:#993333;"&gt;&lt;strong&gt;2. Find all the require information for the transformatin. the 'totalpix' is the numbers of '1' in the image.&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;totalpix = length(x);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;3. Preallocate memory for the Hough Matrix. The R is known in the range from 1 to 50, so we reserve 50 "layers" for the HM matrix&lt;/span&gt;&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;HM = zeros(sy,sx,50);&lt;br /&gt;R = 1:50;&lt;br /&gt;R2 = R.^2;&lt;br /&gt;sz = sy*sx;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;4. Performing Hough Transform. Notice the accumulator is located in the inner for loop.&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;for cnt = 1:totalpix&lt;br /&gt;  for cntR = 1:50&lt;br /&gt;    b = 1:sy;&lt;br /&gt;    a = (round(x(cnt) - sqrt(R2(cntR) - (y(cnt) - [1:sy]).^2)));&lt;br /&gt;    b = b(imag(a)==0 &amp; a&gt;0);&lt;br /&gt;    a = a(imag(a)==0 &amp; a&gt;0);&lt;br /&gt;    ind = sub2ind([sy,sx],b,a); &lt;br /&gt;    HM(sz*(cntR-1)+ind) = HM(sz*(cntR-1)+ind) + 1;&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;5. Find for the maximum value for each layer, or in other words, the layer with maximum value will indicate the correspond R for the circle.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;for cnt = 1:50&lt;br /&gt;H(cnt) = max(max(HM(:,:,cnt)));&lt;br /&gt;end&lt;br /&gt;plot(H,'*-');&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig2.16.png"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.9.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;6. Extract the information from the layer with maximum value, and overlap with the original image.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;[maxval, maxind] = max(H);&lt;br /&gt;[B,A] = find(HM(:,:,maxind)==maxval);&lt;br /&gt;imshow(I); hold on;&lt;br /&gt;plot(mean(A),mean(B),'xr')&lt;br /&gt;text(mean(A),mean(B),num2str(maxind),'color','green')&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig3.11.png" border="0" /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;7. This example use the "for loop" extensively, and the speed of the program is rather slow. Vectorized the code might speed up the execution time, we wee see it in the next example. :)&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113801731341505891?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113801731341505891/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113801731341505891' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113801731341505891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113801731341505891'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/01/hough-transform-for-circle-detection_23.html' title='Hough Transform For Circle Detection - with unknown radius (I)'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113715313396330859</id><published>2006-01-18T20:13:00.000+08:00</published><updated>2006-01-18T20:08:25.716+08:00</updated><title type='text'>Hough Transform For Circle Detection - with known radius (II)</title><content type='html'>This example doing the same as the previous example, with the difference that this example does not use any "for loops" in the code. The vectorized code make the algorithm runs faster but with the trade-off of high memory consumtion. Try to compare this with the previous example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;1. Reading image and the convert to binary image. After that, the location of the value '1' is found using 'find' function. (assume the image is already preprocess, if not, the 'edge' function might help)&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;clear all;clc;&lt;br /&gt;I = imread('pic21.bmp');&lt;br /&gt;I =im2bw(I);&lt;br /&gt;[y,x]=find(I);&lt;br /&gt;[sy,sx]=size(I);&lt;br /&gt;imshow(I);&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig1a.png"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/fig1a.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;2. Find all the require information for the transformatin. the 'totalpix' is the numbers of '1' in the image.&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;totalpix = length(x);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;3. Preallocate memory for the Hough Matrix. Try to play around with the R, or the radius to see the different results.&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;HM = zeros(sy*sx,1);&lt;br /&gt;R = 36;&lt;br /&gt;R2 = R^2;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;4. Performing Hough Transform. Notice that no "for-loop" in this portion of code.&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;a. Preparing all the matrices for the computation without "for-loop"&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;b = 1:sy;&lt;br /&gt;a = zeros(sy,totalpix);&lt;br /&gt;&lt;br /&gt;y = repmat(y',[sy,1]);&lt;br /&gt;x = repmat(x',[sy,1]);&lt;br /&gt;&lt;br /&gt;b = repmat(b',[1,totalpix]);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;b. The equation for the circle&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;a = (round(x - sqrt(R2 - (y - b).^2)));&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;c. Removing all the invalid value in matrices a and b&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;b = b(imag(a)==0 &amp; a&gt;0);&lt;br /&gt;a = a(imag(a)==0 &amp; a&gt;0);&lt;br /&gt;ind = sub2ind([sy,sx],b,a);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;d. Reconstruct the Hough Matrix&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;val = ones(length(ind),1);&lt;br /&gt;data=accumarray(ind,val);&lt;br /&gt;HM(1:length(data)) = data;&lt;br /&gt;HM2 = reshape(HM,[sy,sx]);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;5. Showing the Hough Matrix&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;cla&lt;br /&gt;imshow(HM2,[]);&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig2.10.png"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/fig2.2.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;6. Finding the location of the circle with radius of R&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;[maxval, maxind] = max(max(HM2));&lt;br /&gt;[B,A] = find(HM2==maxval);&lt;br /&gt;imshow(I); hold on;&lt;br /&gt;plot(mean(A),mean(B),'xr')&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig3.10.png"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/fig3.2.png" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113715313396330859?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113715313396330859/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113715313396330859' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113715313396330859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113715313396330859'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/01/hough-transform-for-circle-detection_18.html' title='Hough Transform For Circle Detection - with known radius (II)'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113715045856471003</id><published>2006-01-13T18:54:00.000+08:00</published><updated>2006-01-14T04:28:54.006+08:00</updated><title type='text'>Hough Transform For Circle Detection - with known radius (I)</title><content type='html'>Some examples using Hough Transform are shown in previous few examples. Firstly, we have look into how to use standard Hough Transform function from new version of image processing toolbox to classified different objects.(Refer to Object Detection using Hough Transform &lt;a href="http://basic-eng.blogspot.com/2005/12/object-detection-using-hough-transform.html"&gt;(I)&lt;/a&gt; and &lt;a href="http://basic-eng.blogspot.com/2005/12/object-detection-using-hough-transform_06.html"&gt;(II)&lt;/a&gt; ) Secondly, we have look into how to implement our own code for Hough Transform (Refer to &lt;a href="http://basic-eng.blogspot.com/2006/01/simple-code-for-hough-transform.html"&gt;Simple Code for Hough Transform&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;The second approach would be more flexible especially when we want to modified the Hought Transform to detect other shape other than line. In this example, a modified version of Hough Transform is used to detect the circle instead of line.&lt;br /&gt;&lt;br /&gt;In this case, instead of transforming the pixel to rho and theta domain, we use the circle equation --&gt; (x-a)^2 + (y-b)^2 = R^2 to map the pixel to a-b domain. Let's see how to perform this:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;1. Reading image and the convert to binary image. After that, the location of the value '1' is found using 'find' function. (assume the image is already preprocess, if not, the 'edge' function might help)&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;clear all;clc;&lt;br /&gt;I = imread('pic20.bmp');&lt;br /&gt;I =im2bw(I);&lt;br /&gt;[y,x]=find(I);&lt;br /&gt;[sy,sx]=size(I);&lt;br /&gt;imshow(I);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig1.8.png"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/fig1.0.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;2. Find all the require information for the transformatin. the 'totalpix' is the numbers of '1' in the image.&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;totalpix = length(x);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;3. Preallocate memory for the Hough Matrix. Try to play around with the R, or the radius to see the different results.&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;HM = zeros(sy,sx);&lt;br /&gt;R = 34;&lt;br /&gt;R2 = R^2;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;4. Performing Hough Transform. Notice the accumulator is located in the inner for loop. This portion of codes will map the original image to the a-b domain.&lt;/span&gt;&lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;b = 1:sy;&lt;br /&gt;&lt;br /&gt;for cnt = 1:totalpix&lt;br /&gt;a = (round(x(cnt) - sqrt(R2 - (y(cnt) - [1:sy]).^2)));&lt;br /&gt;for cnt2 =1:sy&lt;br /&gt;if isreal(a(cnt2)) &amp; a(cnt2)&gt;0&lt;br /&gt;HM(cnt2,a(cnt2)) = HM(cnt2,a(cnt2)) + 1;&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#993333;"&gt;&lt;strong&gt;&lt;u&gt;5. Showing the Hough Matrix&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;imshow(HM,[]);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig2.13.png"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/fig2.1.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;6. Finding the location of the circle with radius of R&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;[maxval, maxind] = max(max(HM));&lt;br /&gt;[B,A] = find(HM==maxval);&lt;br /&gt;imshow(I); hold on;&lt;br /&gt;plot(mean(A),mean(B),'xr')&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/fig3.1.png" border="0" /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113715045856471003?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113715045856471003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113715045856471003' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113715045856471003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113715045856471003'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/01/hough-transform-for-circle-detection.html' title='Hough Transform For Circle Detection - with known radius (I)'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113645068553999415</id><published>2006-01-05T19:39:00.000+08:00</published><updated>2006-01-05T19:05:02.206+08:00</updated><title type='text'>Simple Code for Hough Transform</title><content type='html'>Previous few examples using the Hough Transform function to perform the operation. However, Hough Transform function only available in new version of the tools. For those who are still using older version, this example shows a simple way of performing Hough Transform with a few lines of codes.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;1. Reading image and the convert to binary image. After that, the location of the value '1' is found using 'find' function. (assume the image is already preprocess, if not, the 'edge' function might help)&lt;br /&gt;&lt;/u&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;I = imread('pic20.jpg');&lt;br /&gt;I =im2bw(I);&lt;br /&gt;[y,x]=find(I);&lt;br /&gt;[sy,sx]=size(I);&lt;br /&gt;imshow(I);&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig1.3.jpg"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/fig1.0.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#993333;"&gt;&lt;strong&gt;&lt;u&gt;2. Find all the require information for the transformatin. the 'totalpix' is the numbers of '1' in the image, while the 'maxrho' is used to find the size of the Hough Matrix&lt;/u&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;totalpix = length(x);&lt;br /&gt;maxrho = round(sqrt(sx^2 + sy^2));&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;3. Preallocate memory for the Hough Matrix. The resolution for both rho and theta are set to one.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/u&gt;&lt;br /&gt;HM = zeros(2*maxrho,180);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;4. Performing Hough Transform. Notice the accumulator is located in the inner for loop.&lt;/u&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;for cnt = 1:totalpix&lt;br /&gt;cnt2 = 1;&lt;br /&gt;for theta = -pi/2:pi/180:pi/2-pi/180&lt;br /&gt;rho = round(x(cnt).*cos(theta) + y(cnt).*sin(theta));&lt;br /&gt;HM(rho+maxrho,cnt2) = HM(rho+maxrho,cnt2) + 1;&lt;br /&gt;cnt2 = cnt2 + 1;&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;theta = rad2deg(-pi/2:pi/180:pi/2-pi/180);&lt;br /&gt;rho = -maxrho:maxrho-1;&lt;br /&gt;imshow(uint8(HM),[],'xdata',theta,'ydata',rho);&lt;br /&gt;xlabel('\theta'),ylabel('\rho')&lt;br /&gt;axis on, axis normal;&lt;br /&gt;title('Hough Matrix');&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/fig2.0.jpg" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;5. Done! However, the code is quite slow, anyway, it works!&lt;/u&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113645068553999415?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113645068553999415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113645068553999415' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113645068553999415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113645068553999415'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/01/simple-code-for-hough-transform.html' title='Simple Code for Hough Transform'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113613753381107987</id><published>2006-01-02T01:31:00.000+08:00</published><updated>2006-01-02T01:45:33.830+08:00</updated><title type='text'>Signature of Binary Objects</title><content type='html'>&lt;p&gt;This example illustrates a simple way of converting the boundary of binary object into a 1-dimentional representation, or signature. One of the purpose of this conversion is to reduce the complexity of the representation for classification purpose. Let's have a look on how to convert the object to signature and compare the signature for different object shapes.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;1. Original image (value 0 represent background while 1 represents object).&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/u&gt;&lt;br /&gt;S = imread('pic19.jpg');&lt;br /&gt;S = im2bw(S);&lt;br /&gt;imshow(S);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig1.2.jpg"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig1.2.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;u&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;2. Get the boundary and plot them on top of the original image.&lt;/span&gt;&lt;/strong&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;[B,L,N,A] = bwboundaries(S);&lt;br /&gt;imshow(S);&lt;br /&gt;    for cnt = 1:N&lt;br /&gt;        hold on;&lt;br /&gt;        boundary = B{cnt};&lt;br /&gt;        plot(boundary(:,2), boundary(:,1),'r'); &lt;br /&gt;        hold on;&lt;br /&gt;        text(mean(boundary(:,2)), mean(boundary(:,1)),num2str(cnt));&lt;br /&gt;    end&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.8.png" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;figure;&lt;br /&gt;subplotrow = ceil(sqrt(N));&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;3. Plot the signature of each object.&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;for cnt = 1:N&lt;br /&gt;    boundary = B{cnt};&lt;br /&gt;    [th, r]=cart2pol(boundary(:,2)-mean(boundary(:,2)), ...&lt;br /&gt;    boundary(:,1)-mean(boundary(:,1)));&lt;br /&gt;    subplot(subplotrow,N/subplotrow,cnt);&lt;br /&gt;    plot(th,r,'.');&lt;br /&gt;    axis([-pi pi 0 50]);&lt;br /&gt;    xlabel('radian');ylabel('r');&lt;br /&gt;    title(['Object ', num2str(cnt)]);&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig3.0.jpg" border="0" /&gt;&lt;br /&gt;More details explanation could be found from the &lt;strong&gt;&lt;em&gt;&lt;span style="color:#993333;"&gt;image processing reference book&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt; which could be found at the site bar of this page&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113613753381107987?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113613753381107987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113613753381107987' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113613753381107987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113613753381107987'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2006/01/signature-of-binary-objects.html' title='Signature of Binary Objects'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113385531315052645</id><published>2005-12-06T13:51:00.000+08:00</published><updated>2005-12-06T19:30:47.250+08:00</updated><title type='text'>Object Detection using Hough Transform (II)</title><content type='html'>In previous post we've compare the Hough Matrix of a single dot, 2 dots and a single line. In this post, we'll look into more shapes:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;a. Square Object&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/img3.0.jpg" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;The right hand plot shows the frequencies of an intensity occurs in the Hough Matrix. It can also interpreted as: Number of lines that cross the number of points shown in the x-axis. For e.g.: for a dot, number of lines that cross one point is 180, for 2 dots image, number of lines that cross one point is 358, while number of lines that cross 2 points are 1. (refer to previous post)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;For a square object, numbers of lines that cross 1 point, 2 points.....until n points in which n is the lenght of the square (approximately) would be almost the same. This could be noticed in the right figure.&lt;/p&gt;&lt;p&gt;&lt;u&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;b. Round Object&lt;/span&gt;&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/img4.jpg" border="0" /&gt;For a round object, numbers of lines that cross 1 point, 2 points.....until n points in which n is the diameter of the round object (approximately) would be increase in exponently. This could be noticed in the right figure.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Well, there are much more information we could get from the Hough Matrix, and what I written here might be wrong in someway, so try it out by using different images with 1 dot, 2 dots, 3 dots... using the code provided in the previous post, you would find more and more useful information from the plots!&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113385531315052645?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113385531315052645/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113385531315052645' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113385531315052645'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113385531315052645'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/12/object-detection-using-hough-transform_06.html' title='Object Detection using Hough Transform (II)'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113378102459377273</id><published>2005-12-05T19:03:00.000+08:00</published><updated>2005-12-05T20:01:05.923+08:00</updated><title type='text'>Object Detection using Hough Transform (I)</title><content type='html'>Hough Transform convert the binary image from x-y plane to rho-theta plane. This series of examples are going to show some properties that we can observe from the hough matrix and classify some simple object shapes based on it. For more information on the Hough Transform, you can use any searh engine such as google or yahoo to searh for the keyword: "Hough Transform".&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc121572607"&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;1. Original image and convert to binary image&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;S = imread('img1.bmp');&lt;br /&gt;S = im2bw(S);&lt;br /&gt;imshow(S);&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc121572608"&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;2. Perform Hough Transform and show the result&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#33ccff;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;[H, theta,rho]=hough(S);&lt;br /&gt;figure;&lt;br /&gt;imshow(H,[],'xdata',theta,'ydata',rho);&lt;br /&gt;xlabel('\theta'),ylabel('\rho')&lt;br /&gt;axis on, axis normal;&lt;br /&gt;title('Hough Matrix');&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc121572609"&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;3. Count the "frequency" of the intensity of the Hough Matrix.&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;clear data;&lt;br /&gt;for cnt = 1:max(max(H))&lt;br /&gt;data(cnt) = sum(sum(H == cnt));&lt;br /&gt;end&lt;br /&gt;figure;&lt;br /&gt;plot(data,'.');&lt;br /&gt;&lt;br /&gt;The codes are applied to different images to compare the differences of&lt;br /&gt;the Hough Matrix on different objects' shapes.&lt;br /&gt;&lt;br /&gt;Some simple objects' shape and their Hough Matrix are as follow:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;a. Single Point&lt;/span&gt;&lt;br /&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/img1.jpg" border="0" /&gt;&lt;br /&gt;To obtain the Hough Transform, draw lines from -90 to 90 degree that cross the dot, follow by drawing a Perpendicular line from the upper left of the image to the line, and measure the lenght(rho) and the angle (theta) of the Perpendicular line. &lt;/p&gt;&lt;p&gt;The "hough" function will perform this for every 1 degree, and hence, for a single dot, the there will be 180 of '1' in the "Hough Matrix".&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;b. Two Points&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt; &lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/img1b.0.jpg" border="0" /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;When there are two points on an image, the Hough Matrix consist of 2 lines, and interect at a point which is a line that link the 2 points together in x-y plane (left figure). &lt;/p&gt;&lt;p&gt;Since there is only one intersection (only one line that link 2 points together), the frequencies of '1' in Hough Matrix is 358, while the frequencies of '2' is 1 in the Hough Matrix. (the '1' and '2' indicates how many time a rho-theta appear in the Hough Matrix)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="color:#993333;"&gt;c. Line&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/400/img2.jpg" border="0" /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;A line consists of numbers of points, ideally (the line is 45 degree) the intersection in the Hough Matrix will have the intensity same as the line lenght. &lt;/p&gt;&lt;p&gt;Hough Transform always used to detect lines in a real image, in which the edges always distorted. A higher value in the Hough Matrix indicates the higher possibility of the existence of a straight line.&lt;/p&gt;&lt;p&gt;More objects shapes will be shown in the next post...&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113378102459377273?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113378102459377273/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113378102459377273' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113378102459377273'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113378102459377273'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/12/object-detection-using-hough-transform.html' title='Object Detection using Hough Transform (I)'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113231193168669228</id><published>2005-11-18T19:01:00.000+08:00</published><updated>2005-11-20T03:20:23.866+08:00</updated><title type='text'>Maple for Image Processing?</title><content type='html'>&lt;strong&gt;&lt;span style="font-family:arial;color:#993333;"&gt;&lt;u&gt;Can Maple used for Image Processing?&lt;/u&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Maple is the tool for solving mathematical problems and creating interactive technical applications. My experience with Maple is that --&gt; a symbolic software.&lt;br /&gt;&lt;br /&gt;However, when I did a search on "maple image processing", I found the following link:&lt;br /&gt;&lt;/span&gt;&lt;a href="http://beta.mapleprimes.com/blog/jan/image_processing_with_maple"&gt;&lt;span style="font-family:arial;"&gt;Image Processing with Maple&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;br /&gt;Seems like the new version of Maple (or even older version) support basic image processing function, and it might be supporting more and more in the future...&lt;br /&gt;&lt;br /&gt;Some other software for image processing could be found at the sidebar, or you can simply do a search using google or yahoo..&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Keyword to search for : Matlab, Maple, Mathematica, Math Software, Image Processing Software, Image Analysis...&lt;/em&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113231193168669228?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113231193168669228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113231193168669228' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113231193168669228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113231193168669228'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/11/maple-for-image-processing.html' title='Maple for Image Processing?'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113223177097857593</id><published>2005-11-17T20:35:00.000+08:00</published><updated>2005-11-20T03:16:36.906+08:00</updated><title type='text'>Which Software to Use?</title><content type='html'>&lt;span style="font-family:arial;color:#993333;"&gt;&lt;strong&gt;&lt;u&gt;What Software Should be Used for Image Processing?&lt;/u&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;There are numbers of different software for engineering, each has its' capability and weakness. Most of the examples here use Matlab because I deal alot with Matlab in University.&lt;br /&gt;&lt;br /&gt;However, I won't say there are no other software better than Matlab, but i still believe:-&lt;br /&gt;&lt;br /&gt;"Choose the Software you're familiar with, know your direction and how far the software can accompany you along the way..."&lt;br /&gt;&lt;br /&gt;A good article comparing 3 famous software:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.computer.org/portal/site/cise/menuitem.92a12adebee18778161489108bcd45f3/index.jsp?&amp;pName=cise_level1_article&amp;amp;TheCat=1030&amp;path=cise/v7n3&amp;amp;amp;amp;amp;file=tech.xml&amp;amp;"&gt;&lt;span style="font-family:arial;"&gt;3Ms for Instruction: Reviews of Maple, Mathematica, and Matlab&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;br /&gt;Happy programming.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113223177097857593?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113223177097857593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113223177097857593' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113223177097857593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113223177097857593'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/11/which-software-to-use.html' title='Which Software to Use?'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113112595666158764</id><published>2005-11-05T01:26:00.000+08:00</published><updated>2006-01-09T08:35:42.966+08:00</updated><title type='text'>Drawing Circles Around Round Object</title><content type='html'>Drawing shapes to highlight certain objects could be done in several ways. Previous examples illustrate few ways of drawing object by overwriting pixel value as well as by adding a "patch" on top of an image. This example shows how to draw circles around a round object just simply using "plot" command&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;1. Original image&lt;/u&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;S = imread('pic13.jpg');&lt;br /&gt;S = im2bw(S);&lt;br /&gt;S2 = ~S;&lt;br /&gt;imshow(S2);&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig1.5.png" border="0" /&gt;&lt;br /&gt;&lt;span style="color:#993333;"&gt;&lt;strong&gt;&lt;u&gt;2. Extracting required objects' properties. Required properties are centroid and the area of the round objects. The area property is used to compute the radius of the object.&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;S3 = bwlabel(S2);&lt;br /&gt;S4 = regionprops(S3,'Centroid','area');&lt;br /&gt;R = sqrt(S4(1).Area/pi);&lt;br /&gt;h = S4(1).Centroid(1);&lt;br /&gt;k = S4(1).Centroid(2);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;3. Drawing circles around 1st object with different radius by refering to the radius of the object.&lt;br /&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;ratio = [2 1.5 1];&lt;br /&gt;nR = round(R*ratio);&lt;br /&gt;t = 0:pi/20:2*pi;&lt;br /&gt;x1 = (h+nR'*cos(t))';&lt;br /&gt;y1 = (k+nR'*sin(t))';&lt;br /&gt;hold on;&lt;br /&gt;plot(x1,y1);&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.7.png" border="0" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113112595666158764?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113112595666158764/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113112595666158764' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113112595666158764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113112595666158764'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/11/drawing-circles-around-round-object.html' title='Drawing Circles Around Round Object'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113112500473240453</id><published>2005-11-05T01:13:00.000+08:00</published><updated>2005-11-11T17:37:38.390+08:00</updated><title type='text'>Drawing Transparent Object</title><content type='html'>In one of the previous post (Drawing Shapes by Overwriting Pixel Value), a method of drawing transparent object had been illustrated using "Overwriting Pixel Value" technique. In this example, another method will be introduced without overwriting pivel value, but drawing a "Patch" on top of the image.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;1. Original image&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/u&gt;&lt;br /&gt;S = imread('pic12.jpg');&lt;br /&gt;S = im2bw(S);&lt;br /&gt;S2 = S;&lt;br /&gt;imshow(S2);&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig1.4.png" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;2. Define transparent object properties&lt;/u&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;transparency = 0.5;&lt;br /&gt;facecolor = [0 1 0];&lt;br /&gt;edgecolor = [0 1 0];&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;3. Creating and drawing transparent object&lt;/u&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;x = [0 20 20 0];&lt;br /&gt;y = [0 0 20 20];&lt;br /&gt;z = [1 1 1 1];&lt;br /&gt;tcolor(1,1,1:3) = facecolor;&lt;br /&gt;&lt;br /&gt;h = patch(x,y,z,tcolor,'FaceAlpha',transparency,'edgecolor',edgecolor);&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig2.6.png"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.6.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#993333;"&gt;&lt;u&gt;4. To move the object, simply set the "Xdata" and "Ydata" of the object without deleting current object and redrawing a new onject&lt;/u&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;set(h,'Xdata',x+20);&lt;br /&gt;set(h,'Ydata',y+20);&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig3.10.png" border="0" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113112500473240453?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113112500473240453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113112500473240453' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113112500473240453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113112500473240453'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/11/drawing-transparent-object.html' title='Drawing Transparent Object'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113108662029868049</id><published>2005-11-04T14:27:00.000+08:00</published><updated>2005-11-04T20:15:40.116+08:00</updated><title type='text'>Detecting Objects' Shape(III) : Triangle Object</title><content type='html'>&lt;p&gt;This example illustrates a simple method in detecting triangle object. This method is slightly different from the methods used for round object and square object detection in which the area and the perimeter of the objects are used to calculate the "score" of similarity. Instead, this method uses the "extrema" points of an object to determine whether the object is triangle.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. Original image and the negative image (value 0 represent background while 1 represents object). &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;S = imread('pic11.jpg');&lt;br /&gt;S = im2bw(S);&lt;br /&gt;S2 = ~S;&lt;br /&gt;imshow(S2);&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig1.3.png" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. Labeling the objects in the image. The advance programming language will support this function and label the objects.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;S3 = bwlabel(S2);&lt;br /&gt;imshow(S3,[]);&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.5.png" border="0" /&gt;&lt;br /&gt;&lt;strong&gt;3. In this example of triangle object detection, only one object property is extracted --&gt; "Extrema".&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;S4 = regionprops(S3,'Extrema','Centroid');&lt;br /&gt;&lt;br /&gt;The “Centriod” is just used for labeling purpose. Following figure shows what “Extrema” of an object is:&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig3.9.png" border="0" /&gt; &lt;strong&gt;4. Ideally, a triangle will only have 3 extrema points. However, due to the imperfection of a binary object, a few of close-by points might exist instead of one.&lt;/strong&gt;&lt;br /&gt;For example eight extrema points of a triangle are: (135.5,11.5),(136.5,11.5),(157.5,45.5),(157.5,47.5),(157.5,47.5),(112.5,4 7.5),(112.5,47.5),(112.5,45.5) first 2 points are referring to the upper corner of the triangle but the values are different. This applied to point 3 to 5 and points 6-8 too.&lt;br /&gt;&lt;br /&gt;In order to solve this problem, we need to cluster the points to their group based on the location of the points. Different ways could be used for clustering but since our topic is about image processing, image processing method will be used to group the similar points together.&lt;br /&gt;&lt;br /&gt;In this method, a morphology technique --&gt; dilation will be used. Firstly, the extrema points will be used to construct an image. The coordinates of the extrema points will be converted to points in an image. Let's look into one of the object for illustration:&lt;br /&gt;&lt;br /&gt;a. Create morphological structuring element.&lt;br /&gt;&lt;br /&gt;se = strel('disk',5);&lt;br /&gt;&lt;br /&gt;b. Round the extrema points for 5th object (pixel value must be integer)&lt;br /&gt;&lt;br /&gt;temp = round(S4(5).Extrema);&lt;br /&gt;&lt;br /&gt;c. Remap the coordinates by referring to the minimum values of x and y&lt;br /&gt;&lt;br /&gt;temp(:,1) = temp(:,1) - min(temp(:,1)) + 1;&lt;br /&gt;temp(:,2) = temp(:,2) - min(temp(:,2)) + 1;&lt;br /&gt;&lt;br /&gt;d. Create a zero matrix (black image)&lt;br /&gt;&lt;br /&gt;mask = zeros(max(temp(:,1)),max(temp(:,2)));&lt;br /&gt;&lt;br /&gt;e. Convert the coordinates to "objects" in the black image&lt;br /&gt;&lt;br /&gt;for cnt2 = 1:8&lt;br /&gt;mask(temp(cnt2,1),temp(cnt2,2))=1;&lt;br /&gt;end&lt;br /&gt;imagesc(mask);&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig4.png" border="0" /&gt;&lt;br /&gt;f. Do note that some of the points are close together; use the image dilation technique to group close-by points.&lt;br /&gt;&lt;br /&gt;mask2 = imdilate(mask,se);&lt;br /&gt;imagesc(mask2);&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig5.png" border="0" /&gt;&lt;br /&gt;g. Count number of real extrema points in the image&lt;br /&gt;&lt;br /&gt;[labeled,numObjects] = bwlabel(mask2,8);&lt;br /&gt;disp(numObjects);&lt;br /&gt;&lt;br /&gt;3&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5. The following codes perform calculation for all objects&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;se = strel('disk',5);&lt;br /&gt;for cnt = 1:length(S4)&lt;br /&gt;temp = round(S4(cnt).Extrema);&lt;br /&gt;temp(:,1) = temp(:,1) - min(temp(:,1)) + 1;&lt;br /&gt;temp(:,2) = temp(:,2) - min(temp(:,2)) + 1;&lt;br /&gt;mask = zeros(max(temp(:,1)),max(temp(:,2)));&lt;br /&gt;for cnt2 = 1:8&lt;br /&gt;mask(temp(cnt2,1),temp(cnt2,2))=1;&lt;br /&gt;end&lt;br /&gt;mask2 = imdilate(mask,se);&lt;br /&gt;[labeled,numObjects(cnt)] = bwlabel(mask2,8);&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;disp(numObjects);&lt;br /&gt;5 3 4 6 3 4 &lt;/p&gt;&lt;p&gt;score = (numObjects == 3);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;6. Display the result visually&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;imshow(S2)&lt;br /&gt;for cnt = 1:length(S4)&lt;br /&gt;text(S4(cnt).Centroid(1),S4(cnt).Centroid(2),num2str(score(cnt)),'color','red');&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig6.png" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113108662029868049?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113108662029868049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113108662029868049' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113108662029868049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113108662029868049'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/11/detecting-objects-shapeiii-triangle.html' title='Detecting Objects&apos; Shape(III) : Triangle Object'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113073029258602781</id><published>2005-10-30T11:35:00.000+08:00</published><updated>2005-10-31T12:59:15.423+08:00</updated><title type='text'>Detecting Objects' Shape(II) : Square Object</title><content type='html'>Detecting square object could be done in similar way we used to detect the round object. What we need to know is just the the formula for the area and the perimeter of a square object which is A = w^2 and P = 4*w.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc118521313"&gt;&lt;strong&gt;1. Original image and the negative image (value 0 represent background&lt;/strong&gt;&lt;/a&gt;&lt;a name="_Toc118521314"&gt;&lt;strong&gt; while 1 represent oject).&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;S = imread('pic10.jpg');&lt;br /&gt;S = im2bw(S);&lt;br /&gt;S2 = ~S;&lt;br /&gt;imshow(S2);&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig1.0.png" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc118521315"&gt;&lt;strong&gt;2. Labeling the objects in the image. The advance programming language&lt;/strong&gt;&lt;/a&gt;&lt;a name="_Toc118521316"&gt;&lt;strong&gt; will support this function and label the objects.&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;S3 = bwlabel(S2);&lt;br /&gt;imshow(S3,[]);&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.1.png" border="0" /&gt;&lt;br /&gt;&lt;a name="_Toc118521317"&gt;&lt;strong&gt;3. Some properties of the objects are extracted using the command. In&lt;/strong&gt;&lt;/a&gt;&lt;a name="_Toc118521318"&gt;&lt;strong&gt; this example, we just use the area and perimeter for our calculation.&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;S4 = regionprops(S3,'Area','Perimeter','centroid');&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc118521319"&gt;&lt;strong&gt;4. Now, evaluate the "squareness" of the objects. this is evaluated by&lt;/strong&gt;&lt;/a&gt;&lt;a name="_Toc118521320"&gt;&lt;strong&gt; only 1 criteria in this example:&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="_Toc118521321"&gt;&lt;strong&gt;a. Calculate the length or width of the object by using the formulas of&lt;/strong&gt;&lt;/a&gt;&lt;a name="_Toc118521322"&gt;&lt;strong&gt; area and perimeter, comparing the result and the square objects would&lt;/strong&gt;&lt;/a&gt;&lt;a name="_Toc118521323"&gt;&lt;strong&gt; have higher score than others. Do note that instead of for loop, the&lt;/strong&gt;&lt;/a&gt;&lt;a name="_Toc118521324"&gt;&lt;strong&gt; code below is a vectorized code.&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;score = (min(sqrt([S4.Area]),[S4.Perimeter]/4)./(max(sqrt([S4.Area]), ...[S4.Perimeter]/4))).^2;&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc118521325"&gt;&lt;strong&gt;5. Display the result visually&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;imshow(S2)&lt;br /&gt;for cnt = 1:length(S4)&lt;br /&gt;text(S4(cnt).Centroid(1),S4(cnt).Centroid(2),num2str(score(cnt)),'color','red');&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig3.2.png" border="0" /&gt;&lt;br /&gt;&lt;a name="_Toc118521326"&gt;Do note that this example assumes perfect images. For more accurate&lt;/a&gt;&lt;a name="_Toc118521327"&gt; results, more properties can be compared by using more criteria.&lt;/a&gt; The example above is done using MATLAB®.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;MATLAB® is registered trademarks of The MathWorks.&lt;/em&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113073029258602781?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113073029258602781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113073029258602781' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113073029258602781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113073029258602781'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/10/detecting-objects-shapeii-square.html' title='Detecting Objects&apos; Shape(II) : Square Object'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113048963597085162</id><published>2005-10-27T21:42:00.000+08:00</published><updated>2007-02-14T01:13:23.903+08:00</updated><title type='text'>Detecting Objects' Shape(I) : Round Object</title><content type='html'>With the powerful technical computing language, the job of detection an object's shape no longer require lengthy codes. What important is the fundamental of mathematic that define the properties of the shape of objects. Let's look into the detection of round object in this section.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. Original image and the negative image (value 0 represent background while 1 represents object).&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;S = imread('pic9.jpg');&lt;br /&gt;S = im2bw(S);&lt;br /&gt;S2 = ~S;&lt;br /&gt;imshow(S2);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig1.1.jpg" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. Labeling the objects in the image. The advance programming language will support this function and label the objects automatically.&lt;/strong&gt;&lt;br /&gt;S3 = bwlabel(S2);&lt;br /&gt;imagesc(S3);&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig2.1.jpg" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. Getting the properties of the objects that require for calculation, which are: the longest and shortest diameter for the object, the area and the perimeter of the object, and the centroid of the object.&lt;/strong&gt;&lt;br /&gt;S4 = regionprops(S3,'MinorAxisLength','MajorAxisLength','Area','Perimeter','centroid');&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4. Now, evaluate the "roundness" of the objects. this is evaluated by 3 criteria:&lt;br /&gt;a. Comparing the longest and shortest diameter for the object,&lt;br /&gt;b. Comparing the Area with the formula pi*r^2.&lt;br /&gt;c. Comparing the Perimeter with the formula 2*pi*r&lt;br /&gt;The "scores" are normalized so that 1 represent "best fit" &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;for cnt = 1:length(S4)&lt;br /&gt;score1(cnt) = abs(1-(S4(cnt).MajorAxisLength-S4(cnt).MinorAxisLength)...&lt;br /&gt;/max([S4(cnt).MajorAxisLength,S4(cnt).MinorAxisLength]));&lt;br /&gt;score2(cnt) = abs(1 - abs(pi*((mean([S4(cnt).MajorAxisLength,...&lt;br /&gt;S4(cnt).MinorAxisLength]))/2)^2-S4(cnt).Area)/S4(cnt).Area);&lt;br /&gt;score3(cnt) = abs(1 - abs(pi*(max([S4(cnt).MajorAxisLength,...&lt;br /&gt;S4(cnt).MinorAxisLength]))-S4(cnt).Perimeter)/S4(cnt).Perimeter);&lt;br /&gt;end&lt;br /&gt;score = mean([score1;score2;score3]);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5. Display the result visually&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;imshow(S2)&lt;br /&gt;for cnt = 1:length(S4)&lt;br /&gt;text(S4(cnt).Centroid(1),S4(cnt).Centroid(2),num2str(score(cnt)),'color','red');&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig3.0.png" border="0" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113048963597085162?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113048963597085162/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113048963597085162' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113048963597085162'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113048963597085162'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/10/detecting-objects-shapei-round-object.html' title='Detecting Objects&apos; Shape(I) : Round Object'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-113032695079635611</id><published>2005-10-26T19:33:00.000+08:00</published><updated>2006-01-20T17:23:52.720+08:00</updated><title type='text'>Playing with “Edge Detection”</title><content type='html'>A lot of articles explain what is edge detection, how to apply it, and the usage of it. Different edge detection techniques such as sobel, prewitt, and canny are easily found from any image processing software.&lt;br /&gt;&lt;br /&gt;However, when we really want to perform edge detection for certain purpose, the problems arise. Look at the following example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. Original image&lt;/strong&gt;&lt;br /&gt;S = imread('pic8.jpg');&lt;br /&gt;imshow(S);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/pic13.jpg" border="0" /&gt;&lt;br /&gt;&lt;strong&gt;2. Edge detection using different methods&lt;/strong&gt;&lt;br /&gt;S2 = rgb2gray(S);&lt;br /&gt;figure,edge(S2,'sobel');&lt;br /&gt;figure,edge(S2,'prewitt');&lt;br /&gt;figure, edge(S2,'canny');&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/pic25.jpg" border="0" /&gt;It seems like great but the usage of these output are useless until we really know what we want to do. For exmaple, we want to find the white rabbit, we need to perform some pre-processing before the edge detection so that we can fully utilize the function to suite to our needs.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. Edge detection for the white rabbit&lt;/strong&gt;&lt;br /&gt;Since we know the RGB value for white color is [255,255,255], we can pre-process the image to extract the white color region from the image.&lt;br /&gt;&lt;br /&gt;Sw = S(:,:,1)&gt;200 &amp; S(:,:,2)&gt;200 &amp;amp; S(:,:,3)&gt;200;&lt;br /&gt;edge(double(Sw));&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/pic33.jpg" border="0" /&gt;&lt;br /&gt;Well, it seems like make more sense. Let's have a look on how to perform edge detection on the black rabbit:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4. Edge detection for the black rabbit&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Sb = S(:,:,1)&lt;40 &amp; S(:,:,2)&lt;40 &amp; S(:,:,3)&lt;40;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/pic42.jpg" border="0" /&gt;The post processing can be used to remove unwanted noise.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-113032695079635611?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/113032695079635611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=113032695079635611' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113032695079635611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/113032695079635611'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/10/playing-with-edge-detection.html' title='Playing with “Edge Detection”'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-112954183899484951</id><published>2005-10-16T00:28:00.000+08:00</published><updated>2005-10-26T20:37:22.823+08:00</updated><title type='text'>Panoramic Picture Creation</title><content type='html'>This example illustrates simple method of panoramic picture creation using sum of absolute differences. It assumes no zooming, rotational variation in 2 images.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. Reading Images for processing&lt;/strong&gt;&lt;br /&gt;S1 = imread('p1.jpg');&lt;br /&gt;S2 = imread('p2.jpg');&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. Showing Images&lt;br /&gt;&lt;em&gt;1st Image&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;imshow(S1);&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig14.jpg" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;2nd Image&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;imshow(S2);&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig21.jpg"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig21.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. Extract red layer of the image for processing using Sum of Absolute Differences (SAD)&lt;/strong&gt;&lt;br /&gt;S1r = S1(:,:,1);&lt;br /&gt;S2r = S2(:,:,1);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4. Sum of Absolute Differences (SAD) of a selected block is from each image are computed.&lt;br /&gt;&lt;/strong&gt;sz = 50;&lt;br /&gt;roi2 = S2r(1:sz,1:sz);&lt;br /&gt;[x,y]=size(S2r);&lt;br /&gt;for cnt = y:-1:x/2&lt;br /&gt;roi1 = S1r(1:sz,cnt-sz+1:cnt);&lt;br /&gt;data(y-cnt+1)=sum(sum(abs(double(roi2)-double(roi1))));&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5. Finding minimum error among all comparison&lt;/strong&gt;&lt;br /&gt;plot(data)&lt;br /&gt;[minval,ind] = min(data);&lt;br /&gt;hold on;&lt;br /&gt;plot(ind,minval,'r*');&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig331.JPG"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig331.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;6. Combine the images at the minimum error region.&lt;br /&gt;&lt;/strong&gt;Sc = S1(1:end,1:y-sz-ind+1,:);&lt;br /&gt;Sfinal = [Sc S2];&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;7. Final Result&lt;/strong&gt;&lt;br /&gt;figure;&lt;br /&gt;imshow(Sfinal);&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig418.JPG" border="0" /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-112954183899484951?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/112954183899484951/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=112954183899484951' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112954183899484951'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112954183899484951'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/10/panoramic-picture-creation.html' title='Panoramic Picture Creation'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-112867731299168625</id><published>2005-10-06T23:59:00.000+08:00</published><updated>2006-05-01T08:07:16.796+08:00</updated><title type='text'>Character Recognition Example (III):Training a Simple NN for classification</title><content type='html'>After preprocess the image, the training dataset is used to train "classification engine" for recognition purpose. In this example, a multi-layer feed-forward back-propagation Neural Network will be used.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. Read the image&lt;/strong&gt;&lt;br /&gt;I = imread('sample.bmp');&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. Image Preprocessing&lt;/strong&gt;&lt;br /&gt;This cell of codes will extract all the components (objects) as descript in section II.&lt;br /&gt;&lt;br /&gt;img = edu_imgpreprocess(I);&lt;br /&gt;for cnt = 1:50&lt;br /&gt;bw2 = edu_imgcrop(img{cnt});&lt;br /&gt;charvec = edu_imgresize(bw2);&lt;br /&gt;out(:,cnt) = charvec;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. Creating Vectors data for the Neural Network (objects)&lt;/strong&gt;&lt;br /&gt;These few line of codes creates training vector and testing vector for the neural network. This is to match the input accepted by the neural network function. The front 4 rows will be used to train the network, while the last row will be used to evaluate the performance of the network. (Please refer to part I and II for the dataset)&lt;br /&gt;&lt;br /&gt;P = out(:,1:40);&lt;br /&gt;T = [eye(10) eye(10) eye(10) eye(10)];&lt;br /&gt;Ptest = out(:,41:50);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4. Creating and training of the Neural Network&lt;br /&gt;&lt;/strong&gt;Create and Train NN. The "edu_createnn" is a function file to create and train the network by accepting the training-target datasets&lt;br /&gt;&lt;br /&gt;net = edu_createnn(P,T);&lt;br /&gt;&lt;br /&gt;TRAINGDX, Epoch 0/5000, SSE 100.603/0.1, Gradient 46.9458/1e-006&lt;br /&gt;TRAINGDX, Epoch 20/5000, SSE 38.3704/0.1, Gradient 1.1137/1e-006&lt;br /&gt;TRAINGDX, Epoch 40/5000, SSE 39.4562/0.1, Gradient 0.485735/1e-006&lt;br /&gt;TRAINGDX, Epoch 60/5000, SSE 39.5979/0.1, Gradient 0.387782/1e-006&lt;br /&gt;TRAINGDX, Epoch 80/5000, SSE 39.6081/0.1, Gradient 0.387929/1e-006&lt;br /&gt;TRAINGDX, Epoch 100/5000, SSE 39.5559/0.1, Gradient 0.445316/1e-006&lt;br /&gt;TRAINGDX, Epoch 120/5000, SSE 39.2765/0.1, Gradient 0.758668/1e-006&lt;br /&gt;TRAINGDX, Epoch 140/5000, SSE 35.941/0.1, Gradient 1.34484/1e-006&lt;br /&gt;TRAINGDX, Epoch 160/5000, SSE 23.9786/0.1, Gradient 2.73872/1e-006&lt;br /&gt;TRAINGDX, Epoch 180/5000, SSE 1.57322/0.1, Gradient 0.898383/1e-006&lt;br /&gt;TRAINGDX, Epoch 196/5000, SSE 0.0909575/0.1, Gradient 0.0769913/1e-006&lt;br /&gt;TRAINGDX, Performance goal met.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/pic12.JPG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5. Testing the Neural Network&lt;/strong&gt;&lt;br /&gt;Simulate the testing dataset&lt;br /&gt;&lt;br /&gt;[a,b]=max(sim(net,Ptest));&lt;br /&gt;disp(b);&lt;br /&gt;&lt;br /&gt;1 2 3 4 5 6 7 8 9 10&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Do note that there might be some misclassifications on the simulated result with different training properties. The accuracy could be improved by better features extraction techniques as well as the selection of NN's properties.&lt;br /&gt;&lt;br /&gt;* MATLAB® is the registered trademarks for The MathWorks, Inc&lt;br /&gt;&lt;br /&gt;The relevant files can be found at:&lt;br /&gt;(link to the files will be provided soon…)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-112867731299168625?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/112867731299168625/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=112867731299168625' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112867731299168625'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112867731299168625'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/10/character-recognition-example.html' title='Character Recognition Example (III):Training a Simple NN for classification'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-112809299362317888</id><published>2005-09-30T22:56:00.000+08:00</published><updated>2007-01-04T04:41:34.566+08:00</updated><title type='text'>Character Recognition Example (II):Automating Image Pre-processing</title><content type='html'>Most of the time we would like to automate our image pre-processing stage especially during the data extraction for database. In other words, the program should be able to extract the characters one by obe and map the target output for training purpose. The following code shows the example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. &lt;/strong&gt;&lt;a name="_Toc115844939"&gt;&lt;strong&gt;Read Image&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;This cell of codes read the image to MATLAB workspace&lt;br /&gt;&lt;br /&gt;I = imread('sample.bmp');&lt;br /&gt;imshow(I)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig121.JPG" border="0" /&gt;&lt;br /&gt;&lt;strong&gt;2. &lt;/strong&gt;&lt;a name="_Toc115844940"&gt;&lt;strong&gt;Convert to grayscale image&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;This cell of codes convert the RGB to gray&lt;br /&gt;&lt;br /&gt;Igray = rgb2gray(I);&lt;br /&gt;imshow(Igray)&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig225.JPG" border="0" /&gt;&lt;br /&gt;&lt;strong&gt;3. &lt;/strong&gt;&lt;a name="_Toc115844941"&gt;&lt;strong&gt;Convert to binary image&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;This cell of codes convert the gray to binary image&lt;br /&gt;&lt;br /&gt;Ibw = im2bw(Igray,graythresh(Igray));&lt;br /&gt;imshow(Ibw)&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig330.JPG" border="0" /&gt;&lt;br /&gt;&lt;strong&gt;4. &lt;/strong&gt;&lt;a name="_Toc115844942"&gt;&lt;strong&gt;Edge detection&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;This cell of codes detect the edge of the image&lt;br /&gt;&lt;br /&gt;Iedge = edge(uint8(Ibw));&lt;br /&gt;imshow(Iedge)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig417.JPG" border="0" /&gt; &lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;5. &lt;/strong&gt;&lt;a name="_Toc115844943"&gt;&lt;strong&gt;Morphology&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;This cell of codes perform the image dilation and image filling on the image&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Image Dilation&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;se = strel('square',2);&lt;br /&gt;Iedge2 = imdilate(Iedge, se);&lt;br /&gt;imshow(Iedge2);&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig52.JPG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Image Filling&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;Ifill= imfill(Iedge2,'holes');&lt;br /&gt;imshow(Ifill)&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig61.JPG" border="0" /&gt;&lt;br /&gt;&lt;strong&gt;6. &lt;/strong&gt;&lt;a name="_Toc115844944"&gt;&lt;strong&gt;Blobs analysis&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;This cell of codes find all the objects on the image, and find the properties of each object.&lt;br /&gt;&lt;br /&gt;[Ilabel num] = bwlabel(Ifill);&lt;br /&gt;disp(num);&lt;br /&gt;Iprops = regionprops(Ilabel);&lt;br /&gt;Ibox = [Iprops.BoundingBox];&lt;br /&gt;Ibox = reshape(Ibox,[4 50]);&lt;br /&gt;imshow(I)&lt;br /&gt;&lt;br /&gt;50&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;7. &lt;/strong&gt;&lt;a name="_Toc115844945"&gt;&lt;strong&gt;Plot the Object Location&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;This cell of codes plot the object locations&lt;br /&gt;&lt;br /&gt;hold on;&lt;br /&gt;for cnt = 1:50&lt;br /&gt;rectangle('position',Ibox(:,cnt),'edgecolor','r');&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig71.JPG" border="0" /&gt;&lt;br /&gt;By this, we are able to extract the character and pass to another stage for "classification" or "training" purpose. (To be continue...) &lt;/p&gt;&lt;p&gt;&lt;br /&gt;* MATLAB® is the registered trademarks for The MathWorks, Inc&lt;/p&gt;&lt;p&gt;&lt;br /&gt;The required files can be found at:&lt;br /&gt;(link for the required files will be provided soon...) &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-112809299362317888?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/112809299362317888/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=112809299362317888' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112809299362317888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112809299362317888'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/09/character-recognition-example.html' title='Character Recognition Example (II):Automating Image Pre-processing'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-112809194425379089</id><published>2005-09-30T22:45:00.000+08:00</published><updated>2006-07-15T22:56:26.423+08:00</updated><title type='text'>Character Recognition Example (I): Image Pre-processing</title><content type='html'>This example illustrates simple way of character recognition. It just serves as a kick start for beginers by introducing them simple coding in MATLAB for character recognition.&lt;br /&gt;&lt;br /&gt;Some useful example for image pre-processing before the recognition stage is shown as follow:&lt;br /&gt;&lt;a name="_Toc115844619"&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;1. Manual Cropping&lt;br /&gt;&lt;/strong&gt;This cell of codes allow the user to crop the image manually, which is important proccess especially the programmer would like to manipulate the data more in details.&lt;br /&gt;&lt;br /&gt;img = imread('sample.bmp');&lt;br /&gt;imshow(img)&lt;br /&gt;imgGray = rgb2gray(img);&lt;br /&gt;imgCrop = imcrop(imgGray);&lt;br /&gt;imshow(imgCrop)&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig114.JPG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. &lt;/strong&gt;&lt;a name="_Toc115844620"&gt;&lt;strong&gt;Resizing&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;This cell of codes magnify the image for 5 times. Resize function is important when the size of the character are not standard, especially in the handwritting recognition program.&lt;br /&gt;&lt;br /&gt;imgLGE = imresize(imgCrop, 5, 'bicubic');&lt;br /&gt;imshow(imgLGE)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig213.JPG"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig213.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;3. &lt;/strong&gt;&lt;a name="_Toc115844621"&gt;&lt;strong&gt;Rotation&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;This cell of codes rotate the image for 35 degree. Some of the printed documents might not in the right degree as expected. This operation coulf make the character to our desired angle.&lt;br /&gt;&lt;br /&gt;imgRTE = imrotate(imgLGE, 35);&lt;br /&gt;imshow(imgRTE)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig314.JPG"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig314.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;4. &lt;/strong&gt;&lt;a name="_Toc115844622"&gt;&lt;strong&gt;Binary Image&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;This cell of codes convert the image to binary image. Definitely, the speed and also the accuracy will increse if this operation is perform properly.&lt;br /&gt;&lt;br /&gt;imgBW = im2bw(imgLGE, 0.90455);&lt;br /&gt;imshow(imgBW)&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig45.JPG" border="0" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-112809194425379089?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/112809194425379089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=112809194425379089' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112809194425379089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112809194425379089'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/09/character-recognition-example-i-image.html' title='Character Recognition Example (I): Image Pre-processing'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-112782124550615406</id><published>2005-09-27T19:31:00.000+08:00</published><updated>2006-01-02T11:33:21.340+08:00</updated><title type='text'>Detecting Object in an Image</title><content type='html'>1. &lt;strong&gt;How to&lt;/strong&gt; detect an object in an image?&lt;br /&gt;Determining the features from the object that you want to detect is the key. The feature in this case is something that differentiates the object from others, such as color, shape, size, etc…&lt;br /&gt;&lt;br /&gt;2. &lt;strong&gt;What are&lt;/strong&gt; the techniques for object detection?&lt;br /&gt;The image processing techniques such as morphology or color processing usually did this job. A simple example in MATLAB® of detecting ‘white rabbit’ is shown as follow, in this case, ‘color’ is the feature used to distinguish the white rabbit from other:&lt;br /&gt;&lt;br /&gt;% Original Image&lt;br /&gt;S = imread('pic3b.jpg');&lt;br /&gt;imshow(S);&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/img13.JPG" border="0" /&gt;&lt;br /&gt;% Gray scale image&lt;br /&gt;S2 = rgb2gray(S);&lt;br /&gt;imshow(S2);&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/img21.jpg" border="0" /&gt;&lt;br /&gt;% Find the white color&lt;br /&gt;S3 = S2&gt;180;&lt;br /&gt;imshow(S3);&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/img31.jpg" border="0" /&gt;&lt;br /&gt;% Morphology technique, image erosion to erase the unwanted components&lt;br /&gt;se = strel('line',10,90);&lt;br /&gt;S4 = imerode(S3,se);&lt;br /&gt;se = strel('line',10,0);&lt;br /&gt;S4 = imerode(S4,se);&lt;br /&gt;imshow(S4)&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/img4.jpg" border="0" /&gt;&lt;br /&gt;% Labeled the component(s), and plot the centroid on the original image&lt;br /&gt;S5 = bwlabel(S5);&lt;br /&gt;[x,y]=find(S6==1);&lt;br /&gt;imshow(S)&lt;br /&gt;hold on;plot(mean(y),mean(x),'r*')&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/img5.jpg" border="0" /&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;More information of image processing techniques can be found by searching "morphology", "morphological" from the search engine or the google search bar at the right hand site of this page.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;* MATLAB® is the registered trademarks for The MathWorks, Inc&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-112782124550615406?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/112782124550615406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=112782124550615406' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112782124550615406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112782124550615406'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/09/detecting-object-in-image.html' title='Detecting Object in an Image'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-112749006360420618</id><published>2005-09-23T23:30:00.000+08:00</published><updated>2006-04-09T04:12:22.166+08:00</updated><title type='text'>Drawing Shapes by Overwriting Pixel Value</title><content type='html'>1. &lt;strong&gt;How to &lt;/strong&gt;highlight certain portion on an image?&lt;br /&gt;The basic concept of highlighting part of an image is “Overwriting Pixel Value” on the image. We start from the basic idea on how to mask portion of image with blank sub-image (black color sub-image). Fig 1 shows the image with the size of 128x128x3 in which 3 represent s RGB. (In grayscale image 3 layers are the same). The image at the right hand site shows a blank sub-image is placed at the upper left of the original image. The MATLAB® code to perform the operation are as follow:&lt;br /&gt;&lt;br /&gt;S = imread('t3.jpg');&lt;br /&gt;imshow(S);&lt;br /&gt;Sblack = uint8(zeros(20,20,3));&lt;br /&gt;S2 = S;&lt;br /&gt;S2(1:20,1:20,:) = Sblack;&lt;br /&gt;imshow(S2); &lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig113.JPG" border="0" /&gt; &lt;p align="justify"&gt;Fig 1&lt;br /&gt;&lt;br /&gt;2. &lt;strong&gt;How to&lt;/strong&gt; create a color mask rather than black color mask?&lt;br /&gt;Since the 3 layers of image matrix represent RGB layers of the image, we can create the red color mask using following command, and the results are shown in fig 2.&lt;br /&gt;&lt;br /&gt;Sred = Sblack;&lt;br /&gt;Sred(:,:,1)=255;&lt;br /&gt;S2 = S;&lt;br /&gt;S2(1:20,1:20,:) = Sred;&lt;br /&gt;imshow(S2);&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig212.JPG" border="0" /&gt;&lt;br /&gt;Fig 2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. &lt;strong&gt;How to&lt;/strong&gt; create a transparent mask?&lt;br /&gt;Simple enough, just play with the values R value, and perform the image addition rather than overwriting the value as follow:&lt;br /&gt;&lt;br /&gt;Sred = Sblack;&lt;br /&gt;Sred(:,:,1)=200;&lt;br /&gt;S2 = S;&lt;br /&gt;S2(1:20,1:20,:) = S2(1:20,1:20,:) + Sred;&lt;br /&gt;imshow(S2); &lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig313.JPG" border="0" /&gt; &lt;p align="justify"&gt;Fig 3&lt;br /&gt;&lt;br /&gt;4. Finally, &lt;strong&gt;how to&lt;/strong&gt; create an outline for the image?&lt;br /&gt;&lt;br /&gt;linelength = 10;&lt;br /&gt;Sblack = uint8(zeros(128+linelength*2,128+linelength*2,3));&lt;br /&gt;S2 = Sblack;&lt;br /&gt;S2((1+linelength):(end-linelength),(1+linelength):(end-linelength),:)=S;&lt;br /&gt;imshow(S2); &lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig44.JPG" border="0" /&gt;&lt;/p&gt;Fig 4&lt;br /&gt;&lt;br /&gt;The “linelength” variable is the outline length in pixel. &lt;p align="justify"&gt;* MATLAB® is the registered trademarks for The MathWorks, Inc&lt;/p&gt;&lt;p align="justify"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-112749006360420618?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/112749006360420618/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=112749006360420618' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112749006360420618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112749006360420618'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/09/drawing-shapes-by-overwriting-pixel.html' title='Drawing Shapes by Overwriting Pixel Value'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16879618.post-112729447509420616</id><published>2005-09-21T16:58:00.000+08:00</published><updated>2005-10-31T13:45:45.023+08:00</updated><title type='text'>What is Image Compression?</title><content type='html'>&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig28.JPG"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/fig28.JPG"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This blog is not for the expert, but for those who like to ask, “what is..?” “how to..?” and “…so what?”. If you want the prove in the form of mathematic equations, this is not the right place you should come.&lt;br /&gt;&lt;br /&gt;&lt;p align="center"&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/img11.JPG"&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;No mathematic equation will be shown, but prove of the methods and the basic concepts of an algorithm and how to apply it in research, work, or “just for fun”.&lt;br /&gt;&lt;br /&gt;The very first topic that I would like to share is the concept of simple image compression. So the first question you might ask is:&lt;br /&gt;&lt;br /&gt;1. &lt;strong&gt;What is&lt;/strong&gt; image compression and how to perform image compression?&lt;br /&gt;Image compression is the technique to compress the image to save storage space as well as before transmitting it through some transmission medium. The most common method of image compression is discrete cosine transform (DCT). By taking the DCT of an original image, the low frequencies contents will be transform into the upper left of the DCT matrix… why…? Don’t ask me why, again, this blob is just for those what want to know “how to…?” and “…so what?” but not for “why…?”. If you would like to learn more on the image compression, you can use any search engine, or you might want to use the&lt;strong&gt;&lt;em&gt; Google search bar&lt;/em&gt;&lt;/strong&gt; on the right panel of this page to search for the “&lt;strong&gt;image compression&lt;/strong&gt;”. :)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. &lt;strong&gt;So what&lt;/strong&gt; after I know the DCT concept?&lt;strong&gt; How to&lt;/strong&gt; apply this into image compression?&lt;br /&gt;The low frequencies components, which also carry most of the information of the image, are our focus. The fig 1 shows the original image while fig 2 shows the DCT matrix for the image. Notice that the “white color” is concentrated at the upper left of the DCT matrix? That’s the “information (energy) for the image which also represents the low frequency components of the image. If we perform a inverse DCT for the fig 2, we will get back the fig 1.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="center"&gt;&lt;a href="http://photos1.blogger.com/blogger/82/1614/1600/img11.JPG"&gt;&lt;/a&gt;&lt;/p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig17.JPG" border="0" /&gt;&lt;br /&gt;3. &lt;strong&gt;How to&lt;/strong&gt; compress the image?&lt;br /&gt;Fig 2 is the DCT matrix of the image. If we through away the high frequencies components, which contain not much information (dark color portion), we can achieve certain level of compression. For example, if I just take quarter of the DCT matrix, I save 75% of the storage!&lt;br /&gt;&lt;br /&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig28.JPG" border="0" /&gt; &lt;p&gt;4. &lt;strong&gt;So what&lt;/strong&gt; is the tradeoff for this storage saving?&lt;br /&gt;We will get some distortion of the image after the reconstruction of the image using the Inversed DCT as shown in fig 4. The level of the distortion is depends on the level of compression you choose. Some visual comparisons are shown in the following figures.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/82/1614/320/fig310.JPG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;5. &lt;strong&gt;What software&lt;/strong&gt; can I use to work on the above example?&lt;br /&gt;You can use any search engine or the &lt;strong&gt;&lt;em&gt;Google search bar&lt;/em&gt;&lt;/strong&gt; on the right panel of this page and search for the “&lt;strong&gt;math software&lt;/strong&gt;”, you would find numbers of useful softwares to perform this.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16879618-112729447509420616?l=basic-eng.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://basic-eng.blogspot.com/feeds/112729447509420616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16879618&amp;postID=112729447509420616' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112729447509420616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16879618/posts/default/112729447509420616'/><link rel='alternate' type='text/html' href='http://basic-eng.blogspot.com/2005/09/what-is-image-compression.html' title='What is Image Compression?'/><author><name>tcl</name><uri>http://www.blogger.com/profile/00129522875781410013</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
