<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>My Applied Physics 186 Blog</title>
	<atom:link href="http://tonilei.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tonilei.wordpress.com</link>
	<description>All About Image Processing</description>
	<lastBuildDate>Mon, 05 Dec 2011 03:37:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='tonilei.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>My Applied Physics 186 Blog</title>
		<link>http://tonilei.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://tonilei.wordpress.com/osd.xml" title="My Applied Physics 186 Blog" />
	<atom:link rel='hub' href='http://tonilei.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Using SpectraSuite &#8211; Part 1 (Setting a Reference Monitor)</title>
		<link>http://tonilei.wordpress.com/2011/12/05/using-spectrasuite-part-1/</link>
		<comments>http://tonilei.wordpress.com/2011/12/05/using-spectrasuite-part-1/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 02:05:42 +0000</pubDate>
		<dc:creator>tonilei</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[jaz spectrometer]]></category>
		<category><![CDATA[SpectraSuite]]></category>
		<category><![CDATA[spectrometer]]></category>

		<guid isPermaLink="false">http://tonilei.wordpress.com/?p=369</guid>
		<description><![CDATA[This isn&#8217;t a guidebook or the first thing you should read when using SpectraSuite. Instead, it&#8217;s a list of procedures NOT included in the SpectraSuite Manual plus some tips and shortcuts for making your time with SpectraSuite a more productive one. Be warned: if you don&#8217;t understand some jargon, that&#8217;s because I won&#8217;t be explaining [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=369&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This isn&#8217;t a guidebook or the first thing you should read when using SpectraSuite. Instead, it&#8217;s a list of procedures NOT included in the SpectraSuite Manual plus some tips and shortcuts for making your time with SpectraSuite a more productive one. Be warned: if you don&#8217;t understand some jargon, that&#8217;s because I won&#8217;t be explaining them if they&#8217;re already in the manual.</p>
<p>The ones I&#8217;m listing here are those I&#8217;ve encountered while setting a reference monitor.</p>
<p>How to terminate an acquisition:<br />
1. Choose Spectrometer &gt; Acquisition &gt; Acquisition Console<br />
2. Choose the channel/spectrometer you want to stop/terminate.<br />
3. Click terminate.</p>
<p>How to start an acquisition in a NEW graph:<br />
1. Terminate the acquisition (see above on how to terminate).<br />
2. On the &#8220;Data Sources&#8221; window, right click on the Channel that you want to have a separate graph of, and choose &#8220;Spectrum Graph.&#8221;<br />
3. Choose &#8220;Show data in new graph.&#8221;</p>
<p>The steps for getting a reference monitor are already outlined in the SpectraSuite Manual. However, I&#8217;m giving some tips to make the process easier.<br />
Tip 1: Open the 2 channels in two separate graphs.<br />
Tip 2: In order to activate the &#8220;Add reference monitor&#8221; icon, you must click on the GRAPH ITSELF, not the word &#8220;Graph&#8221; on the Data Sources window.</p>
<p>A last reminder: even if you have a reference monitor (which is of course set up in ANOTHER channel other than the one you&#8217;re using for sample acquisition), if you want to measure Absorbance, Reflectance and Transmittance, it&#8217;s a MUST that you get a reference spectrum for the sample acquisition channel.  </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonilei.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonilei.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonilei.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonilei.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonilei.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonilei.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonilei.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonilei.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonilei.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonilei.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonilei.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonilei.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonilei.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonilei.wordpress.com/369/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=369&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonilei.wordpress.com/2011/12/05/using-spectrasuite-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61833323006e900837e1ab8078b85c27?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonilei</media:title>
		</media:content>
	</item>
		<item>
		<title>Activity 20 &#8211; Neural Networks</title>
		<link>http://tonilei.wordpress.com/2008/10/10/activity-20-neural-networks/</link>
		<comments>http://tonilei.wordpress.com/2008/10/10/activity-20-neural-networks/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 06:20:35 +0000</pubDate>
		<dc:creator>tonilei</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonilei.wordpress.com/?p=324</guid>
		<description><![CDATA[Neural networks are models of neurons in the brains; they can be trained to &#8220;learn&#8221; a particular type of activity. It has many applications; for instance, this can be used as a classification tool in image processing. Instead of using rules, the neural network &#8220;learns the rules of the mapping&#8221; (M. Soriano, 2008). For this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=324&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Neural networks are models of neurons in the brains; they can be trained to &#8220;learn&#8221; a particular type of activity.  It has many applications; for instance, this can be used as a classification tool in image processing.  Instead of using rules, the neural network &#8220;learns the rules of the mapping&#8221; (M. Soriano, 2008).</p>
<p>For this activity, I again made use of the red and pink beads.</p>
<p><a href="http://tonilei.files.wordpress.com/2008/09/red1.jpg"><img class="aligncenter size-medium wp-image-326" title="red1" src="http://tonilei.files.wordpress.com/2008/09/red1.jpg?w=206&#038;h=300" alt="" width="206" height="300" /></a></p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/09/pink4.jpg"><img class="aligncenter size-medium wp-image-327" title="pink4" src="http://tonilei.files.wordpress.com/2008/09/pink4.jpg?w=180&#038;h=177" alt="" width="180" height="177" /></a></p>
<p style="text-align:left;">The first input for the neural network are the features of the training set, where x is equal to:</p>
<p style="text-align:left;">x=[0.988078346,    0.217334;<br />
0.99504038,    0.2057463;<br />
0.996698007,    0.2361515;<br />
0.996963227,    0.2858829;<br />
0.137781962,    0.5295532;<br />
0.141030911,    0.5210784;<br />
0.149186437,    0.5611408;<br />
0.137715657,    0.5842001]&#8216;;.</p>
<p style="text-align:left;">This was obtained from the data from the LDA classification employed in Activity 19:</p>
<p style="text-align:left;"><a href="http://tonilei.files.wordpress.com/2008/10/training2.jpg"><img class="aligncenter size-large wp-image-335" title="training2" src="http://tonilei.files.wordpress.com/2008/10/training2.jpg?w=420&#038;h=162" alt="" width="420" height="162" /></a></p>
<table style="border-collapse:collapse;height:21px;" border="0" cellspacing="0" cellpadding="0" width="512">
<col style="width:48pt;" span="8" width="64"></col>
<col></col>
<tbody>
<tr>
<td style="height:15pt;width:48pt;" width="64" height="20" align="right"></td>
<td style="width:48pt;" width="64" align="right"></td>
<td style="width:48pt;" width="64" align="right"></td>
<td style="width:48pt;" width="64" align="right"></td>
</tr>
</tbody>
</table>
<p>Using the and.sce code by Jeric Tugaff, the output of the neural network is:</p>
<table style="border-collapse:collapse;width:48pt;" border="0" cellspacing="0" cellpadding="0" width="64">
<col style="width:48pt;" width="64"></col>
<tbody>
<tr style="height:15pt;">
<td style="height:15pt;width:48pt;" width="64" height="20" align="right">0.022191</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.021233</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.022151</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.024055</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.977368</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.976556</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.977627</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.97985</td>
</tr>
</tbody>
</table>
<p style="text-align:left;">The classification is as follows:</p>
<p style="text-align:center;">
<table style="border-collapse:collapse;width:96pt;text-align:center;" border="0" cellspacing="0" cellpadding="0" width="128">
<col style="width:48pt;" span="2" width="64"></col>
<tbody>
<tr style="height:15pt;">
<td style="height:15pt;width:48pt;" width="64" height="20">Class</td>
<td style="width:48pt;" width="64">Output</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">1</td>
<td align="right">0.022191</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">1</td>
<td align="right">0.021233</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">1</td>
<td align="right">0.022151</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">1</td>
<td align="right">0.024055</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">2</td>
<td align="right">0.977368</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">2</td>
<td align="right">0.976556</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">2</td>
<td align="right">0.977627</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">2</td>
<td align="right">0.97985</td>
</tr>
</tbody>
</table>
<p style="text-align:left;">The beads under class 1have outputs that are approximately 0.022407575 (mean of the 4 class 1 beads in the training set) while those under class 2 have outputs at about 0.977850025 (mean of the 4 class 2 beads in the training set). Actually, the outputs are expected to be either 0 or 1, so we round the answer to the nearest integer; thus, the output should be 0 for a class 1 bead and 1 for a class 2 bead</p>
<p style="text-align:left;">We now use the following data for the test set:</p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/10/test.jpg"><img class="aligncenter size-large wp-image-339" title="test" src="http://tonilei.files.wordpress.com/2008/10/test.jpg?w=420&#038;h=162" alt="" width="420" height="162" /></a></p>
<p style="text-align:left;">The output of the test set is:</p>
<p style="text-align:left;">
<table style="border-collapse:collapse;width:48pt;" border="0" cellspacing="0" cellpadding="0" width="64">
<col style="width:48pt;" width="64"></col>
<tbody>
<tr style="height:15pt;">
<td style="height:15pt;width:48pt;" width="64" height="20" align="right">0.023479</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.979589</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.015971</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.977019</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.029123</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.017914</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.976193</td>
</tr>
<tr style="height:15pt;">
<td style="height:15pt;" height="20" align="right">0.97911</td>
</tr>
</tbody>
</table>
<p>To classify these, we round to the nearest integer. We get the following results:</p>
<table style="border-collapse:collapse;width:206pt;" border="0" cellspacing="0" cellpadding="0" width="274">
<col style="width:79pt;" span="2" width="105"></col>
<col style="width:48pt;" width="64"></col>
<tbody>
<tr style="height:15pt;">
<td class="xl65" style="height:15pt;width:79pt;" width="105" height="20">Output</td>
<td class="xl65" style="width:79pt;" width="105">Nearest Integer</td>
<td class="xl65" style="width:48pt;" width="64">Class</td>
</tr>
<tr style="height:15pt;">
<td class="xl65" style="height:15pt;" height="20">0.0234794</td>
<td class="xl65">0</td>
<td class="xl65">1</td>
</tr>
<tr style="height:15pt;">
<td class="xl65" style="height:15pt;" height="20">0.9795894</td>
<td class="xl65">1</td>
<td class="xl65">2</td>
</tr>
<tr style="height:15pt;">
<td class="xl65" style="height:15pt;" height="20">0.0159705</td>
<td class="xl65">0</td>
<td class="xl65">1</td>
</tr>
<tr style="height:15pt;">
<td class="xl65" style="height:15pt;" height="20">0.9770187</td>
<td class="xl65">1</td>
<td class="xl65">2</td>
</tr>
<tr style="height:15pt;">
<td class="xl65" style="height:15pt;" height="20">0.0291225</td>
<td class="xl65">0</td>
<td class="xl65">1</td>
</tr>
<tr style="height:15pt;">
<td class="xl65" style="height:15pt;" height="20">0.0179141</td>
<td class="xl65">0</td>
<td class="xl65">1</td>
</tr>
<tr style="height:15pt;">
<td class="xl65" style="height:15pt;" height="20">0.9761925</td>
<td class="xl65">1</td>
<td class="xl65">2</td>
</tr>
<tr style="height:15pt;">
<td class="xl65" style="height:15pt;" height="20">0.9791101</td>
<td class="xl65">1</td>
<td class="xl65">2</td>
</tr>
</tbody>
</table>
<p>The classification using neural networks agrees with that using LDA.</p>
<p>The activity was successfully done.  Because of this, I give myself a grade of 10 for this activity.</p>
<p>Thanks to Jeric Tugaff for giving a short lecture on neural networks and for providing the and.sce code.</p>
<p style="text-align:center;">
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonilei.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonilei.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonilei.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonilei.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonilei.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonilei.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonilei.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonilei.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonilei.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonilei.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonilei.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonilei.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonilei.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonilei.wordpress.com/324/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=324&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonilei.wordpress.com/2008/10/10/activity-20-neural-networks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61833323006e900837e1ab8078b85c27?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonilei</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/red1.jpg?w=206" medium="image">
			<media:title type="html">red1</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/pink4.jpg?w=300" medium="image">
			<media:title type="html">pink4</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/10/training2.jpg?w=420" medium="image">
			<media:title type="html">training2</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/10/test.jpg?w=420" medium="image">
			<media:title type="html">test</media:title>
		</media:content>
	</item>
		<item>
		<title>Activity 19 &#8211; Probabilistic Classification</title>
		<link>http://tonilei.wordpress.com/2008/09/24/activity-19-probabilistic-classification/</link>
		<comments>http://tonilei.wordpress.com/2008/09/24/activity-19-probabilistic-classification/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 10:00:52 +0000</pubDate>
		<dc:creator>tonilei</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonilei.wordpress.com/?p=291</guid>
		<description><![CDATA[Linear Discriminant Analysis (LDA) is another method that can be used for classifying objects into their respective classes. The features of an object are used to classify them into one of several classes. For this activity, I again used the pink and red beads as the objects to be classified. The red beads are classified [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=291&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Linear Discriminant Analysis (LDA) is another method that can be used for classifying objects into their respective classes.  The features of an object are used to classify them into one of several classes.</p>
<p>For this activity, I again used the pink and red beads as the objects to be classified. <strong>The red beads are classified as class 1 and the pink beads as class 2.</strong></p>
<p><a href="http://tonilei.files.wordpress.com/2008/09/red.jpg"><img class="aligncenter size-medium wp-image-302" title="red" src="http://tonilei.files.wordpress.com/2008/09/red.jpg?w=206&#038;h=300" alt="" width="206" height="300" /></a></p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/09/pink3.jpg"><img class="aligncenter size-medium wp-image-306" title="pink3" src="http://tonilei.files.wordpress.com/2008/09/pink3.jpg?w=180&#038;h=177" alt="" width="180" height="177" /></a></p>
<p>In each class, four of the beads were used for the training set and the other four were used for the test set.  Two features were used for LDA &#8211; the length (diameter for the red beads) of the bead and its &#8220;mean&#8221; color (the mean of its R, G, and B channels).  These were stored in the matrix, x with the length in the first column and color in the second column.  The &#8220;training set&#8221; features vector, x and their corresponding classes are shown below.</p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/09/x.jpg"><img class="aligncenter size-medium wp-image-307" title="x" src="http://tonilei.files.wordpress.com/2008/09/x.jpg?w=240&#038;h=181" alt="" width="240" height="181" /></a></p>
<p style="text-align:left;">The matrix x was split into x1 and x2 and the mean, mu_i for each vector was obtained.  The global mean vector, mu was also obtained.</p>
<p style="text-align:left;"><a href="http://tonilei.files.wordpress.com/2008/09/x1x2.jpg"><img class="aligncenter size-medium wp-image-311" title="x1x2" src="http://tonilei.files.wordpress.com/2008/09/x1x2.jpg?w=300&#038;h=52" alt="" width="300" height="52" /></a></p>
<p style="text-align:left;"><a href="http://tonilei.files.wordpress.com/2008/09/mean.jpg"><img class="aligncenter size-medium wp-image-313" title="mean" src="http://tonilei.files.wordpress.com/2008/09/mean.jpg?w=300&#038;h=43" alt="" width="300" height="43" /></a></p>
<p style="text-align:left;">The covariance matrix, c_i is then computed using the following equation:</p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/09/covariance.jpg"><img class="aligncenter size-full wp-image-314" title="covariance" src="http://tonilei.files.wordpress.com/2008/09/covariance.jpg?w=420" alt=""   /></a></p>
<p style="text-align:left;">where n_i is the number of objects in x_i; thus n1=4 and n2=4. The matrices, c1 and c2 are:</p>
<p style="text-align:left;"><a href="http://tonilei.files.wordpress.com/2008/09/c1c2.jpg"><img class="aligncenter size-medium wp-image-315" title="c1c2" src="http://tonilei.files.wordpress.com/2008/09/c1c2.jpg?w=300&#038;h=32" alt="" width="300" height="32" /></a></p>
<p style="text-align:left;">Using c1 and c2, C is obtained using the following equation:</p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/09/c.jpg"><img class="aligncenter size-full wp-image-317" title="c" src="http://tonilei.files.wordpress.com/2008/09/c.jpg?w=420" alt=""   /></a></p>
<p style="text-align:left;">C and its inverse, C^-1are:</p>
<p style="text-align:left;"><a href="http://tonilei.files.wordpress.com/2008/09/cinvc.jpg"><img class="aligncenter size-medium wp-image-319" title="cinvc" src="http://tonilei.files.wordpress.com/2008/09/cinvc.jpg?w=300&#038;h=34" alt="" width="300" height="34" /></a></p>
<p style="text-align:left;">For this particular data set, the prior probability vector, p is given by:</p>
<p style="text-align:left;"><a href="http://tonilei.files.wordpress.com/2008/09/p.jpg"><img class="aligncenter size-full wp-image-320" title="p" src="http://tonilei.files.wordpress.com/2008/09/p.jpg?w=420" alt=""   /></a></p>
<p>Using the said variables, it is now possible to compute for the Linear Discriminant function, f_i.</p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/09/f_i.jpg"><img class="aligncenter size-full wp-image-322" title="f_i" src="http://tonilei.files.wordpress.com/2008/09/f_i.jpg?w=420" alt=""   /></a></p>
<p>For the &#8220;training set&#8221; I used, f1 and f2 must be obtained and then compared in order to determine in which class the particular object, k belongs.  If the value of f_i is greater then the object belongs in class i.  The data I got for the four red and four pink beads are shown below:</p>
<p><a href="http://tonilei.files.wordpress.com/2008/09/training1.jpg"><img class="aligncenter size-full wp-image-297" title="training1" src="http://tonilei.files.wordpress.com/2008/09/training1.jpg?w=420&#038;h=162" alt="" width="420" height="162" /></a></p>
<p>The highlighted values are the larger ones (yellow for class 1 and peach for class 2).  Now, I tested the remaining four red and four pink beads to determine how well these will be classified using LDA.  The data for this is:</p>
<p><a href="http://tonilei.files.wordpress.com/2008/09/test2.jpg"><img class="aligncenter size-large wp-image-300" title="test2" src="http://tonilei.files.wordpress.com/2008/09/test2.jpg?w=420&#038;h=162" alt="" width="420" height="162" /></a></p>
<p>Comparing the classification made by LDA to the actual class of the beads, we can see that there is a 100 % classification.</p>
<p>I give myself a grade of 10 in this activity for being able to successfully implement LDA.</p>
<p>___________________</p>
<p>The code that I made for this activity is shown below:</p>
<p>//training set data<br />
x1=[0.988078346    0.217334; 0.99504038    0.2057463; 0.996698007    0.2361515; 0.996963227    0.2858829];<br />
x2=[0.137781962    0.5295532; 0.141030911    0.5210784; 0.149186437    0.5611408; 0.137715657    0.5842001];<br />
x=[0.988078346    0.217334; 0.99504038    0.2057463; 0.996698007    0.2361515; 0.996963227    0.2858829; 0.137781962    0.5295532; 0.141030911    0.5210784; 0.149186437    0.5611408; 0.137715657    0.5842001];</p>
<p>//test set data<br />
//x1t=[1.02322004    0.2186213; 0.143020064    0.5815481; 1.128777732    0.1655321; 0.150910369    0.5429531];<br />
//x2t=[0.98290655    0.2522253; 1.092774072    0.1837175; 0.158203928    0.5429531; 0.140168945    0.5640654];<br />
xt=[1.02322004    0.2186213; 0.143020064    0.5815481; 1.128777732    0.1655321; 0.150910369    0.5429531; 0.98290655    0.2522253; 1.092774072    0.1837175; 0.158203928    0.5429531; 0.140168945    0.5640654];</p>
<p>mu1=[mean(x1(:,1)) mean(x1(:,2))];<br />
mu2=[mean(x2(:,1)) mean(x2(:,2))];<br />
mu=[mean(x(:,1)) mean(x(:,2)); mean(x(:,1)) mean(x(:,2)); mean(x(:,1)) mean(x(:,2)); mean(x(:,1)) mean(x(:,2))];</p>
<p>x01=x1-mu;<br />
x02=x2-mu;</p>
<p>//compute covariance matrices<br />
n1=4;<br />
n2=4;<br />
c1=(x01&#8242;*x01)/n1;<br />
c2=(x02&#8242;*x02)/n2;</p>
<p>for r=1:2<br />
for s=1:2<br />
C(r,s)=(n1*c1(r,s)+n2*c2(r,s))/(n1+n2);<br />
end<br />
end</p>
<p>p=[0.5; 0.5];</p>
<p>for i=1:8<br />
f1(i)=mu1*(inv(C)*xt(i,:)&#8217;) &#8211; 0.5*mu1*(inv(C)*mu1&#8242;) + log(p(1));<br />
f2(i)=mu2*(inv(C)*xt(i,:)&#8217;) &#8211; 0.5*mu1*(inv(C)*mu2&#8242;) + log(p(2));<br />
end</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonilei.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonilei.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonilei.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonilei.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonilei.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonilei.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonilei.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonilei.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonilei.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonilei.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonilei.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonilei.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonilei.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonilei.wordpress.com/291/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=291&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonilei.wordpress.com/2008/09/24/activity-19-probabilistic-classification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61833323006e900837e1ab8078b85c27?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonilei</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/red.jpg?w=206" medium="image">
			<media:title type="html">red</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/pink3.jpg?w=300" medium="image">
			<media:title type="html">pink3</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/x.jpg?w=300" medium="image">
			<media:title type="html">x</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/x1x2.jpg?w=300" medium="image">
			<media:title type="html">x1x2</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/mean.jpg?w=300" medium="image">
			<media:title type="html">mean</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/covariance.jpg" medium="image">
			<media:title type="html">covariance</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/c1c2.jpg?w=300" medium="image">
			<media:title type="html">c1c2</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/c.jpg" medium="image">
			<media:title type="html">c</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/cinvc.jpg?w=300" medium="image">
			<media:title type="html">cinvc</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/p.jpg" medium="image">
			<media:title type="html">p</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/f_i.jpg" medium="image">
			<media:title type="html">f_i</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/training1.jpg" medium="image">
			<media:title type="html">training1</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/test2.jpg?w=420" medium="image">
			<media:title type="html">test2</media:title>
		</media:content>
	</item>
		<item>
		<title>Activity 18 &#8211; Pattern Recognition</title>
		<link>http://tonilei.wordpress.com/2008/09/16/activity-18-pattern-recognition/</link>
		<comments>http://tonilei.wordpress.com/2008/09/16/activity-18-pattern-recognition/#comments</comments>
		<pubDate>Tue, 16 Sep 2008 03:11:12 +0000</pubDate>
		<dc:creator>tonilei</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonilei.wordpress.com/?p=272</guid>
		<description><![CDATA[In order to determine if an object is a member of a particular set of objects using &#8220;machine vision&#8221; (instead of human vision), we use pattern recognition. Using objects that belong to the particular set we which to recognize we build a training set; we will use this to extract features that are characteristic of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=272&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In order to determine if an object is a member of a particular set of objects using &#8220;machine vision&#8221; (instead of human vision), we use pattern recognition.  Using objects that belong to the particular set we which to recognize we build a <strong>training set</strong>; we will use this to extract features that are characteristic of the objects in the training set.</p>
<p>I took a picture of three types of beads &#8211; large red spherical beads, medium-sized blue spherical beads, and small cylindrical pink beads.</p>
<p><a href="http://tonilei.files.wordpress.com/2008/09/beads.jpg"><img class="aligncenter size-medium wp-image-277" title="beads" src="http://tonilei.files.wordpress.com/2008/09/beads.jpg?w=300&#038;h=231" alt="" width="300" height="231" /></a></p>
<p>In order to classify them, I built a training set for each class (type of bead) by getting three features &#8211; the area  in pixels, the length of the longest portion of the bead (in the case of spherical beads, this was the diameter), and the &#8220;mean color&#8221; of the bead.  All these features are each expressed using a single number.  The area was obtained by binarizing the image, using the <strong>follow</strong> command to get the outline of the bead, and implementing Green&#8217;s theorem to get the area in terms of number of pixels.  The length of the longest portion of the bead was obtained by getting the difference between the coordinates of the two ends of the longest portion of the bead.  The &#8220;mean color&#8221; was obtained by averaging the color values of the three color channels for each bead.</p>
<p>Since the area and the length features had large values, these were normalized so that no feature would have a greater effect in the classification (this was not done anymore for the color because the values were already fractional).  The euclidean distance,</p>
<p><a href="http://tonilei.files.wordpress.com/2008/09/eucldistance.jpg"><img class="aligncenter size-full wp-image-284" title="eucldistance" src="http://tonilei.files.wordpress.com/2008/09/eucldistance.jpg?w=420" alt="" /></a></p>
<p>from the origin (0,0,0) was then obtained.  The data for the training set is shown below (please click on picture if it is not shown properly).</p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/09/trainingset1.jpg"><img class="aligncenter size-full wp-image-280" title="trainingset1" src="http://tonilei.files.wordpress.com/2008/09/trainingset1.jpg?w=420" alt=""   /></a></p>
<p style="text-align:left;">After this, two beads from each class (those that were not included in the training set) were subjected to pattern recognition.</p>
<p style="text-align:left;"><a href="http://tonilei.files.wordpress.com/2008/09/testlabeled.jpg"><img class="aligncenter size-full wp-image-286" title="testlabeled" src="http://tonilei.files.wordpress.com/2008/09/testlabeled.jpg?w=420" alt=""   /></a></p>
<p style="text-align:left;">They were then placed into the class whose value of the euclidean distance is closest to theirs. The data for this is:</p>
<p style="text-align:left;"><a href="http://tonilei.files.wordpress.com/2008/09/testclassification.jpg"><img class="aligncenter size-large wp-image-289" title="testclassification" src="http://tonilei.files.wordpress.com/2008/09/testclassification.jpg?w=420&#038;h=128" alt="" width="420" height="128" /></a></p>
<p style="text-align:left;">All of the beads were properly classified into their respective classes.  I think that the 100% correct classification was achieved because the features that were taken were truly different for each class.</p>
<p style="text-align:left;">I give myself a grade of 10 for this activity for being able to classify the beads correctly through pattern recognition.</p>
<p style="text-align:left;">
<p style="text-align:left;">
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tonilei.wordpress.com/272/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tonilei.wordpress.com/272/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonilei.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonilei.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonilei.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonilei.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonilei.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonilei.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonilei.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonilei.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonilei.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonilei.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonilei.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonilei.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonilei.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonilei.wordpress.com/272/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=272&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonilei.wordpress.com/2008/09/16/activity-18-pattern-recognition/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61833323006e900837e1ab8078b85c27?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonilei</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/beads.jpg?w=300" medium="image">
			<media:title type="html">beads</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/eucldistance.jpg" medium="image">
			<media:title type="html">eucldistance</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/trainingset1.jpg" medium="image">
			<media:title type="html">trainingset1</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/testlabeled.jpg" medium="image">
			<media:title type="html">testlabeled</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/testclassification.jpg?w=420" medium="image">
			<media:title type="html">testclassification</media:title>
		</media:content>
	</item>
		<item>
		<title>Activity 17 &#8211; Basic Video Processing</title>
		<link>http://tonilei.wordpress.com/2008/09/09/activity-17-basic-video-processing/</link>
		<comments>http://tonilei.wordpress.com/2008/09/09/activity-17-basic-video-processing/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 02:28:38 +0000</pubDate>
		<dc:creator>tonilei</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonilei.wordpress.com/?p=263</guid>
		<description><![CDATA[For this activity, our group (Beth, Aiyin, April, and I) captured a video of a free-falling object and determined kinematic variables from the video. Against a dark blue background, a crumpled piece of white paper was dropped from a height, y0 of 50.0 cm and caught on video until the paper hit the ground. My [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=263&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For this activity, our group (Beth, Aiyin, April, and I) captured a video of a free-falling object and determined kinematic variables from the video. Against a dark blue background, a crumpled piece of white paper was dropped from a height, y0 of 50.0 cm and caught on video until the paper hit the ground.  My goal in this activity was to determine the distance travelled by the paper (the crumpled paper only) for a particular time, t and compare it with the theoretical value.</p>
<p>The first step was to convert the wmv file into an avi file using Stoik Video Converter 2.0.  The video was then cropped to the significant number of frames, with a frame rate of 30 frames per second; this corresponds to  0.0333333 seconds between 2 frames.  The frames were then converted into separate images via VirtualDub 1.6.19.  For our video, there were 9 frames, and these were labeled 1.png to 9.png. A sample frame is shown below.  At the center of the blue background, 5 strips were pasted to indicate every 10th cm (10, 20, and so on).  This was done so that  the actual distance in centimeters could be determined by getting the ratio of pixels/cm from the picture. The topmost part of each white strip was used for measurement.  <a href="http://tonilei.files.wordpress.com/2008/09/1.png"><img class="aligncenter size-medium wp-image-268" title="1" src="http://tonilei.files.wordpress.com/2008/09/1.png?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<p><a href="http://tonilei.files.wordpress.com/2008/09/3.png"><img class="aligncenter size-medium wp-image-270" title="3" src="http://tonilei.files.wordpress.com/2008/09/3.png?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/10/9.png"><img class="aligncenter size-full wp-image-347" title="9" src="http://tonilei.files.wordpress.com/2008/10/9.png?w=420" alt=""   /></a></p>
<p>The images were binarized.</p>
<p><a href="http://tonilei.files.wordpress.com/2008/10/2.jpg"><img class="aligncenter size-full wp-image-345" title="2" src="http://tonilei.files.wordpress.com/2008/10/2.jpg?w=420" alt="" /></a></p>
<p><a href="http://tonilei.files.wordpress.com/2008/10/9.jpg"><img class="aligncenter size-full wp-image-346" title="9" src="http://tonilei.files.wordpress.com/2008/10/9.jpg?w=420" alt="" /></a></p>
<p>There wasn&#8217;t much difficulty in this part since the region of interest (ROI) was distinguishable from the background. After binarizing the image, the y-coordinate of the crumpled piece of paper was taken. Since the motion of the paper was too fast for the 30 frames/sec sampling rate of the videocam, we have an &#8220;extended&#8221; object instead of the crumpled paper, so the centroid of the &#8220;extended&#8221; object was taken instead. This was done using the the locate command.</p>
<p>The distance traveled by the paper, in pixels is dy, the difference  between the y-coordinates of the crumpled paper in the first and ninth frames.  (Values are non-integral because these are already from the centroid)</p>
<p>dy (in pixels) = (206.66667 &#8211; 77.604167) pixels = 129.062503 pixels</p>
<p>The number of pixels/cm was also measured; it&#8217;s equal to 2.9166666.  Dividing the distance travelled in pixels, dy by the number of pixels/cm, we have the distance travelled by the piece of paper in cm.</p>
<p>dy (in cm) = dy (in pixels) / (number of pixels/cm) = 129.062503 pixels / 2.9166666 pixels/cm</p>
<p>dy (in cm) = 44.25 cm</p>
<p>This is a reasonable answer since the video obtained was the falling of the paper from the 50 cm mark to a point before it hits the ground. Now, we get the theoretical value for this distance.</p>
<p>The equation for the motion of an object undergoing projectile motion along the y-axis is:</p>
<p>y = y0 + v0*t + (1/2)*g*t^2</p>
<p>where t is the time, y is the distance of the object from the origin at a time t, y0 is the initial distance, v0 is the initial velocity, and g is the acceleration due to gravity. Since this is a free fall, the initial velocity should be equal to zero, thus we have:</p>
<p>y = y0 + (1/2)*g*t^2</p>
<p>Since we are getting the distance travelled by the paper, we compute for y-y0 instead of y.</p>
<p>y-y0 = (1/2)*g*t^2</p>
<p>Using t= (0.0333333 sec/frame)*(9 frames) = 0.3 seconds and g=9.8 m/s^2 = 98 cm/s^2, the distance travelled by the paper (theoretical), y-y0 is:</p>
<p>y-y0 = (1/2)*(98 cm/s^2)*(0.3 sec)^2</p>
<p>y-y0 = 44.10 cm.</p>
<p>The percent error is:</p>
<p>% error = |theoretical &#8211; actual| / theoretical * 100 = | (44.10 &#8211; 44.25) cm| / 44.10 cm * 100</p>
<p>% error = 0.3401</p>
<p>This is a very small error. I give myself a grade of 10 for being able to successfully investigate this physical phenomenon (free fall of an object) using basic video/image processing techniques.</p>
<p>Thanks to my 3 groupmates in this activity &#8211; Aiyin Laganapan, Elizabeth Prieto, and April Teodoro &#8211; for all the help both in creating the free-fall set-up and in the processing of the video.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tonilei.wordpress.com/263/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tonilei.wordpress.com/263/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonilei.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonilei.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonilei.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonilei.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonilei.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonilei.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonilei.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonilei.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonilei.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonilei.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonilei.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonilei.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonilei.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonilei.wordpress.com/263/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=263&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonilei.wordpress.com/2008/09/09/activity-17-basic-video-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61833323006e900837e1ab8078b85c27?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonilei</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/1.png?w=300" medium="image">
			<media:title type="html">1</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/3.png?w=300" medium="image">
			<media:title type="html">3</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/10/9.png" medium="image">
			<media:title type="html">9</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/10/2.jpg" medium="image">
			<media:title type="html">2</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/10/9.jpg" medium="image">
			<media:title type="html">9</media:title>
		</media:content>
	</item>
		<item>
		<title>Activity 16 &#8211; Color Image Segmentation</title>
		<link>http://tonilei.wordpress.com/2008/09/02/activity-16-color-image-segmentation/</link>
		<comments>http://tonilei.wordpress.com/2008/09/02/activity-16-color-image-segmentation/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 03:27:27 +0000</pubDate>
		<dc:creator>tonilei</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonilei.wordpress.com/?p=240</guid>
		<description><![CDATA[Color segmentation is the process of separating a region of interest (ROI) from its background based on its color. First, a subregion must be cropped from the ROI, then its histogram must be obtained. Then, we determine which parts of the image have that particular color by determining the probability that a particular pixel is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=240&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Color segmentation is the process of separating a region of interest (ROI) from its background based on its color. First, a subregion must be cropped from the ROI, then its histogram must be obtained.  Then, we determine which parts of the image have that particular color by determining the probability that a particular pixel is a member of the ROI. There are two ways to do this: 1) Parametric and 2) Non-Parametric Segmentation.</p>
<p>Parametric Segmentation is carried out by assuming that the normalized chromaticity coordinates (NCC) &#8211; r and g (b is dependent on r and g, b = 1 &#8211; (r+g)) &#8211; follow a Gaussian distribution, where the probabilities for r and g are p(r) and p(g) respectively.  The probability, p(r) is given by:</p>
<p><a href="http://tonilei.files.wordpress.com/2008/09/pr.jpg"><img class="aligncenter size-full wp-image-260" title="pr" src="http://tonilei.files.wordpress.com/2008/09/pr.jpg?w=420" alt=""   /></a></p>
<p>where mu_r is the mean and sigma_r is the standard deviation for the r values in the image.  We use a similar expression for p(g), replacing the mean, standard deviation, and NCC with mu_g, sigma_g, and g, respectively. To get the joint probability that a pixel belongs to the ROI, we simply get the product of p(r) and p(g). The probabilities for all pixels is then rendered as an image.</p>
<p>For the following picture (a green tape dispenser), I used parametric segmentation to separate the green ROI from the background. Shown below it is the color segmented image.</p>
<p><img src="/DOCUME~1/APED23~1/LOCALS~1/Temp/moz-screenshot-1.jpg" alt="" /></p>
<p><a href="http://tonilei.files.wordpress.com/2008/09/green.jpg"><img class="aligncenter size-medium wp-image-244" src="http://tonilei.files.wordpress.com/2008/09/green.jpg?w=300&#038;h=167" alt="" width="300" height="167" /></a></p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/09/p1.jpg"><img class="aligncenter size-full wp-image-247" src="http://tonilei.files.wordpress.com/2008/09/p1.jpg?w=420" alt=""   /></a></p>
<p style="text-align:left;">Again I used parametric segmentation to separate the blue region from non-blue regions. The result is shown below.</p>
<p style="text-align:left;">
<p style="text-align:center;">
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/09/blueglove.jpg"><img class="aligncenter size-medium wp-image-249" src="http://tonilei.files.wordpress.com/2008/09/blueglove.jpg?w=300&#038;h=251" alt="" width="300" height="251" /></a></p>
<p style="text-align:center;">
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/09/pglove.jpg"><img class="aligncenter size-full wp-image-250" src="http://tonilei.files.wordpress.com/2008/09/pglove.jpg?w=420" alt=""   /></a></p>
<p style="text-align:left;">For both regions, the result is satisfactory; it was able to segment the chosen ROI from the background.</p>
<p style="text-align:center;">
<p style="text-align:left;">The second method is Non-parametric Segmentation. Compared to the first method, this one is not analytical; it simply makes use of a &#8220;look-up table&#8221; for the probability that a pixel is located within the region of interest.  The color histogram of the image is obtained, then using histogram backprojection the pixel value is given by its histogram value in chromaticity space.  Using these new pixel values, I obtained the following color-segmented images (note: 1.0 was added as a bias to make the gray values more obvious; this is the reason why the background is white and the ROI is dark):</p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/09/nonpargreen.jpg"><img class="aligncenter size-full wp-image-254" src="http://tonilei.files.wordpress.com/2008/09/nonpargreen.jpg?w=420" alt=""   /></a></p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/09/nonparblue.jpg"><img class="aligncenter size-full wp-image-255" src="http://tonilei.files.wordpress.com/2008/09/nonparblue.jpg?w=420" alt=""   /></a></p>
<p style="text-align:left;">The images are satisfactory, maybe even better than those obtained from parametric segmentation.  For the non-parametric method, even within the ROI itself, it is able to show which parts are more likely to be within the ROI (the differences in grayscale values in the color-segmented image correspond to the areas in the ROI having slightly different shades of blue or green).  The color-segmented images can be further improved by morphological operations such as opening or closing  in order to select the entire ROI.</p>
<p style="text-align:left;">I give myself a grade of 10 for being able to perform the two methods of color image segmentation successfully.</p>
<p style="text-align:left;">Thanks to Julie Dado and Jeric Tugaff for helping me with the color histogram code in parametric segmentation.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tonilei.wordpress.com/240/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tonilei.wordpress.com/240/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonilei.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonilei.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonilei.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonilei.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonilei.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonilei.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonilei.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonilei.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonilei.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonilei.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonilei.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonilei.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonilei.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonilei.wordpress.com/240/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=240&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonilei.wordpress.com/2008/09/02/activity-16-color-image-segmentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61833323006e900837e1ab8078b85c27?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonilei</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/pr.jpg" medium="image">
			<media:title type="html">pr</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/09/green.jpg?w=300" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/09/p1.jpg" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/09/blueglove.jpg?w=300" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/09/pglove.jpg" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/09/nonpargreen.jpg" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/09/nonparblue.jpg" medium="image" />
	</item>
		<item>
		<title>Activity 15 &#8211; Color Image Processing</title>
		<link>http://tonilei.wordpress.com/2008/08/28/activity-15-color-image-processing/</link>
		<comments>http://tonilei.wordpress.com/2008/08/28/activity-15-color-image-processing/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 03:27:59 +0000</pubDate>
		<dc:creator>tonilei</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonilei.wordpress.com/?p=216</guid>
		<description><![CDATA[When taking pictures, it sometimes happens that colors are not rendered correctly. For instance, a white object came become bluish or yellowish in the picture. In order to correct render the colors in the scene we are capturing, white balance is performed. &#8220;White balancing&#8221; is the process of setting the supposedly white portion of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=216&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When taking pictures, it sometimes happens that colors are not rendered correctly.  For instance, a white object came become bluish or yellowish in the picture. In order to correct render the colors in the scene we are capturing, white balance is performed.  &#8220;White balancing&#8221; is the process of setting the supposedly white portion of the image as white.  In this activity, we performed white balancing using two methods: by 1)  the Reference White Algorithm and 2) the Gray World Algorithm.</p>
<p>In the Reference White Algorithm, the red (R), green (G), and blue (B) pixel values of the image are divided by the R, G, B values of the the &#8220;white&#8221; portion respectively. Values greater than 1.0 are set to 1.0.  Shown below is a picture of several objects of different colors; it was taken inside the classroom, with a camera setting of &#8220;incandescent&#8221;. After it is the &#8220;white balanced&#8221; picture using the Reference White Algorithm.</p>
<p>Before:<a href="http://tonilei.files.wordpress.com/2008/08/i-incandescent1.jpg"><img class="aligncenter size-medium wp-image-219" src="http://tonilei.files.wordpress.com/2008/08/i-incandescent1.jpg?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<p>After:</p>
<p style="text-align:center;"><a href="http://tonilei.files.wordpress.com/2008/08/i-incandescent-rw.jpg"><img class="size-medium wp-image-220 aligncenter" src="http://tonilei.files.wordpress.com/2008/08/i-incandescent-rw.jpg?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<p style="text-align:left;">The white balancing was able to remove the &#8220;blue cast&#8221; in the image. (Note: The paper is now white!)</p>
<p>The second method is the Gray World Algorithm.  In this method, the R, G, and B values of the image are each divided by the average of the R, G, and B values, respectively.  Again, if the values are greater than 1.0, they are clipped to 1.0. Using the same unbalanced image, the before and after shots using the Gray World Algorithm are shown below:</p>
<p>Before:<a href="http://tonilei.files.wordpress.com/2008/08/i-incandescent1.jpg"><img class="aligncenter size-medium wp-image-219" src="http://tonilei.files.wordpress.com/2008/08/i-incandescent1.jpg?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<p style="text-align:left;">After:<a href="http://tonilei.files.wordpress.com/2008/08/i-incandescent-gw.jpg"><img class="aligncenter size-medium wp-image-221" src="http://tonilei.files.wordpress.com/2008/08/i-incandescent-gw.jpg?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<p style="text-align:left;">For Gray World, the &#8220;blue cast&#8221; was again removed!  On closer inspection, I noticed that the Reference White Algorithm did a better job because the paper is whiter and the other colors less dark.</p>
<p style="text-align:left;">Here is another example. The same scene (same objects, still inside the classroom with the same light source) has been captured with a camera setting of &#8220;cloudy.&#8221; The Before and After shots for both algorithms are shown below:</p>
<p style="text-align:left;">Before:</p>
<p><a href="http://tonilei.files.wordpress.com/2008/08/i-cloudy1.jpg"><img class="aligncenter size-medium wp-image-229" src="http://tonilei.files.wordpress.com/2008/08/i-cloudy1.jpg?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<p>After (using the Reference White Algorithm):</p>
<p><a href="http://tonilei.files.wordpress.com/2008/08/i-cloudy-rw.jpg"><img class="aligncenter size-medium wp-image-230" src="http://tonilei.files.wordpress.com/2008/08/i-cloudy-rw.jpg?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<p>After (using the Gray World Algorithm):</p>
<p><a href="http://tonilei.files.wordpress.com/2008/08/i-cloudy-gw.jpg"><img class="aligncenter size-medium wp-image-231" src="http://tonilei.files.wordpress.com/2008/08/i-cloudy-gw.jpg?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<p>The &#8220;yellow cast&#8221; has been removed from the 2 &#8220;After&#8221; images; however, using the Reference White algorithm is better.  The paper is &#8220;whiter&#8221; as compared to that of the Gray World balanced image, which is a bit bluer.  The &#8220;After&#8221; picture from the RW algorithm produced the closest rendition of the original colors of the objects.</p>
<p>For the next part of the activity, objects of the same hue were captured in a single image using the &#8220;wrong setting&#8221; and then white balanced.  The image has several leaves of different colors; it was pictured outdoors so the illumination is daylight, but the setting was &#8220;incandescent.&#8221;  The Before and After images are shown below.</p>
<p>Before:</p>
<p><a href="http://tonilei.files.wordpress.com/2008/08/o-incan-leaf.jpg"><img class="aligncenter size-medium wp-image-233" src="http://tonilei.files.wordpress.com/2008/08/o-incan-leaf.jpg?w=234&#038;h=300" alt="" width="234" height="300" /></a></p>
<p>After (using the Reference White Algorithm):</p>
<p><a href="http://tonilei.files.wordpress.com/2008/08/o-incan-leaf-rw.jpg"><img class="aligncenter size-medium wp-image-234" src="http://tonilei.files.wordpress.com/2008/08/o-incan-leaf-rw.jpg?w=234&#038;h=300" alt="" width="234" height="300" /></a></p>
<p>After (using the Gray World Algorithm):</p>
<p style="text-align:left;"><a href="http://tonilei.files.wordpress.com/2008/08/o-incan-leaf-gw.jpg"><img class="aligncenter size-medium wp-image-236" src="http://tonilei.files.wordpress.com/2008/08/o-incan-leaf-gw.jpg?w=234&#038;h=300" alt="" width="234" height="300" /></a></p>
<p style="text-align:left;">Visually, the RW balanced image seems to have better green hues and the Gray World image has a bit of a reddish and bluish tinge.</p>
<p style="text-align:left;">Overall, the Reference White Algorithm seems to give a more balanced image, color-wise.</p>
<p style="text-align:left;">I give myself a grade of 10 for this activity because I was able to perform white balancing using the 2 algorithms.</p>
<p style="text-align:left;">Thank you, Aiyin and Beth for taking the pictures, Mark Leo for obtaining the leaves, and Rica and Benj for the tip re: clipping the values to 1.0.</p>
<p style="text-align:left;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p style="text-align:left;">The following was my code for this activity:</p>
<p style="text-align:left;">
im=imread(&#8216;i-cloudy.jpg&#8217;);<br />
w=imread(&#8216;i-cloudy-white.jpg&#8217;);<br />
Rw=mean(w(:,:,1));<br />
Gw=mean(w(:,:,2));<br />
Bw=mean(w(:,:,3));</p>
<p>//Reference White<br />
imw(:,:,1)=im(:,:,1)/Rw;<br />
imw(:,:,2)=im(:,:,2)/Gw;<br />
imw(:,:,3)=im(:,:,3)/Bw;<br />
Mw=max(max(max(imw)));<br />
newimw=imw./Mw;<br />
//im(find(im&gt;=1)) = 1<br />
imwrite(newimw,&#8217;i-cloudy-rw.jpg&#8217;);</p>
<p>//Gray-world<br />
Rwg=mean(im(:,:,1));<br />
Gwg=mean(im(:,:,2));<br />
Bwg=mean(im(:,:,3));</p>
<p>ig(:,:,1)=im(:,:,1)/Rwg;<br />
ig(:,:,2)=im(:,:,2)/Gwg;<br />
ig(:,:,3)=im(:,:,3)/Bwg;<br />
Mg=max(max(max(ig)));<br />
newimg=ig./Mg;<br />
//im(find(im&gt;=1)) = 1<br />
imwrite(newimg,&#8217;i-cloudy-gw.jpg&#8217;);</p>
<p style="text-align:left;">
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tonilei.wordpress.com/216/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tonilei.wordpress.com/216/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonilei.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonilei.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonilei.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonilei.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonilei.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonilei.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonilei.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonilei.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonilei.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonilei.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonilei.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonilei.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonilei.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonilei.wordpress.com/216/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=216&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonilei.wordpress.com/2008/08/28/activity-15-color-image-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61833323006e900837e1ab8078b85c27?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonilei</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/08/i-incandescent1.jpg?w=300" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/i-incandescent-rw.jpg?w=300" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/i-incandescent1.jpg?w=300" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/i-incandescent-gw.jpg?w=300" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/i-cloudy1.jpg?w=300" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/i-cloudy-rw.jpg?w=300" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/i-cloudy-gw.jpg?w=300" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/o-incan-leaf.jpg?w=234" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/o-incan-leaf-rw.jpg?w=234" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/o-incan-leaf-gw.jpg?w=234" medium="image" />
	</item>
		<item>
		<title>Activity 14 &#8211; Stereometry</title>
		<link>http://tonilei.wordpress.com/2008/08/26/activity-14-stereometry/</link>
		<comments>http://tonilei.wordpress.com/2008/08/26/activity-14-stereometry/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 14:35:03 +0000</pubDate>
		<dc:creator>tonilei</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonilei.wordpress.com/?p=200</guid>
		<description><![CDATA[The goal of this exercise in stereometry is to reconstruct a 3D object by taking multiple pictures of it, either by using 2 cameras or taking 2 images of the object. The object that I will reconstruct is a rubix cube; I obtained these two images by moving the cube by 4 cm in the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=200&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The goal of this exercise in stereometry is to reconstruct a 3D object by taking multiple pictures of it, either by using 2 cameras or taking 2 images of the object.  The object that I will reconstruct is a rubix cube; I obtained these two images by moving the cube by 4 cm in the 2nd image:</p>
<p><img class="aligncenter size-medium wp-image-208" src="http://tonilei.files.wordpress.com/2008/08/cube1.jpg?w=300&#038;h=140" alt="" width="300" height="140" /></p>
<p><img class="aligncenter size-medium wp-image-210" src="http://tonilei.files.wordpress.com/2008/08/cube3.jpg?w=300&#038;h=140" alt="" width="300" height="140" /></p>
<p>The first step in reconstruction is to determine the focal length, f of the camera.  I obtained f from the information provided in the Summary of properties of the images, where f=6 mm.</p>
<p>Next, I obtained the x- and y-coordinates of 25 points in the cube for each image (x1 for image 1, x2 for image 2).  From these points, I was able to get the z-coordinates, using the equation:</p>
<p><img src="/DOCUME%7E1/TONILE%7E1/LOCALS%7E1/Temp/moz-screenshot.jpg" alt="" /><a href="http://tonilei.files.wordpress.com/2008/08/defn-of-z.jpg"><img class="aligncenter size-full wp-image-213" src="http://tonilei.files.wordpress.com/2008/08/defn-of-z.jpg?w=420" alt=""   /></a></p>
<p>Having obtained z, I plotted the x, y, and z components using the splin2D function and here is what I obtained:</p>
<p><a href="http://tonilei.files.wordpress.com/2008/10/plot1.gif"><img class="aligncenter size-medium wp-image-358" title="plot1" src="http://tonilei.files.wordpress.com/2008/10/plot1.gif?w=300&#038;h=226" alt="" width="300" height="226" /></a></p>
<p>This resembles one side (i.e. the top portion) of the rubix cube, with a few &#8220;waves.&#8221; The waviness of the reconstruction may be due to the fact that a small number of samples were obtained.</p>
<p>I give myself a grade of 8 for this activity for not being able to reconstruct the entire rubix cube.</p>
<p>I would like to thank Elizabeth Prieto and Jeric Tugaff for helping me in this activity.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tonilei.wordpress.com/200/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tonilei.wordpress.com/200/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonilei.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonilei.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonilei.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonilei.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonilei.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonilei.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonilei.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonilei.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonilei.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonilei.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonilei.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonilei.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonilei.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonilei.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=200&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonilei.wordpress.com/2008/08/26/activity-14-stereometry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61833323006e900837e1ab8078b85c27?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonilei</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/08/cube1.jpg?w=300" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/cube3.jpg?w=300" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/defn-of-z.jpg" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/10/plot1.gif?w=300" medium="image">
			<media:title type="html">plot1</media:title>
		</media:content>
	</item>
		<item>
		<title>Activity 13 &#8211; Photometric Stereo</title>
		<link>http://tonilei.wordpress.com/2008/08/07/activity-13-photometric-stereo/</link>
		<comments>http://tonilei.wordpress.com/2008/08/07/activity-13-photometric-stereo/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 01:02:50 +0000</pubDate>
		<dc:creator>tonilei</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonilei.wordpress.com/?p=188</guid>
		<description><![CDATA[In Photometric Stereo, we reconstruct the 3D shape of an object by capturing several images of an object &#8211; using a single view but with different positions of the light source. In this activity, we aim to recreate the 3D shape of the following pictures with different light sources: To do this, we evaluate the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=188&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In Photometric Stereo, we reconstruct the 3D shape of an object by capturing several images of an object &#8211; using a single view but with different positions of the light source. In this activity, we aim to recreate the 3D shape of the following pictures with different light sources:<a href="http://tonilei.files.wordpress.com/2008/08/images-diff-sources.gif"><img class="aligncenter size-medium wp-image-192" src="http://tonilei.files.wordpress.com/2008/08/images-diff-sources.gif?w=300&#038;h=199" alt="" width="300" height="199" /></a></p>
<p>To do this, we evaluate the  equation <a href="http://tonilei.files.wordpress.com/2008/08/eq9.jpg"><img class="aligncenter size-medium wp-image-193" src="http://tonilei.files.wordpress.com/2008/08/eq9.jpg?w=71&#038;h=32" alt="" width="71" height="32" /></a> where I is the image matrix, V is the matrix containing the position of the light sources, and g is the matrix for the reflectance of the image. Since we know the matrix I and V, we obtain g:</p>
<p><a href="http://tonilei.files.wordpress.com/2008/08/eq10.jpg"><img class="aligncenter size-medium wp-image-194" src="http://tonilei.files.wordpress.com/2008/08/eq10.jpg?w=136&#038;h=34" alt="" width="136" height="34" /></a></p>
<p>from which, we obtain the unit vector of n:<a href="http://tonilei.files.wordpress.com/2008/08/nhat.jpg"><img class="aligncenter size-medium wp-image-201" src="http://tonilei.files.wordpress.com/2008/08/nhat.jpg?w=50&#038;h=51" alt="" width="50" height="51" /></a></p>
<p>We get the gradient of c = z &#8211; f(x,y) = 0:</p>
<p><a href="http://tonilei.files.wordpress.com/2008/08/grad-c.jpg"><img class="aligncenter size-medium wp-image-202" src="http://tonilei.files.wordpress.com/2008/08/grad-c.jpg?w=248&#038;h=51" alt="" width="248" height="51" /></a></p>
<p>using the following code:</p>
<p>for j=1:c<br />
dfdx(j)=-nhat(1,j)/(nhat(3,j)+1.0e-15);<br />
dfdy(j)=-nhat(2,j)/(nhat(3,j)+1.0e-15);<br />
end</p>
<p>and evaluate the line integral to get the Image matrix:</p>
<p><a href="http://tonilei.files.wordpress.com/2008/08/integral.jpg"><img class="aligncenter size-medium wp-image-203" src="http://tonilei.files.wordpress.com/2008/08/integral.jpg?w=266&#038;h=60" alt="" width="266" height="60" /></a></p>
<p>using the following code:</p>
<p>lintfx=cumsum(dfdx2di,2);<br />
lintfy=cumsum(dfdy2di,1);<br />
Image=lintfx + lintfy;.</p>
<p>The Image matrix is plotted and the result is a hemisphere. Voila!</p>
<p><a href="http://tonilei.files.wordpress.com/2008/08/hemisphere11.gif"><img class="aligncenter size-medium wp-image-196" src="http://tonilei.files.wordpress.com/2008/08/hemisphere11.gif?w=300&#038;h=226" alt="" width="300" height="226" /></a></p>
<p>I give myself a grade of 10 for this activity for being able to reconstruct the sphere (3D) from the 4 images (2D).</p>
<p>Thanks to my collaborators: Benj Palmares and Julie Dado.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tonilei.wordpress.com/188/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tonilei.wordpress.com/188/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonilei.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonilei.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonilei.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonilei.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonilei.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonilei.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonilei.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonilei.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonilei.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonilei.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonilei.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonilei.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonilei.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonilei.wordpress.com/188/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=188&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonilei.wordpress.com/2008/08/07/activity-13-photometric-stereo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61833323006e900837e1ab8078b85c27?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonilei</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/08/images-diff-sources.gif?w=300" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/eq9.jpg?w=71" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/eq10.jpg?w=136" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/nhat.jpg?w=50" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/grad-c.jpg?w=248" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/integral.jpg?w=266" medium="image" />

		<media:content url="http://tonilei.files.wordpress.com/2008/08/hemisphere11.gif?w=300" medium="image" />
	</item>
		<item>
		<title>Activity 12 &#8211; Correcting Geometric Distortions</title>
		<link>http://tonilei.wordpress.com/2008/08/06/activity-12-correcting-geometric-distortions-under-construction/</link>
		<comments>http://tonilei.wordpress.com/2008/08/06/activity-12-correcting-geometric-distortions-under-construction/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 14:54:06 +0000</pubDate>
		<dc:creator>tonilei</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonilei.wordpress.com/?p=184</guid>
		<description><![CDATA[Geometric distortions are usually a result of imperfections in the imaging system (e.g. due to the camera&#8217;s lens) or improper capturing of an image (e.g. taking a picture at a wrong angle).  To correct for geometric distortions, we get the new coordinates for the undistorted image and then substitute with the gray level values. I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=184&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Geometric distortions are usually a result of imperfections in the imaging system (e.g. due to the camera&#8217;s lens) or improper capturing of an image (e.g. taking a picture at a wrong angle).  To correct for geometric distortions, we get the new coordinates for the undistorted image and then substitute with the gray level values.</p>
<p>I used the following image (provided by Dr. Soriano) for this activity:<a href="http://tonilei.files.wordpress.com/2008/08/capiz.jpg"><img class="aligncenter size-medium wp-image-185" src="http://tonilei.files.wordpress.com/2008/08/capiz.jpg?w=200&#038;h=267" alt="" width="200" height="267" /></a></p>
<p>One notices that in this image, the window&#8217;s edges do not appear as straight lines. The first process in correcting this image is to</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tonilei.wordpress.com/184/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tonilei.wordpress.com/184/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonilei.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonilei.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonilei.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonilei.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonilei.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonilei.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonilei.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonilei.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonilei.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonilei.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonilei.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonilei.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonilei.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonilei.wordpress.com/184/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonilei.wordpress.com&amp;blog=3467507&amp;post=184&amp;subd=tonilei&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonilei.wordpress.com/2008/08/06/activity-12-correcting-geometric-distortions-under-construction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61833323006e900837e1ab8078b85c27?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonilei</media:title>
		</media:content>

		<media:content url="http://tonilei.files.wordpress.com/2008/08/capiz.jpg?w=200" medium="image" />
	</item>
	</channel>
</rss>
