<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Shawn Lankton Online &#187; Projects</title>
	<atom:link href="http://www.shawnlankton.com/category/projects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shawnlankton.com</link>
	<description>life, business, consulting, and computer vision</description>
	<lastBuildDate>Mon, 26 Dec 2011 23:04:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>3D Vision with Stereo Disparity</title>
		<link>http://www.shawnlankton.com/2007/12/3d-vision-with-stereo-disparity/</link>
		<comments>http://www.shawnlankton.com/2007/12/3d-vision-with-stereo-disparity/#comments</comments>
		<pubDate>Wed, 19 Dec 2007 22:00:16 +0000</pubDate>
		<dc:creator>Shawn Lankton</dc:creator>
				<category><![CDATA[Matlab]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Vision]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[computer vision]]></category>
		<category><![CDATA[stereo vision]]></category>

		<guid isPermaLink="false">http://www.shawnlankton.com/2007/12/3d-vision-with-stereo-disparity/</guid>
		<description><![CDATA[2D is nice, but these days I&#8217;m getting interested in doing computer vision in 3D. One way to get 3D data is to use two cameras and determine distance by looking at the differences in the two pictures (just like eyes!). In this project I show some initial results and codes for computing disparity from [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.shawnlankton.com/2007/12/3d-vision-with-stereo-disparity/' title='Stereo Thumbnail'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/12/stereo_thumb.png' alt='Stereo Thumbnail' align='right'/></a>2D is nice, but these days I&#8217;m getting interested in doing computer vision in 3D.  One way to get 3D data is to use two cameras and determine distance by looking at the differences in the two pictures (just like eyes!).  In this project I show some initial results and codes for computing disparity from stereo images. <span id="more-281"></span></p>
<h2>Introduction</h2>
<blockquote><p><strong>UPDATE:</strong> <a href="http://www.shawnlankton.com/2008/04/stereo-vision-update-with-new-code/">Check this recent post</a> for a newer, faster version of this code.  The new version no longer relies on mean-shift.
</p></blockquote>
<p>People can see depth because they look at the same scene at two slightly different angles (one from each eye).  Our brains then figure out how close things are by determining how far apart they are in the two images from our eyes.  The idea here is to do the same thing with a computer.  Check this for some information on the <a href="http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/OWENS/LECT11/node4.html">geometry and mathematics of stereo vision</a>.  First, here are the images I&#8217;ll use to show results.</p>
<p><center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/12/stacked.png' title='Stacked Tsu Images'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/12/stacked.thumbnail.png' alt='Stacked Tsu Images' /></a></center></p>
<p>These two images are slightly different.  The top one is from the left and the bottom is from the right.  It&#8217;s a bit hard to see the disparity like this, so here are the same two images placed &#8220;on top&#8221; of one another.</p>
<p><center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/12/together.png' title='Tsu images smashed together'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/12/together.thumbnail.png' alt='Tsu images smashed together' /></a></center></p>
<p>You can see that the close-up objects like the lamp are very misaligned in the two images, while the farther-away things like the poster and the camera are lined up better.  The greater the misalignment, the closer the object.</p>
<p>This pair of images is one of many standard stereo pairs that can be found at the <a href="http://vision.middlebury.edu/stereo/">Middlebury stereo vision site</a>.  These guys keep a compendium of standard datasets as well as a scoreboard of who&#8217;s algorithms work the best.  The algorithm I talk about here is a knock-off of the one that was on top in December 2007: &#8220;<a href="http://www.google.com/url?sa=t&#038;ct=res&#038;cd=1&#038;url=http%3A%2F%2Fwww.vrvis.at%2Fpublications%2Fpdfs%2FVRVis_2006_05_22_16_20_00.pdf&#038;ei=JIlqR66AIqPGywSXytFC&#038;usg=AFQjCNHmGjB8ilAn_FjEkR3yM6HMeWsqag&#038;sig2=JgNCKIjiwxjGXKWSPsd5MQ">Segment-Based Stereo Matching Using Belief Propogation and a Self-Adapting Dissimilarity Measure[PDF]</a>&#8221; by Klaus, Sormann, and Karner.  (Mind that the algorithm here is *inspired* by the algorithm of Klaus <em>et al</em>.  Theirs is much more complete)</p>
<h2>Getting Pixel Disparity</h2>
<p>The first step here is to get an estimate of the disparity at each pixel in the image.  A reference image is chosen (in this case, the right image), and the other image slides across it.  As the two images &#8216;slide&#8217; over one another we subtract their intensity values.  Additionally, we subtract gradient information from the images (spatial derivatives).  Combining these gives better accuracy, especially on surfaces with texture.  In the video below, we can see a visualization of this process.  You&#8217;ll notice how far-away objects go dark (meaning they line up in the two images) at different times than close-up objects.  We record the offset when the difference is the smallest as well as the value of the difference.</p>
<p><center><object width="400" height="316"><param name="movie" value="http://www.youtube.com/v/LnzFcw0mXvo&#038;rel=0&#038;color1=0x234900&#038;color2=0x4e9e00&#038;border=0"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/LnzFcw0mXvo&#038;rel=0&#038;color1=0x234900&#038;color2=0x4e9e00&#038;border=0" type="application/x-shockwave-flash" wmode="transparent" width="400" height="316"></embed></object></center></p>
<p>We perform this slide-and-subtract operation from right-to-left (R-L) and left-to-right (L-R).  Then we try to eliminate bad pixels in two ways.  First, we use the disparity from the R-L pass or the L-R pass depending on which has the lowest matching difference.  Next, we mark as bad all points where the R-L disparity is significantly different from the L-R disparity.  Finally, we are left with a pixel disparity map.</p>
<p><center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/12/original_disparity.png' title='Pixel Disparity'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/12/original_disparity.thumbnail.png' alt='Pixel Disparity' /></a></center></p>
<p>In this image, red-er colors indicate closer pixels, and blue-er colors represent pixels that are farther away.</p>
<h2>Filtering the Pixel Disparity</h2>
<p>In the next step, we combine image information with the pixel disparities to get a cleaner disparity map.  First, we segment the reference image using a technique called &#8220;<a href="http://www.shawnlankton.com/2007/11/mean-shift-segmentation-in-matlab/">Mean Shift Segmentation</a>.&#8221;  This is a clustering algorithm that &#8220;over-segments&#8221; the image.  The result is a very &#8216;blocky&#8217; version of the original image.</p>
<p>Then, for each segment, we look at the associated pixel disparities.  In my simple implementation, we assign each segment to have the median disparity of all the pixels within that segment.  This gives the final result:</p>
<p><center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/12/filtered_disparity.png' title='Filtered Disparity'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/12/filtered_disparity.thumbnail.png' alt='Filtered Disparity' /></a></center></p>
<p>Here again, the red colors are close objects, and blue objects are far away.</p>
<h2>Matlab Code</h2>
<p>I spent some time getting these simple ideas into working form.  I&#8217;ve posted the codes and images I used as well as a demo script.  To see how the code works, simply un-archive everything and run <strong>demo</strong> from a Matlab prompt. Enjoy, and let me know how these work for you.</p>
<blockquote><p>
<a href="http://www.shawnlankton.com/wp-content/uploads/files/stereo_modefilt.zip">stereo_modefilt.zip</a> (New! <a href="http://www.shawnlankton.com/2008/04/stereo-vision-update-with-new-code/">Described here.</a>)<br/><br />
<del datetime="2009-07-02T17:55:52+00:00"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/12/lankton_stereo.tar.gz">lankton_stereo.tar.gz</a></del> (Old)
</p></blockquote>
<p>Check out the newest results:</p>
<p><center><br />
<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com/s/c/bin/slideshow.swf" width="400" height="267" flashvars="host=picasaweb.google.com&#038;RGB=0x000000&#038;feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fshawn.lankton%2Falbumid%2F5188210756103456801%3Fkind%3Dphoto%26alt%3Drss%26authkey%3DxyPWYtqp8GM" pluginspage="http://www.macromedia.com/go/getflashplayer"><br/>[red indicates close, blue indicates far away]</embed></center></p>
<h2>Conclusion</h2>
<p>This stereo algorithm is just a tool to be used on other projects.  For instance, by computing the stereo disparity of a stereoscopic video it is possible to improve tracking results by using the 3D information.  Also, segmentations can be made more accurate if 3D information is known.</p>
<p>I wanted to put this up to introduce people to stereo vision (as this was my introductory project).  Hopefully, the words and the codes above will save you some time getting up to speed.  I would ask that if you find this helpful and make improvements that you let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnlankton.com/2007/12/3d-vision-with-stereo-disparity/feed/</wfw:commentRss>
		<slash:comments>75</slash:comments>
		</item>
		<item>
		<title>Park-Find Business Plan</title>
		<link>http://www.shawnlankton.com/2007/04/park-find-business-plan/</link>
		<comments>http://www.shawnlankton.com/2007/04/park-find-business-plan/#comments</comments>
		<pubDate>Tue, 24 Apr 2007 22:00:13 +0000</pubDate>
		<dc:creator>Shawn Lankton</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Vision]]></category>
		<category><![CDATA[computer vision]]></category>
		<category><![CDATA[paper]]></category>
		<category><![CDATA[tracking]]></category>

		<guid isPermaLink="false">http://www.shawnlankton.com/2007/04/park-find-business-plan/</guid>
		<description><![CDATA[In this project I look at engineering from a different perspective&#8230; the business perspective. My team and I started with an idea: Track cars in a parking lot and use the information to help the whole operation run smoother. From there, we researched, though, and schemed until we had a sturdy business plan for the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.shawnlankton.com/2007/04/park-find-business-plan/"><img src='http://www.shawnlankton.com/wp-content/uploads/2007/09/park-find-thumb.png' alt='Park-Find Thumbnail' align='right' /></a>In this project I look at engineering from a different perspective&#8230; the business perspective.  My team and I started with an idea: <em>Track cars in a parking lot and use the information to help the whole operation run smoother.</em> From there, we researched, though, and schemed until we had a sturdy business plan for the new venture.<span id="more-203"></span></p>
<h2>Introduction</h2>
<p>There is a movie theater in Atlanta that is nearly impossible to park at.  It requires you to drive around endlessly to find a space.  It occurred to me one evening, that with cameras set up to watch the lot it would be possible to track all the cars and know where the available spaces were.  Then, movie-goers could get the map of all available spaces via an MMS message.</p>
<p>When I took &#8220;Technology Ventures&#8221; last semester in the College of Management a team and I worked together to design a business plan around this technology called &#8220;Park-Find&#8221;.  Over the course of the project we researched our competition, researched our target market, made analyses of costs to develop and produce the technology, and learned a great deal about what goes into planning a business.</p>
<p>Here I&#8217;ll summarize some parts of the business plan.  The full document, as well as a final presentation of the business (similar to a presentation that could be given to VC&#8217;s etc.) are available for download.  Finally we decided that although the technology could make money we didn&#8217;t want to launch the company because it seemed a bit too risky to out-weight the potential rewards.</p>
<h2>Abstract</h2>
<p>The pay parking management equipment industry of the United States is a $3.2 billion industry with immense potential for additional revenue. Current systems exist to provide total parking system management, but they fail to provide an efficient, secure system that is easy to use for both parker and lot owner.  Park-Find offers a solution that will change the way people think about parking. We offer a unique technology that allows parking lot owners to actively monitor and manage their lots via an autonomously running video tracking system.  With Park-Find, customers will increase their profitability with a solution that provides more benefit to parkers. Our industry analysis indicates that there is significant need for this type of product, and that there exists an opportunity to penetrate the market with our novel solution. Because of our strong intellectual property and strategic positioning in the market, we expect Park-Find to grow and become profitable as well as becoming an attractive acquisition to established parking solution providers.  Through careful positioning, we expect liquidation in the next five years.</p>
<p>In the business plan we address, among other things, the following areas:</p>
<ul>
<li>Executive Summary</li>
<li>Business Description</li>
<li>Product Offerings</li>
<li>Market and Industry Analysis</li>
<ul>
<li>Industry Background</li>
<li>Target Market</li>
<li>Market Size</li>
<li>Market Trends</li>
<li>Competitor Analysis</li>
<li>Product Appeal</li>
</ul>
<li>Marketing Plan</li>
<ul>
<li>Strategic Partnerships</li>
<li>Pricing</li>
<li>Promotion</li>
<li>Placement</li>
<li>Sustaining Competitive Advantage</li>
</ul>
<li>Operations</li>
<ul>
<li>Outsourcing and Strategic Partnership</li>
<li>Research and Development</li>
<li>Business Milestones</li>
</ul>
<li>Risk Assessment</li>
<li>Financial Plan</li>
<li>Exit Strategy</li>
</ul>
<p>Below are selected sections from the business plan.</p>
<h2>Venture Summary</h2>
<p>Parking is something that everyone is familiar with and nearly all of us do every day.  We have been trained to use various methods of payment and control that are scattered around to help owners and managers of parking systems deal with the volume of parkers that use their facilities everyday. Over the years, the technology used to manage parking has been changing. Spring-loaded mechanical parking meters led to digital parking meters.  Next, ticket-based machines were introduced, which can sometimes take cash or even credit card thus allowing someone to park without carrying a pocket full of change.</p>
<p>Park-Find is prepared to enter the market with the next step in parking management solutions.  Using our innovative technology, the gates and tickets of today will vanish.  No longer will people be required to wait in long lines to enter and exit.  Parking places can be found automatically.  Parking as an industry becomes more profitable, and parking your car becomes less of a chore.</p>
<p>This dream is made possible by recent developments in the field of computer vision.  New algorithms allow computers to take video from small wireless cameras placed in a parking facility, process the information, understand it, and produce a simple map of which spaces are available and which spaces are occupied.  From here, this map can be integrated with existing payment systems to streamline the process of payment, simplify management and enforcement, as well as give parkers hints about where to park to save time and effort.</p>
<h2>Value Proposition</h2>
<p>The parking management equipment industry is very large ($3.2 billion annually), and is perpetually re-invested in by pay-parking facilities nationwide.  Right now the market is in upheaval as companies are searching for a technology solution that fits the needs of the industry.  Park-Find, using its innovative vision-based solution, has the opportunity to leap past other technology providers in the industry and give customers a solution that far out-performs the status quo and even other radical technologies.</p>
<p>Based on industry research and engineering experience we expect the Park-Find product offering to have the ability to save our customers considerable amounts of money and thereby increase their profits.  We can do this for a lower cost and with greater profit margins than most competitors in the field. These factors blend to create a valuable opportunity for Park-Find to enter this market, help customers solve their problems, and in the process grow into a valuable company.</p>
<p><center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/09/park-find3.png' title='Park-Find Visual Aid'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/09/park-find3.thumbnail.png' alt='Park-Find Visual Aid' /></a></center></p>
<h2>Core Technology::Park-Watch Engine</h2>
<p>The Park-Watch Engine is the heart of Park-Findâ€™s product offering.  This system will use visual tracking algorithms to monitor cars in the parking structure.  Then based on their movements, a virtual map that shows the location of occupied and unoccupied spaces can be continuously updated.  The information contained in this map can then be used in various ways to help manage parking at the facility.</p>
<h2>Downloads</h2>
<blockquote>
<ul>
<li><a href='http://www.shawnlankton.com/wp-content/uploads/2007/09/park-find-business-plan.pdf' title='Park-Find Business Plan (pdf)'>Park-Find Business Plan (892k, pdf)</a></li>
<li><a href='http://www.shawnlankton.com/wp-content/uploads/2007/09/park-find-business-plan2.pdf' title='Park-Find Business Plan, Financials (pdf)'>Park-Find Business Plan, Financial Appendicies (148k, pdf)</a></li>
<li><a href='http://www.shawnlankton.com/wp-content/uploads/2007/09/park-find-presentation.pdf' title='Park-Find Presentation Slides (pdf)'>Park-Find Presentation Slides (892k, pdf)</a></li>
</ul>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnlankton.com/2007/04/park-find-business-plan/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Visual Tracking</title>
		<link>http://www.shawnlankton.com/2007/04/visual-tracking/</link>
		<comments>http://www.shawnlankton.com/2007/04/visual-tracking/#comments</comments>
		<pubDate>Tue, 03 Apr 2007 22:00:36 +0000</pubDate>
		<dc:creator>Shawn Lankton</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Vision]]></category>
		<category><![CDATA[computer vision]]></category>
		<category><![CDATA[tracking]]></category>
		<category><![CDATA[videos]]></category>

		<guid isPermaLink="false">http://www.shawnlankton.com/wordpress/?p=106</guid>
		<description><![CDATA[My newest research focus has moved away from medical images and towards moving images&#8230; And instead of finding organs and tumors, I&#8217;m tracking moving objects in the videos. Check out some of my latest successes (and failures). Introduction So, I&#8217;ve said before that Computer Vision is teaching computers to understand images.&#160; Well, I&#8217;m currently working [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.shawnlankton.com/2007/04/visual-tracking/"><img src="http://www.shawnlankton.com/files/vidtrack/thumb.jpg" align="right" height="75" width="75" /></a>My newest research focus has moved away from medical images and towards moving images&#8230; And instead of finding organs and tumors, I&#8217;m tracking moving objects in the videos.  Check out some of my latest successes (and failures).<span id="more-106"></span></p>
<h2>Introduction</h2>
<p>				So, I&#8217;ve said before that Computer Vision is teaching computers to <i>understand</i> images.&nbsp; Well, I&#8217;m currently working on a slightly new problem.&nbsp; Now I&#8217;m trying to teach computers to understand movies!</p>
<p>				The idea in most visual tracking is: given the location of an object in the first frame of the movie, follow it through the whole video.</p>
<h2>Applications</h2>
<p>				This has lots of applications.&nbsp; Many of them are defense-related, but tracking is also very important in medicine, security, robotics, manufacturing, exploration, etc. etc&#8230;</p>
<h2>How it works</h2>
<p>				Yikes! I&#8217;m pretty busy learning about that right now, but I plan to put some tutorials and source code here soon.&nbsp; In the meantime, feel free to email me.</p>
<h2>Results</h2>
<p>				Ahhh, here&#8217;s the good part!&nbsp; Videos!&nbsp; What you see here are black and white videos of either cars or people.&nbsp; The colored boxes represent where the computer has determined the &quot;targets&quot; to be.&nbsp; You can see that the boxes follow the &quot;targets&quot; as they move around in the scene.</p>
<p align="center">
			<object height="316" width="400"><param name="movie" value="http://www.youtube.com/v/otUhFkHSAxc"><embed src="http://www.youtube.com/v/otUhFkHSAxc" type="application/x-shockwave-flash" height="316" width="400"></embed></object>
			</p>
</p>
<p align="center"><object height="316" width="400"><param name="movie" value="http://www.youtube.com/v/NQFNfSVo9S8"><embed src="http://www.youtube.com/v/NQFNfSVo9S8" type="application/x-shockwave-flash" height="316" width="400"></embed></object>
			</p>
<h2>Conclusion</h2>
<p>			I hope you liked these results&#8230; There will be lots more to come soon, as this is my new primary research focus.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnlankton.com/2007/04/visual-tracking/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Hybrid Segmentation</title>
		<link>http://www.shawnlankton.com/2007/02/cool-hybrid-segmentation/</link>
		<comments>http://www.shawnlankton.com/2007/02/cool-hybrid-segmentation/#comments</comments>
		<pubDate>Sat, 10 Feb 2007 22:00:28 +0000</pubDate>
		<dc:creator>Shawn Lankton</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Vision]]></category>
		<category><![CDATA[computer vision]]></category>
		<category><![CDATA[paper]]></category>
		<category><![CDATA[segmentation]]></category>
		<category><![CDATA[videos]]></category>

		<guid isPermaLink="false">http://www.shawnlankton.com/wordpress/?p=107</guid>
		<description><![CDATA[This algorithm analyzes statistics in small local regions of an image to try and separate the foreground from the background. This is an active contour segmentation technique, meaning a curve (or surface) is deformed over time to iteratively improve the segmentation until an optimum is reached. Introduction One of the main aspects of computer vision [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.shawnlankton.com/2007/02/cool-hybrid-segmentation/"><img src="http://www.shawnlankton.com/files/hybridseg/thumb.jpg" align="right" height="75" width="75" /></a>This algorithm analyzes statistics in small local regions of an image to try and separate the foreground from the background.  This is an active contour segmentation technique, meaning a curve (or surface) is deformed over time to iteratively improve the segmentation until an optimum is reached.<span id="more-107"></span></p>
<h2>Introduction</h2>
<p>One of the main aspects of computer vision is finding the appropriate outline of shapes in images. This is useful for analyzing â€œnatural imagesâ€ like the ones taken from a camera or medical images such as 3D MRI scans of the brain. This project began by trying to define the boundary of a particularly tricky structure in the brain called the putamen.</p>
<p><center><a href="http://www.shawnlankton.com/wp-content/uploads/2007/06/figure1.png" title="Hybred Seg, Figure 1"></a><a href="http://www.shawnlankton.com/wp-content/uploads/2007/06/figure1.png" title="Hybred Seg, Figure 1"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/06/figure1.thumbnail.png" alt="Hybrid Seg, Figure 1" /></a></center></p>
<p>I first developed a solution that worked, then analyzed it to figure out the mathematical principles behind what I was doing.  In the end, a very nice technique was discovered that is both highly effective and mathematically sound.  This idea was first submitted to a conference in August 2006.  It was subsequently published in March 2007.</p>
<p>Shawn Lankton, Delphine Nain, Anthony Yezzi, Allen Tannenbaum. Hybrid Geodesic Region-Based Curve Evolutions for Image Segmentation. In Proceedings of SPIE Medical Imaging, San Diego, 2007. [<a href="http://www.shawnlankton.com/files/hybridseg/Lankton-Hybrid_geodesic_region-based-SPIE-2007.pdf">pdf</a>]</p>
<p>(<a href="http://www.shawnlankton.com/files/hybridseg/Lankton_Hybrid_Flow_Poster_SPIE_2007.pdf">Poster</a> presented at conference.)</p>
<p>Below is a very high-level summary of the paper along with some results and a code demo.</p>
<h2>Abstract</h2>
<p>This paper presents a novel segmentation technique (Segmentation is the process of detecting the boundary of an object in an image.  This can be 2D or 3D images).  This technique is based off of two well known classes of techniques, but combines the two in a clever way that allows it to capture benefits of both methods.  These two methods are: <a href = "http://www.iua.upf.es/~vcaselles/papers_v/GAC_article.pdf">gradient-based active contours</a>, and <a href="http://www.csee.wvu.edu/~tmcgraw/cs593spring2006/chanvese.pdf">region-based active contours</a>.  The mechanism of our solution is to start from a naive initial curve, and then move each point on the curve based on analysis of the statistics of the local interior and exterior regions.</p>
<h2>Level Set Active Contours</h2>
<p>Active contour methods begin with an initial curve and define some cost for that curve based on its geometric properties and the associated image data. Cost based on the geometry is provided to keep the curve smooth, and cost based on the image data are intended to attract the contour to object boundaries. This curve is then deformed in the way needed to decrease the cost thus moving the curve toward a position where cost is locally minimized. Presumably this occurs when the curve is correctly situated on the object.</p>
<h2>Related Work</h2>
<p>Essentially what we are doing is combining the ideas of â€œEdge-basedâ€ flows and â€œRegion-basedâ€ flows.</p>
<p>Edge-based flows use an <a href="http://www.pages.drexel.edu/~weg22/edge.html">edge detector</a> to find edges, then try to fit a curve nicely on those detected edges. The problem is that these methods only look at very local image information. That means that it is very susceptible to noise, and the initial placement of the curve.  For a reference, check this paper: <a href = "http://www.iua.upf.es/~vcaselles/papers_v/GAC_article.pdf">Geodesic Active Contours by Caselles, <em>et al.</em></a> </p>
<p>Region-based flows take an alternate approach. They try to model the global characteristics of entire regions of the image. This approach is nice because its very robust to initialization and noise, but sometimes images can&#8217;t be modeled well in terms of global rules and erroneous segmentations occur.  For a reference, check this paper: <a href="http://www.csee.wvu.edu/~tmcgraw/cs593spring2006/chanvese.pdf">Active Contours Without Edges by Chan and Vese</a></p>
<h2>The Hybrid Flow</h2>
<p>The hybrid flow aims to blend the benefits of the geodesic active contours and the region based active contours. This is accomplished by forming a cost based on a shortest weighted path.  The weights at each point along the path are determined from local regions around the curve. The resulting flow is more robust to initial curve placement and image noise like region-based flows, but also capable of finding significant local minima and partitioning the image without making global assumptions about its makeup.</p>
<p>The key assumption that we make about ob jects to be segmented by this technique is this: At each point on the true edge of an object, nearby points inside and outside the ob ject will be modeled well by the mean intensities of the local regions. The result is an energy that is more global in nature than edge-based flows.</p>
<p>The cost of the entire curve is often called an &#8216;energy.&#8217;  In the definition of this hybrid energy we use several notations.  I represents the image, and <em>x</em> and <em>s</em> represent independent spatial variables.  Omega and Omega-bar represent the interior and exterior of the curve respectively.  Chi, in the equations below, represents a ball centered at the point <em>s</em> that specifies the local region being examined.</p>
<p><center><a href="http://www.shawnlankton.com/wp-content/uploads/2007/06/figure2.png" title="Hybrid Seg, Figure 2"></a><a href="http://www.shawnlankton.com/wp-content/uploads/2007/06/figure2.png" title="Hybrid Seg, Figure 2"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/06/figure2.thumbnail.png" alt="Hybrid Seg, Figure 2" /></a></center></p>
<p>We define the ul and vl functions:</p>
<p><center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/09/equation2.png' title='Equation 2'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/09/equation2.thumbnail.png' alt='Equation 2' /></a><br />
<a href='http://www.shawnlankton.com/wp-content/uploads/2007/09/equation3.png' title='Equation 3'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/09/equation3.thumbnail.png' alt='Equation 3' /></a></center>,</p>
<p>in terms of local sums (SIl and SEl) and local areas (AIl, AEl).  Based on these notations, we can define the hybrid energy:</p>
<p><center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/09/equation1.png' title='Equation 1'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/09/equation1.thumbnail.png' alt='Equation 1' /></a></center>.</p>
<p>In this energy we use an outer integral over <em>s</em> to cover the points along the curve.  Then, in the inner integrals we use <em>x</em> to inspect the entire domain restricted by the Chi function so that the only contribution in from image information in the local neighborhood around the point <em>s</em>.  The energy around each point <em>s</em> is a function of how well the interior and exterior are modeled by their means, ul and vl.  The total energy is the sum of the contribution of energy from every point around the curve.</p>
<p>Using the calculus of variations, it is possible to take the derivative of this energy with respect to the shape of the curve itself.  Hence, we find the way to deform the curve such that this energy is always decreasing.  By decreasing the energy in an iterative fashion, we continuously refine our guess at the correct answer until we finally converge on the local minimum solution.</p>
<h2>Results</h2>
<p>Here are two experiments run with this flow.  In each set, you see the initial contour (in red), and then the result of three different techniques: a typical region-based technique, an edge-based technique, and the presented hybrid technique.  In all cases, the hybrid method outperforms all others.</p>
<p>First a synthetic image designed specifically to foil the other algorithms.</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/06/figure3.png" title="Hybrid Seg, Figure 3"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/06/figure3.png" title="Hybrid Seg, Figure 3"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/06/figure3.thumbnail.png" alt="Hybrid Seg, Figure 3" /></a></p>
<p>The next experiment is an MRI image of the putamen.  This is a small structure in the sub-cortex of the brain.</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/06/figure4.png" title="Hybrid Seg, Figure 4"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/06/figure4.png" title="Hybrid Seg, Figure 4"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/06/figure4.thumbnail.png" alt="Hybrid Seg, Figure 4" /></a></p>
<p>As you can see, there is significant improvement with the hybrid method.</p>
<h2>Conclusion</h2>
<p>The presented technique combines the ideas of geodesic and region-based active contours and as a result produces a segmentation algorithm which has benefits of both. Like other geodesic models, this approach is capable of looking locally for correct solutions while only making weak assumptions about global image properties. Also, as with region based models, our method has increased robustness to noise and reduced dependence on initial curve placement as a result of taking image data from local regions. The algorithm has proven to be more versatile than either of the two standard techniques presented, even in its simplest form.</p>
<p>Despite its benefits, this method still has some drawbacks. As with all geometric-based energies, initial curve placement is still important. Although this algorithm is less dependent than some, it is still necessary to initialize the contour nearby the object to be segmented or risk that the final segmentation result will converge at an incorrect local minima. Additionally, the key assumption made about image makeup is not ideal for all images.  There are cases where the ideal border of an ob ject is not characterized by a separation of image intensities at that border.</p>
<p>The method presented here is merely the first application of a new class of energy functionals based around combining local and global flows. The ability to define a geodesic energy with respect to local regions of image data has many possible applications. Extension of the implementation to accommodate higher order statistics, vector valued images, and images of higher dimensionality will improve performance and open the door to other potential applications.</p>
<p>Many of these improvements will be addressed in my future publications.</p>
<h2>Demo</h2>
<p>Check out this Matlab code to see an example of this technique in action.</p>
<blockquote><p>
<a href="http://www.shawnlankton.com/wp-content/uploads/files/hybridseg/localized_seg.zip">localized_seg.zip</a>
</p></blockquote>
<p>Feel free to <a href="http://www.shawnlankton.com/contact">contact me</a> with any questions, comments, or improvements on the code!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnlankton.com/2007/02/cool-hybrid-segmentation/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Trashbot</title>
		<link>http://www.shawnlankton.com/2006/05/trashbot/</link>
		<comments>http://www.shawnlankton.com/2006/05/trashbot/#comments</comments>
		<pubDate>Sat, 06 May 2006 20:00:08 +0000</pubDate>
		<dc:creator>Shawn Lankton</dc:creator>
				<category><![CDATA[Matlab]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[robots]]></category>

		<guid isPermaLink="false">http://www.shawnlankton.com/wordpress/?p=122</guid>
		<description><![CDATA[I had a lot of fun &#8220;teaching&#8221; a Sony Aibo to find and pick up &#8220;trash.&#8221; This project uses some rudimentary computer vision, simple tracking, audio location, and neural network classification. Plus, its cute! Introduction This was a class project for a grad class at Georgia Tech on robotics. The course was a bit of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.shawnlankton.com/2006/05/trashbot/"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/thumb1.jpg" alt="Trashbot Thumbnail" align="right" /></a>I had a lot of fun &#8220;teaching&#8221; a Sony Aibo to find and pick up &#8220;trash.&#8221;  This project uses some rudimentary computer vision, simple tracking, audio location, and neural network classification.  Plus, its cute!<span id="more-122"></span></p>
<h2>Introduction</h2>
<p>This was a class project for a grad class at Georgia Tech on robotics.  The course was a bit of a survey, and as such, the final project is a bit reflective of this.  It covers a little bit of everything from vision (my specialty), to tracking (my other specialty&#8230; now), to locomotion, to neural networks.  It was a ton of fun to do&#8230; enjoy!</p>
<p>Below is a description of the project along with our solutions to several problems&#8230; Finally, at the end you can find our project code.</p>
<p>I&#8217;d like to send a shout out to my  two esteemed collegues on this project: Brad Schwagler, and Brian Stefanovic.</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/brian_and_brad1.jpg" title="brian_and_brad1.jpg"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/brian_and_brad1.jpg" title="brian_and_brad1.jpg"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/brian_and_brad1.thumbnail.jpg" alt="brian_and_brad1.jpg" /></a></p>
<p>Now, before we start, I&#8217;d like to whet your appetites with a little video demo:</p>
<p align="center">&nbsp;</p>
<p><a href="http://www.shawnlankton.com/wp-admin/" style="left: 0px ! important; top: 0px ! important" title="Click here to block this object with Adblock Plus" class="abp-objtab visible ontop"></a><embed src="http://www.youtube.com/v/2SvlEV2RVUU" type="application/x-shockwave-flash" height="316" width="400"></embed></p>
<h2>Motivation</h2>
<p>This robot, is really just a cute project to play around with the Aibo.  However, we made up a whole &#8220;back story&#8221; so, here it is:  There are disorganized objects in the world such as litter, household clutter, etc.</p>
<p>It sure would be nice if there was a robot that could find, classify, acquire and put away that stuff!  Lets make the Aibo do that!  So, we used green geometric shapes to represent &#8220;trash.&#8221;  The dog finds, classifies, and picks up the trash, then brings it to a base station.</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/cute_aibo.jpg" title="Cute Aibo"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/cute_aibo.jpg" title="Cute Aibo"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/cute_aibo.thumbnail.jpg" alt="Cute Aibo" /></a></p>
<h2>Locomotion &amp; Implementation</h2>
<p>We used URBI &amp; liburbi for Matlab for all the programming.  I&#8217;m a big fan of Matlab, of course, and the URBI package made interfacing to the Aibo a breeze.  URBI also has a bunch of built-in functions for locomotion.  Also, you can use the Webots simulator to play with the Aibo virtually&#8230; This is great if A) you don&#8217;t have an Aibo, or B) you don&#8217;t want to deal with charging its batteries!</p>
<h2>Sensing</h2>
<p>We used rangefinders for a basic collision avoidance and for localizing on the object when we were ready to pick it up.  To do this, we recorded the distance the robot sees when looking &#8220;at infinity&#8221; as its head sweeps around  Then, we compare that with the values we get in situ to make sure there&#8217;s an object there.</p>
<p>We also use some cooler sensors like stereo microphones, and vision.</p>
<h2>Audiolocation</h2>
<p>We wanted the robot to be able to return to a &#8220;home base&#8221; with his collected &#8220;trash.&#8221;  To do this, we had the base broadcast a tone ( we wanted it to be supersonic, but the mics weren&#8217;t good enough, so we used 2kHz).</p>
<p>Then, based on the phase difference in the two microphones, we determined the angle to the source.  This is a technique known as <a href="http://en.wikipedia.org/wiki/Phase_interferometry">Phase Interferometry</a>.  Below are some phase plots from the left and right ears&#8230; As you can see, there&#8217;s not a huge amount of difference to work with.</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/phase_diagram.png" title="Phase Diagram"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/phase_diagram.png" title="Phase Diagram"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/phase_diagram.thumbnail.png" alt="Phase Diagram" /></a></p>
<h2>Vision</h2>
<p>Since we cheated a little and made all of our objects green, segmentation was simplified somewhat.  Here&#8217;s a sample image from Aibo&#8217;s camera:</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision1.png" title="Vision 1"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision1.png" title="Vision 1"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision1.png" alt="Vision 1" /></a></p>
<p>We mapped our image to a chromatic color space known as YBR.  This has three components like the familiar RGB, but Y is intensity (the grayscale version of this image), and B and R are the percentage of red and blue respectively that make up the intensity.  Here are the three channels we get:</p>
<p align="center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision2.png" title="Vision 2"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision2.png" alt="Vision 2" /></a> <a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision3.png" title="Vision 3"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision3.png" alt="Vision 3" /></a> <a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision4.png" title="Vision 4"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision4.png" alt="Vision 4" /></a></p>
<p>Notice how the box stands out a bit better in this space (its the only green thing).  Now, based on some training data, we produced a probability distribution function for the objects very similarly to these guys.  Based on this probability we can extract something like this:</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision5.png" title="Vision 5"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision5.png" title="Vision 5"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision5.png" alt="Vision 5" /></a></p>
<p>Then, with a little morphology, we turn it into this beauty:</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision6.png" title="Vision 6"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision6.png" title="Vision 6"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/vision6.png" alt="Vision 6" /></a></p>
<p>These segmentations are important for tracking the object (we extract its centroid), and for classification&#8230; You&#8217;ll see that one in a bit..</p>
<h2>Tracking</h2>
<p>So, with these segmentations the tracking is pretty simple.  We use this handy little algorithm:</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/flow_3.png" title="Flowchart for Tracking"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/flow_3.png" title="Flowchart for Tracking"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/flow_3.thumbnail.png" alt="Flowchart for Tracking" /></a></p>
<p>&#8220;Find Object&#8221; step consist of taking an image, segmenting it, and finding how many degrees from center the object is.  Then if we loose the object we look around for it.  This ends up being pretty tedious because the Aibo locomotion package we were using wasn&#8217;t great.</p>
<h2>Classification</h2>
<p>The geometric shapes that represented different kinds of &#8220;trash&#8221; were cubes, spheres, and tetrahedrons.  We used a neural net for classifying the objects.  We tried a bunch of features before finding one that worked well.  The trick finally ended up being border angles.  We computed the angle from one point to the next along the border of the shapes.  The results look a bit like this:</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/angles_diagram.png" title="Diagram of Object Angles"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/angles_diagram.png" title="Diagram of Object Angles"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/angles_diagram.thumbnail.png" alt="Diagram of Object Angles" /></a></p>
<p>Notice the four levels for the cube, the sinusoid for the sphere, and the three levels for the tetrahedron.  This ended up being a great way to do shape classification with neural networks!</p>
<p>We used a backpropogation network with 70 inputs and two outputs (00 = cube, 01 = sphere, 10 = tetra).  Our network had 150 nodes in the hidden layer.  We did the whole implementation with the Matlab toolbox.</p>
<p>Also, to make this work, we needed a lot of examples, both positive and negative.  We also added noise to our training set. In the end we were getting 95+% success.  (That was with a best-of-five-classifications scheme that took 5 different segmentations).</p>
<h2>Conclusion</h2>
<p>All in all, the project was a total success.  We accomplished everything we set out to do and got an A!  Also, we learned a lot and entertained our classmates with a live demo in class.</p>
<p>It would be fun to try to do this with fewer assumptions (more complex vision, more object classes, etc.)  Also, the Aibo wasn&#8217;t really the best platform for this application.  A wheeled robot would have been much more capable (but far less cute).</p>
<p>I was impressed with how well the neural network worked.  It was really amazing the results we were getting by the end.</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/wave.jpg" title="Aibo Waving"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/wave.jpg" title="Aibo Waving"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/wave.thumbnail.jpg" alt="Aibo Waving" /></a></p>
<h2>Files</h2>
<p>As usual, here are some nice files to help you out&#8230;  This code is *terribly* commented, and probably not readable.  However, here it is if you&#8217;re looking for guidance:</p>
<blockquote><p><a href="http://www.shawnlankton.com/wp-content/uploads/files/trashbot/project.zip">project.zip</a> (374 Kb)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnlankton.com/2006/05/trashbot/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Robot Simulator</title>
		<link>http://www.shawnlankton.com/2006/02/robot-simulator/</link>
		<comments>http://www.shawnlankton.com/2006/02/robot-simulator/#comments</comments>
		<pubDate>Wed, 01 Feb 2006 22:00:20 +0000</pubDate>
		<dc:creator>Shawn Lankton</dc:creator>
				<category><![CDATA[Matlab]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[robots]]></category>

		<guid isPermaLink="false">http://www.shawnlankton.com/2005/02/robot-simulator/</guid>
		<description><![CDATA[This was a quick and dirty project for a robotics class that I took at Georgia Tech in 2005. In this project, I built a Matlab simulator for testing out some simple obstacle avoidance/navigation code. My hope is that someone uses this a springboard to make a more complete version. Introduction I&#8217;ve spent plenty of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.shawnlankton.com/2005/02/robot-simulator/"><img src='http://www.shawnlankton.com/wp-content/uploads/2007/09/icon.png' alt='Robot Simulator Icon' align="right"/></a>This was a quick and dirty project for a robotics class that I took at Georgia Tech in 2005.  In this project, I built a Matlab simulator for testing out some simple obstacle avoidance/navigation code.  My hope is that someone uses this a springboard to make a more complete version.<span id="more-231"></span></p>
<h2>Introduction</h2>
<p>I&#8217;ve spent plenty of time working on robotics projects, and I have enjoyed all aspects of the design process from mechanical to electrical to computer science.  However, if you are only interested in the computer science part (control theory, artificial intelligence, creating behavior) then having to have an electromechanical platform to run your code on can be a big hassle!</p>
<p>One solution to this is to use a pre-made platform (such as in <a href="www.shawnlankton.com/trashbot/">this</a> project).  However, this too can be problematic because everything can break, <em>and</em> when developing algorithms, it is often convenient to prototype them in a simulated environment where real-life confounders don&#8217;t hinder your creativity.</p>
<h2>Simulations</h2>
<p>This problem is often solved by robot simulators.  One that I&#8217;ve used with great success is <a href="http://www.webots.com>webots</a> which is customizable, and has a simulator for various kinds of robots.  This project presents a very watered down version of the same thing.</p>
<h3>Simulated Robot</h3>
<p>In this project, we simulate a round, two-wheeled robot with three range-finder sensors.  The speed is controlled by setting the velocity of each wheel. This controls the path of the robot, and its position at teach time step.  Motion is estimated using the <a href="http://rossum.sourceforge.net/papers/DiffSteer/DiffSteer.html"> differential steering model</a>.  This is a simple, but very useful model for robotic actuation.  With this type of drive system the robot can drive straight, trace an arc, or even turn in place.</p>
<p><center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/09/closeup.png' title='close up of the robot'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/09/closeup.thumbnail.png' alt='close up of the robot' /></a></center></p>
<h3>Simulated World</h3>
<p>The simulated robot can make its way around a simulated environment represented by a .png file where black represents walls, and white represents flat, clear terrain.  Thus any &#8220;environment&#8221; can be shown as a black and white image.  For testing, I used two types of terrains, an organic-looking obstacle course and an &#8220;office&#8221; with square walls and corners.</p>
<p><center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/09/course_terrain.png' title='[terrain images]'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/09/course_terrain.thumbnail.png' alt='[terrain images]' width="150" height="150"/></a><a href='http://www.shawnlankton.com/wp-content/uploads/2007/09/office_terrain.png' title='[terrain images]'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/09/office_terrain.thumbnail.png' width="150" height="150" alt='[terrain images]' /></a></center></p>
<h2>Navigation</h2>
<p>So, now that we have a simulated robot in a simulated world we want it to do something. The goal I was working towards was this:  Make the robot wander around the environment covering most of the area and not hitting any of the walls.  This is accomplished with a pretty simple algorithm:</p>
<ol>
<li>Go straight unless sensors are blocked</li>
<li>If one sensor is blocked, turn away from it</li>
<li>If both are blocked, turn towards the farthest</li>
<li>Turn until both sensors are free</li>
<li>Continue going straight</li>
</ol>
<p>There is a lot of room for improvement here (obviously), but this was a very quick project.</p>
<h2>Results</h2>
<p>Check out a couple of videos.  Here we see the robot&#8217;s path as it drives around the area.</p>
<p><center>															<script type="text/javascript" src="http://blip.tv/scripts/pokkariPlayer.js?ver=2007082501"></script><script type="text/javascript" src="http://blip.tv/syndication/write_player?skin=js&#038;posts_id=391636&#038;source=3&#038;autoplay=true&#038;file_type=flv&#038;player_width=&#038;player_height="></script>
<div id="blip_movie_content_391636"><a rel="enclosure" href="http://blip.tv/file/get/Slankton-RobotInObstacleCourse863.flv" onclick="play_blip_movie_391636(); return false;"><img title="Click to play" alt="Video thumbnail. Click to play"  src="http://blip.tv/file/get/Slankton-RobotInObstacleCourse863.flv.jpg" border="0" title="Click To Play" /></a><br /><a rel="enclosure" href="http://blip.tv/file/get/Slankton-RobotInObstacleCourse863.flv" onclick="play_blip_movie_391636(); return false;">Click To Play</a></div>
<p>										</center></p>
<p><center><script type="text/javascript" src="http://blip.tv/scripts/pokkariPlayer.js?ver=2007082501"></script><script type="text/javascript" src="http://blip.tv/syndication/write_player?skin=js&#038;posts_id=391639&#038;source=3&#038;autoplay=true&#038;file_type=flv&#038;player_width=&#038;player_height="></script>
<div id="blip_movie_content_391639"><a rel="enclosure" href="http://blip.tv/file/get/Slankton-RobotInOffice125.flv" onclick="play_blip_movie_391639(); return false;"><img title="Click to play" alt="Video thumbnail. Click to play"  src="http://blip.tv/file/get/Slankton-RobotInOffice125.flv.jpg" border="0" title="Click To Play" /></a><br /><a rel="enclosure" href="http://blip.tv/file/get/Slankton-RobotInOffice125.flv" onclick="play_blip_movie_391639(); return false;">Click To Play</a></div>
<p></center></p>
<h2>Demo</h2>
<p>Download <a href='http://www.shawnlankton.com/wp-content/uploads/files/robot_simulator.zip' title='Robot Simulator Demo'>the demo</a> and run &#8220;&gt;&gt;setup.m&#8221;  Please feel free to make improvements to this.  If you do, <a href="http://www.shawnlankton.com/contact/">let me know</a>! </p>
<blockquote><p>
<a href='http://www.shawnlankton.com/wp-content/uploads/files/robot_simulator.zip' title='Robot Simulator Demo'>robot_simulator.zip</a>
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnlankton.com/2006/02/robot-simulator/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
<enclosure url="http://blip.tv/file/get/Slankton-RobotInObstacleCourse863.flv" length="2578050" type="video/x-flv" />
<enclosure url="http://blip.tv/file/get/Slankton-RobotInOffice125.flv" length="2162800" type="video/x-flv" />
		</item>
		<item>
		<title>Wound Measurement Device</title>
		<link>http://www.shawnlankton.com/2005/08/wound-measurement-device/</link>
		<comments>http://www.shawnlankton.com/2005/08/wound-measurement-device/#comments</comments>
		<pubDate>Wed, 10 Aug 2005 22:00:21 +0000</pubDate>
		<dc:creator>Shawn Lankton</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Vision]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[computer vision]]></category>
		<category><![CDATA[paper]]></category>

		<guid isPermaLink="false">http://www.shawnlankton.com/wordpress/?p=117</guid>
		<description><![CDATA[What started as a class project has developed into a prototype algorithm for a medical instrument. Introduction What started as a class project has developed into a prototype algorithm for an actual medical instrument. The motivation is simple. Elderly people, wheelchair bound individuals, amputees, and many other people suffer from large wounds known commonly as [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.shawnlankton.com/2005/08/wound-measurement-device/"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/thumb.jpg" alt="Wound Measurement Thumb" align="right" /></a>What started as a class project has developed into a prototype algorithm for a medical instrument.<span id="more-117"></span></p>
<h2>Introduction</h2>
<p>What started as a class project has developed into a prototype algorithm for an actual medical instrument. The motivation is simple. Elderly people, wheelchair bound individuals, amputees, and many other people suffer from large wounds known commonly as pressure ulcers or bed sores. These wounds (apart from being very nasty) can be quite painful and take a very long time to heal. Because the healing process is so long, the wound must be measured daily to determine if interventions used by the medical personnel are helping to shrink it.</p>
<p>Usually wound area and volume are measured. Currently, when area is measured, it is often done by measuring length and width and modeling the wound as a rectangle. I created a computer algorithm that is capable extracting the area with very small error (less than 5%).</p>
<h2>Preliminary Solution</h2>
<p>I used a simple algorithm that takes examines the image and makes a guess about the wound outline.  This initial version still has some problems, but the end results were very encouraging.</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/wound_results.jpg" title="Results of Wound Detection"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/wound_results.jpg" title="Results of Wound Detection"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/wound_results.thumbnail.jpg" alt="Results of Wound Detection" /></a></p>
<h2>Conclusion</h2>
<p>The end result was a total success! In addition to performing quite well, this project impressed my professor so much that I was offered a graduate research assistantship position in the lab where I now work.</p>
<p>This project is now being maintained and even drastically improved by grad students working at CATEA and CCG Group at Georgia Tech.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnlankton.com/2005/08/wound-measurement-device/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keyboard Snooper</title>
		<link>http://www.shawnlankton.com/2005/05/keyboard-snooper/</link>
		<comments>http://www.shawnlankton.com/2005/05/keyboard-snooper/#comments</comments>
		<pubDate>Sun, 15 May 2005 22:00:19 +0000</pubDate>
		<dc:creator>Shawn Lankton</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[electrical engineering]]></category>

		<guid isPermaLink="false">http://www.shawnlankton.com/2005/05/keyboard-snooper/</guid>
		<description><![CDATA[Hacking into computers is all well and good if you&#8217;re a CS person, but I&#8217;m a EE. This device plugs in-line with the PS2 port and hijacks key presses. When a username is typed in, it records the following password. Introduction This originated as a final project for a microcontrollers class I was in. Consequently, [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.shawnlankton.com/2005/05/keyboard-snooper/'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/08/thumb.jpg' alt='Snooper Thumbnail' align='right'/></a>Hacking into computers is all well and good if you&#8217;re a CS person, but I&#8217;m a EE.  This device plugs in-line with the PS2 port and hijacks key presses.  When a username is typed in, it records the following password.<span id="more-182"></span></p>
<h2>Introduction</h2>
<p>This originated as a final project for a microcontrollers class I was in.  Consequently, this project is designed on a PIC microcontroller.  The electronics are built onto a small board that plugs into the computer&#8217;s PS2 port and provides another PS2 port for the keyboard to plug in to.  While plugged in it secretly steals passwords.  I&#8217;ll give some background about PS2 keyboard protocol as well as info about electrical and software design.  Finally, I&#8217;ll provide links to schematics and source code.</p>
<p><center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/08/snooper_full.jpg' title='The Snooper'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/08/snooper_full.thumbnail.jpg' alt='The Snooper' /></a></center></p>
<p>I want to give credit to <a href="http://www.ryanwestafer.com/">Ryan Westafer</a> as well.  He was my partner on this project. </p>
<h2>PS2 keyboard protocol</h2>
<p>The keyboard uses two signals to implement its synchronous communication protocol. Both clock and data lines are open-collector and therefore idle high. When either party is ready to send data, the clock is driven low for eight bits of data plus a start bit, stop bit, and parity bit. This protocol is used to send â€˜makeâ€™ and â€˜breakâ€™ codes for each keystroke. Make codes signify a key has been pressed, and break codes signify its release. <a href="http://www.computer-engineering.org/ps2keyboard/scancodes2.html">Here</a> is a list of all make and break codes. In fact, this guy&#8217;s site explains all of this very well.  <a href="http://www.computer-engineering.org/ps2keyboard">Link</a>.</p>
<h2>Electronic Design</h2>
<p>I wanted to use the 5V power that is supplied in the PS2 connector to power our device so it could be covertly implanted. I also didn&#8217;t want to mess-up the computer or keyboard, hinder the user, or give ourselves away.  This didn&#8217;t really require sneakiness because I just hooked clock and data lines to our high impedance digital inputs on the PIC.  I also added an LED for debugging purposes, but it would definitely be removed in a for-real spy version.  <a href="http://www.shawnlankton.com/wp-content/uploads/files/snooper/snooper_schem.pdf">Schematic</a>.</p>
<h2>Software Design</h2>
<p>The algorithm works by watching for clock edges then recording the eight data bits that follow. The program then checks to see if the received byte is within the range of acceptable characters (0&#215;15-0x7d). If the byte is within the given range of alphanumeric characters, it gets processed. If not, the byte gets ignored. Ignored bytes are either break codes, or function key make codes, and thus are of no interest. Once bytes are received and validated, the pattern recognition algorithm determines if data logging should begin.</p>
<p>Pattern recognition algorithm is a big word for a simple state machine that looks for patterns like &#8220;root&#8221;, &#8220;su&#8221;, or other programmable phrases that signify that a pattern is coming.  When a pattern is recognized, the next 16 characters are stored to a RAM buffer. </p>
<p>The guidelines of the class were that two PIC processors had to communicate, so here ends the functionality of the &#8216;spy board.&#8217; The spy board could be connected to another board (which had a LCD display) via an SPI connection.  When a button on the spy board was pushed it downloaded its ram buffer to the larger board.  The spy board just kept the make codes for the keys.  Once they were transmitted to the larger board, a lookup table was used to determine which make code made what ASCII character.  This message was then displayed on the LCD display.</p>
<h2>Stuff I learned</h2>
<p>Turns out that mouse movement drives the same clock line as the keyboard. Either they share the clock, or the OS requests the state of keys such as â€œALTâ€ or â€œCTRLâ€ when the mouse is moved. Because the data line remains high during this occurrence, null bytes are received. Fortunately the algorithm, designed to discard invalid bytes, ignores the mouse movement.</p>
<p>Also, after a byte is received you need to wait approximately 30 ms in order successfully ignore all non-make code transmissions of the keyboard.</p>
<p>Furthermore, I learned during this project that holding a chip onto a socket != putting the chip in that socket.  *Especially* when trying to program a chip.  It ended up causing all sorts of errors and once I started actually plugging it in development went much faster.</p>
<h2>Future Work and Other Ideas</h2>
<p>Ideally, I would like to re-build this and bundle it with a flash memory card so that it could just record every thing that the snooped on computer typed.  Then, when a &#8216;secret code&#8217; was typed in it would dump everything back onto the PS2 line and print out a complete log.  Then you could get passwords and all sorts of other stuff.</p>
<p>Also, if I could do it all over again, I would use C instead of assembly. (C makes life immensely easier!)</p>
<h2>Code &#038; Schematic Files</h2>
<blockquote><p><a href="http://www.shawnlankton.com/wp-content/uploads/files/snooper/snooper_676.asm">PIC16F676 Code</a><br />
<a href="http://www.shawnlankton.com/wp-content/uploads/files/snooper/snooper_452.asm">PIC18F452 Code</a><br />
<a href="http://www.shawnlankton.com/wp-content/uploads/files/snooper/snooper_schem.pdf">Schematic</a></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnlankton.com/2005/05/keyboard-snooper/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PIC PID Micro-Controller</title>
		<link>http://www.shawnlankton.com/2005/03/pic-pid-controller/</link>
		<comments>http://www.shawnlankton.com/2005/03/pic-pid-controller/#comments</comments>
		<pubDate>Mon, 14 Mar 2005 22:00:35 +0000</pubDate>
		<dc:creator>Shawn Lankton</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[electrical engineering]]></category>
		<category><![CDATA[robots]]></category>

		<guid isPermaLink="false">http://www.shawnlankton.com/wordpress/?p=136</guid>
		<description><![CDATA[Doing this project really turned me on to systems and controls theory. A friend and I implemented a fully functioning PID motor speed and positioning controller onto a PIC MCU. This is a pretty thorough guide to building this very hand robotics peripheral. Introduction As part of the IEEE hardware team I&#8217;ve done a lot [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.shawnlankton.com/2005/03/pic-pid-controller/"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/thumb2.jpg" alt="PID Thumb" align="right" /></a>Doing this project really turned me on to systems and controls theory.  A friend and I implemented a fully functioning PID motor speed and positioning controller onto a PIC MCU.  This is a pretty thorough guide to building this very hand robotics peripheral.<span id="more-136"></span></p>
<h2>Introduction</h2>
<p>As part of the IEEE hardware team I&#8217;ve done a lot of projects, but I&#8217;m proudest of this one.  This was a PIC based system that implemented a closed-loop PID controller for position and speed control of two DC motors.  In addition, the control loop could be adjusted to induce arcs.</p>
<p>The system was designed as a peripheral for another processor so it also had an SPI command interface that allowed it to be communicated with on a high level while it controlled the motors on a low level.  The peripheral had a serial console that allowed you to tune, test, and drive the robot.</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/motorboard.jpg" title="The Board"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/motorboard.jpg" title="The Board"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/motorboard.thumbnail.jpg" alt="The Board" /></a></p>
<p>Shout outs go to <a href="http://www.picbook.com/">Dr. John Peatman</a> and my esteemed partner in this endeavor <a href="http://www.jacquesf.com">Jacques Fortier</a>.</p>
<h2>Motivation</h2>
<p>In order to complete its task, the robot needed to have precise control of its speed and position. Because much of the way finding of this robot was accomplished through dead reckoning, it was also especially important to maintain accurate information regarding the distance traveled by the robot.</p>
<p>In order to give the robot all of these features, we designed a special sub-processor that was devoted to the low-level control of the two primary motors. We implemented this system on a Microchip PIC18F252. This processor was housed on the same board as the motor driver which took control signals from this controller and used them to actually drive the motors.</p>
<p>Our sub-processor monitored the motors, and applied an appropriate pulse width modulated (PWM) signals to allow them to reach their goal. This controller also had the ability to communicate with the primary controller to receive speed and distance commands as well as report accomplished speed and distance traveled back to the commanding processor.</p>
<h2>Feedback</h2>
<p>In order to get speed and distance information from the motors, we purchased motors with built in encoders that output a quatrature encoder interface (QEI) signal. This signal is comprised of two pulse trains that tell when the wheel travels a part of a rotation, and the direction of motion. When channel A makes a low to high transition, the value of channel B is checked to determine the direction. A sample QEI output can be seen below.</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/qei.gif" title="Quatrature Encoder Interface (QEI)"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/qei.gif" title="Quatrature Encoder Interface (QEI)"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/qei.thumbnail.gif" alt="Quatrature Encoder Interface (QEI)" /></a></p>
<p>The motion controller was able to interrupt on low to high transitions from the QEI on channel A and create an estimate of instantaneous speed and direction by monitoring the number of counts obtained during a specified time interval. We used this information as inputs to the control loop that determines and compensates for errors in speed or distance.</p>
<h2>The Control Loop</h2>
<p>We implemented a PID (Proportional, Integral, and Differential) control loop to control the speed of the motors. The speed of the motors is manipulated by altering the duty cycle of a PWM signal generated by the processor. The duty cycle of this signal is known as the control value. below is a functional diagram of the control loop.</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/flow1.gif" title="PID Flow Chart"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/flow1.gif" title="PID Flow Chart"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/flow1.thumbnail.gif" alt="PID Flow Chart" /></a></p>
<p>This algorithm first determines the difference between the commanded speed and the actual speed. This value is known as error. The integral error is determined by adding the error to an accumulator, and the derivative error is calculated by subtracting the error from the previous error.</p>
<p>Every time the control loop executes, each of these errors are multiplied by a gain constant that has been tuned to optimize response time and accuracy. These errors, multiplied by their gain constants are then be added to the control value to compute the new control value.</p>
<p>In this way, the control value is continuously updated based on the response of the motors. This ensured that the motors are moving at the desired speed despite drag, obstacles, or other unexpected track conditions.</p>
<p>A final compensation factor is summed along with the P, I, and D errors. This is an error generated by inconsistencies in the two wheels. This helps to ensure that the robot goes straight by compensating for factors that slow one wheel but not the other.</p>
<h2>Position Control</h2>
<p>This was accomplished by controlling the speed based on the robotâ€™s proximity to the desired position. The motor controller could take commands from the main processor that told it how many â€˜ticksâ€™ to travel. This value corresponded exactly to the number of QEI pulses that the robot should move.</p>
<p>The exact distance represented by each tick was determined by the resolution of the encoders and the diameter of the wheel. Our control system was capable of responding to 2944 ticks per revolution. With wheels that were 2.2 inches in diameter, the total distance per tick was 2.346&#215;10-3 inches. Thus, very detailed motor control was possible.</p>
<p>The position control algorithm allowed the robot to approach its target distance at any speed. Then, as the target approached, it would slow its speed so that it could stop accurately when desired. This was achieved with a simple algorithm diagramed below.</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/flow2.gif" title="Position Control Flow Chart"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/flow2.gif" title="Position Control Flow Chart"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/flow2.thumbnail.gif" alt="Position Control Flow Chart" /></a></p>
<p>The motors position was monitored and continuously updated in local variables. Once the motors reached a distance a certain threshold before the desired position, the position control section of the algorithm would command the motors to stop. This would ensure that as the motors slowed down and achieved a speed of zero the robot would be at the desired position. These two systems were independent for the left and right wheel so that they could be commanded to go different distances for turning purposes.</p>
<h2>Communication</h2>
<p>These abilities provided the robot with the tools needed to control the speed and distance of travel. However, in order to be truly useful, this sub processor needed to be able to receive commands from the master processor, and provide information regarding the motor status back.</p>
<p>We accomplished this by using an SPI (Serial Peripheral Interface) communication protocol. The communication was message-based. The main processor could send eight-byte messages to the PID controller. These messages began with a one byte op-code telling the sub processor what type of command the message contained. The next seven bytes held data such as the desired speed, or the desired distance to be traveled.</p>
<p>The sub processor could simultaneously send back eight bytes that held instantaneous speed, and total distance traveled information.  With the ability to control speed, position, and communicate with the main processor completed, the motion control system was almost done.</p>
<h2>Tuning the Control</h2>
<p>The final step was to tune the PID control algorithm. This is accomplished by adjusting the gain constants by which each error is multiplied by before summing it with the previous control effort. This is a complicated process that is mostly achieved through trial and error.</p>
<p>Another tool that helped was using GNUplot to make graphs of debug data output by the PID controller.  This allowed us to see the interaction of different errors.  This interaction can be seen below.</p>
<p><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/pid_plot.gif" title="Plots used to Tune Controller"></a></p>
<p style="text-align: center"><a href="http://www.shawnlankton.com/wp-content/uploads/2007/07/pid_plot.gif" title="Plots used to Tune Controller"><img src="http://www.shawnlankton.com/wp-content/uploads/2007/07/pid_plot.thumbnail.gif" alt="Plots used to Tune Controller" /></a></p>
<p>The work of tuning the processor was simplified by developing a user interface on the PID controller that was separate from the main processor. This allowed the control system to be tuned over serial by adjusting gain constants stored in EEPROM.</p>
<p>With the motor controller fully tuned, it performed very well and provided excellent speed and position control for the robot without bothering the main processor with this low level task. Full code for this motion controller is below.</p>
<h2>The Motor Driver</h2>
<p>All of this fluffy code stuff is great, but you always need some good ol&#8217; power electronics too.  The motor driver was required to step up logic level PWM signals to 9.7V motor driving PWM at up to 3A.  In order to accomplish this, we used an L298 H-bridge chip and some glue logic.  In addition, it was a nice place to house the PIC chip that implemented the PID controller.  We added some handy plugs for programming, connecting to other processors, and attaching motors and power. Just because I&#8217;m a nice guy, I&#8217;ve included a schematic and layout for the board as well as the code below.</p>
<h2>Downloads</h2>
<blockquote><p><a href="http://www.shawnlankton.com/wp-content/uploads/files/pid/pid.zip">PID C Code</a> (8kb)<br />
<a href="http://www.shawnlankton.com/wp-content/uploads/files/pid/motorboard-sch.pdf">Motorboard Schematic</a> (184kb)<br />
<a href="http://www.shawnlankton.com/wp-content/uploads/files/pid/motorboard-layout.gif">Motorboard Layout</a> (54kb)</p></blockquote>
<h2>Final Thoughts</h2>
<p>I was really happy with this project.  Below you can see me and Jacques giving our &#8216;gang sign.&#8217;  In case you can&#8217;t read it that says &#8220;PIC&#8221; &#8230; as in the PIC chip we wrote the PID controller on.</p>
<p>But more seriously, there were some valuable lessons learned.  I really got the hang of SPI.  It may have been better to use I2C for this, but I&#8217;ll have to save that for next time.  I also got really turned on to systems and controls.  The idea of a closed loop control system that uses its error to correct itself is very clever and elegant.  I strongly recommend taking a class on systems and controls if you haven&#8217;t yet.</p>
<p>Another thing I&#8217;d like to share is *ALWAYS* program in C.  Assembly is sooo much more annoying.  We started the project in assembly and quickly realized that things were getting out of hand so we switched to C (God&#8217;s own language) and everything started going very smoothly.</p>
<p>If I had it to do over again, I might also make the position control better.  As it was, you really needed to tweak constants every time you changed the default speed of the system.  It was highly accurate, but it would be a little more robust if I had implemented a PID position control algorithm in addition to the PID speed control algorithm.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnlankton.com/2005/03/pic-pid-controller/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>DTMF Generator</title>
		<link>http://www.shawnlankton.com/2003/08/dtmf-generator/</link>
		<comments>http://www.shawnlankton.com/2003/08/dtmf-generator/#comments</comments>
		<pubDate>Fri, 15 Aug 2003 22:00:16 +0000</pubDate>
		<dc:creator>Shawn Lankton</dc:creator>
				<category><![CDATA[Matlab]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.shawnlankton.com/2003/08/dtmf-generator/</guid>
		<description><![CDATA[This was a simple Matlab project, but it can be very handy for generating touch tones for telephony hacks. In fact, try it out, you can dial your phone just by holding it up to the speaker! Introduction The purpose of signals is to communicate information. Some of this information is designed for humans to [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.shawnlankton.com/2003/08/dtmf-generator/'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/08/thumb3.jpg' alt='DTMF Thumbnail' align='right'/></a>This was a simple Matlab project, but it can be very handy for generating touch tones for telephony hacks. In fact, try it out, you can dial your phone just by holding it up to the speaker!<span id="more-189"></span></p>
<h2>Introduction</h2>
<p>The purpose of signals is to communicate information. Some of this information is designed for humans to receive. Pictures and music are some examples. Most others are intended for computers or machines to receive. In this exercise the ability to create and decode touch tones, a task that happens millions of times a day, was replicated using principles of filtering.</p>
<p>First touch tones had to be understood and synthesized, and then using filtering each had to be decoded to produce the original key sequence that generated it. The end result was a dialing and decoding system like that of a phone.</p>
<h2>Generating Touch Tones</h2>
<p>A touch tone is made up of two frequencies corresponding to the keysâ€™ position on the grid of the phone.  For instance, 5 is produce by playing a pure 1336 Hz sine wave and a pure 770 Hz sine wave simultaneously.  The result is the warbly sound you hear.<br />
<center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/08/grid.gif' title='Table Showing Needed Touch Tones'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/08/grid.thumbnail.gif' alt='Table Showing Needed Touch Tones' /></a></center><br />
It was relatively simple to code a function that would cycle through a list of characters (like a phone number) and produce the corresponding waveform to simulate touch tones. The final code was as follows:</p>
<blockquote><p><a href="http://www.shawnlankton.com/wp-content/uploads/files/dtmf/dtmfdial.m">dtmfdial.m</a></p></blockquote>
<h2>Making Filters</h2>
<p>The first step to decoding the touch tones was to design a set of filters whose purpose it would be to eliminate all frequencies but one. To accomplish this, a bandpass filter was used. Eight filters were constructed to correspond to the eight possible frequencies that the touch tones are made up of. Each filter had to be scaled so that the magnitude of its frequency response was equal to exactly one. The final code was as follows:</p>
<blockquote><p><a href="http://www.shawnlankton.com/wp-content/uploads/files/dtmf/dtmfdesign.m">dtmfdesign.m</a></p></blockquote>
<p>The frequency response of each filter is important because it shows what every possible frequency component will be scaled by. For instance, a signal with a frequency that occurs where a filter is peaking will go through virtually unmolested because it will be scaled by a factor of one. On the other hand, signals with frequencies that occur where the frequency response is very low will be almost eliminated by the filter because they will be scaled by a small number. The images below show the passbands of all 8 filters that are used.</p>
<p><center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/08/bandpass2.gif' title='Passbands of Filters'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/08/bandpass2.thumbnail.gif' alt='Passbands of Filters' /></a></center></p>
<p>These filters had to be narrow enough that they would not overlap.  It was imperative that each filter would only select one of the 8 frequencies that make up DTMF.  Below is an image of the filters that finally accomplished that task.</p>
<p><center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/08/bandpass3.gif' title='Zoomed In Passbands of Filters'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/08/bandpass3.thumbnail.gif' alt='Zoomed In Passbands of Filters' /></a></center></p>
<h2>Making Sense of The Signal</h2>
<p>The second phase of the decoding algorithm involved a scoring function. This function took in one impulse response of a bandpass filter and one short segment of a touch tone and determined if there was a frequency in the pass band after the two were convolved.In order to determine if a frequency was in the pass band the magnitude of the convolution was measured. If it was above 0.71 then the frequency was considered to be passed otherwise it wasnâ€™t. The final code was as follows:</p>
<blockquote><p><a href="http://www.shawnlankton.com/wp-content/uploads/files/dtmf/dtmfscore.m">dtmfscore.m</a></p></blockquote>
<h2>Putting it Together</h2>
<p>Finally, a main function was written to call the other functions. It parsed the input signal of touch tones using a program called dtmfcut, and then used loops to iterate each tone through each filter. The resulting scores from those iterations were used to decode the row and column of each key, and thus make a vector containing the original keys that were dialed. The completed program was tested by running it on a signal of synthesized touch tones. The touch tones were created with the string â€˜891#40789132*DABCâ€™ which produced a vector whose spectrogram is shown below.<br />
<center><a href='http://www.shawnlankton.com/wp-content/uploads/2007/08/specgram.gif' title='Spectrogram of Output'><img src='http://www.shawnlankton.com/wp-content/uploads/2007/08/specgram.thumbnail.gif' alt='Spectrogram of Output' /></a></center><br />
When the program was run, it correctly reproduced the same vector.  The code for the main function and dtmfcut were as follows:</p>
<blockquote><p><a href="http://www.shawnlankton.com/wp-content/uploads/files/dtmf/dtmfrun.m">dtmfrun.m</a><br />
<a href="http://www.shawnlankton.com/wp-content/uploads/files/dtmf/dtmfcut.m">dtmfcut.m</a></p></blockquote>
<h2>Final Thought</h2>
<p>Millions of people use phones many times a day and yet, very few understand what complex processes go on inside the touch tone creation and decoding process. In this exercise, that understanding at least has been obtained. However, the ideas presented have a far broader application. The ability to use FIR filters to encode and decode signals in order to accomplish goals is pretty darn important, and it was fun to do too!</p>
<p>For some other great projects in Matlab, check these out:</p>
<blockquote><p>
<a href="http://www.shawnlankton.com/2008/04/selective-mode-filter-in-matlab/">3D Vision with Stereo Cameras</a><br />
<a href="http://www.shawnlankton.com/2006/02/robot-simulator/">Simple Robot Simulator</a><br />
<a href="http://www.shawnlankton.com/2006/05/trashbot/">Neural-Net Powered Aibo Robot Project</a>
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnlankton.com/2003/08/dtmf-generator/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

