<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7918007414439081515</id><updated>2011-07-08T09:22:17.323-07:00</updated><title type='text'>Wanna Eat Six Kamatis</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>20</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-3654856981014584420</id><published>2009-10-12T08:53:00.000-07:00</published><updated>2009-10-12T10:07:34.386-07:00</updated><title type='text'>ACTIVITY 19 Restoration of Blurred Image</title><content type='html'>&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;In this activity, we demonstrate the degradation process and the restoration of the degraded image. A diagram is shown in Figure 1 to illustrate the process of degradation and then restoration of an image. The degradation part is equivalent to equation 1 where G, H, F and N are the Fourier transforms of the degraded image, degradation function, original image and noise, respectively. We used the model of motion blur as our degradation function (see equation 2). The assumption of this model is that the blurring is due to linear motion between the image and the sensor during image acquisition. In equation 2, T is the duration of the exposure, a and b are the total distances for which the image has been displaced in the x- and y-direction, respectively. In addition to degradation, noise was also introduced to the image in the form of Gaussian. The equation for this type of noise was already shown in the previous activity. The restoration process is through minimum mean square error (Weiner) filtering. Equations 3 and 4 give us the Fourier transform of the restored image. So, the restored image can be shown by getting the inverse Fourier of these transforms. Note that u and v are just the indices of the pixels in the image.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNg3Ytu4uI/AAAAAAAAAcw/rnuPjN2s_FA/s1600-h/diagram.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 138px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNg3Ytu4uI/AAAAAAAAAcw/rnuPjN2s_FA/s400/diagram.jpg" alt="" id="BLOGGER_PHOTO_ID_5391759683535954658" border="0" /&gt;&lt;/a&gt;Figure 1.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNg3LnMpMI/AAAAAAAAAco/utwjL6mRQ-o/s1600-h/eq1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 389px; height: 46px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNg3LnMpMI/AAAAAAAAAco/utwjL6mRQ-o/s400/eq1.jpg" alt="" id="BLOGGER_PHOTO_ID_5391759680018883778" border="0" /&gt;&lt;/a&gt;Equation 1.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNg2us4d7I/AAAAAAAAAcg/v00WlLX-s7I/s1600-h/eq2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 62px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNg2us4d7I/AAAAAAAAAcg/v00WlLX-s7I/s400/eq2.jpg" alt="" id="BLOGGER_PHOTO_ID_5391759672258099122" border="0" /&gt;&lt;/a&gt;Equation 2.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNge0aH-jI/AAAAAAAAAcQ/yjf3TlZ4bGk/s1600-h/eq3.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 86px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNge0aH-jI/AAAAAAAAAcQ/yjf3TlZ4bGk/s400/eq3.jpg" alt="" id="BLOGGER_PHOTO_ID_5391759261473176114" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNgeYaFUAI/AAAAAAAAAcI/AAlRMGXBj8Y/s1600-h/eq3_a.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 85px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNgeYaFUAI/AAAAAAAAAcI/AAlRMGXBj8Y/s400/eq3_a.jpg" alt="" id="BLOGGER_PHOTO_ID_5391759253956808706" border="0" /&gt;&lt;/a&gt;Equation 3.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNgeCa4AyI/AAAAAAAAAcA/1dcNzcCBg6o/s1600-h/eq4.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 99px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNgeCa4AyI/AAAAAAAAAcA/1dcNzcCBg6o/s400/eq4.jpg" alt="" id="BLOGGER_PHOTO_ID_5391759248054551330" border="0" /&gt;&lt;/a&gt;Equation 4.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNgdgk_eKI/AAAAAAAAAb4/-Gm8BaghI9o/s1600-h/orig.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 389px; height: 292px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNgdgk_eKI/AAAAAAAAAb4/-Gm8BaghI9o/s400/orig.jpg" alt="" id="BLOGGER_PHOTO_ID_5391759238970177698" border="0" /&gt;&lt;/a&gt;Figure 1.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The following are the investigations I did in relation to the degradation and restoration of the image shown in Figure 1.&lt;br /&gt;&lt;br /&gt;1.) The value of T in H (degradation function, equation 2) was varied.&lt;br /&gt;Figure 2 shows the degraded and restored images for different values of T. As you can see, the only detectable difference in the images but not that obvious is that the image becomes whiter as the value of T is increased. This difference becomes more obvious when the images are restored as shown in Figure 2. This is because T is the duration of the exposure. So, the longer the time the image is exposed, the whiter the image will be.&lt;br /&gt;&lt;br /&gt;2.) The values of a and b (same value) were varied.&lt;br /&gt;Figure 3 shows the degraded and restored images for different values of a and b (same value). a and b are the total displacement in the x- and y-direction. So, the larger the values of these variables are,the more blurry the image will be. Moreover, the blurriness is equal in the two directions since a and b are equal. The more blurry the image is, the harder it is to restore. As you can see in Figure 3, the level of restoration decreases as the values of a and b increase.&lt;br /&gt;&lt;br /&gt;3.) The values of a and b (different values) were varied.&lt;br /&gt;Figure 4 shows the degraded and restored images when a and b (different values) were varied. Since a and b are not equal anymore, the blurriness is not the same in the two directions (x and y). As you can see, when a is larger(smaller), the degraded image appears to be stretched horizontally (vertically). Comparing the restored images, it can be observed that the lines (contour) of the texts are darker when a is larger than b.&lt;br /&gt;&lt;br /&gt;4.) The standard deviation and mean in the Gaussian noise were varied.&lt;br /&gt;Figure 5 shows the degraded and restored images for different values of the standard deviation and mean. The larger the value of these parameters are, the noisier the image is. Similar to the results of varying a and b but of equal values, it is harder to restore the image when it is noisier.&lt;br /&gt;&lt;br /&gt;4.) The value of K in equation 4 was varied.&lt;br /&gt;This time, we did not vary the degradation process but the restoration process. Figure 6 shows the restored images for different values of K. When the value of K is at extreme 0 or 1, the filter failed to restore the image. When it is near 0, the blurriness is removed but the noise remains. In fact, the noise already covers the entire image that it is not visible anymore. On the other hand, when it is near 1, the noise is removed but the image becomes more blurry. Thus, the value of K must be properly chosen to produce the best restored images. Compared to the restored image using equation 6, equation 7 produces images that are still noisy. This is because this equation assumes that the noise is spectral white. However, in our case, the noise we used is Gaussian. This is why equation 6 has better results because it is able to use the right noise.&lt;br /&gt;&lt;/div&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNUsjGDqzI/AAAAAAAAAaQ/Heoypj9W_vk/s1600-h/diff_T_results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 201px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNUsjGDqzI/AAAAAAAAAaQ/Heoypj9W_vk/s400/diff_T_results.png" alt="" id="BLOGGER_PHOTO_ID_5391746303204240178" border="0" /&gt;&lt;/a&gt;Figure 2.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNUrwQYp3I/AAAAAAAAAaI/7CGDFtb5coE/s1600-h/same_ab_results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 150px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNUrwQYp3I/AAAAAAAAAaI/7CGDFtb5coE/s400/same_ab_results.png" alt="" id="BLOGGER_PHOTO_ID_5391746289557350258" border="0" /&gt;&lt;/a&gt;Figure 3.&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNUrOfIFqI/AAAAAAAAAaA/sBcli3S9nL8/s1600-h/diff_ab.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 302px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNUrOfIFqI/AAAAAAAAAaA/sBcli3S9nL8/s400/diff_ab.png" alt="" id="BLOGGER_PHOTO_ID_5391746280492373666" border="0" /&gt;&lt;/a&gt;Figure 4.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNUqiUEa2I/AAAAAAAAAZ4/djXrypcPzeU/s1600-h/diff_noise_results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 150px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNUqiUEa2I/AAAAAAAAAZ4/djXrypcPzeU/s400/diff_noise_results.png" alt="" id="BLOGGER_PHOTO_ID_5391746268634835810" border="0" /&gt;&lt;/a&gt;Figure 5.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNUpk89_mI/AAAAAAAAAZw/eXVqaI1PVcg/s1600-h/diff_K_results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 59px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNUpk89_mI/AAAAAAAAAZw/eXVqaI1PVcg/s400/diff_K_results.png" alt="" id="BLOGGER_PHOTO_ID_5391746252163382882" border="0" /&gt;&lt;/a&gt;Figure 6.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;I would give myself a grade of 10 for this activity. &lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-3654856981014584420?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/3654856981014584420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-19-restoration-of-blurred.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/3654856981014584420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/3654856981014584420'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-19-restoration-of-blurred.html' title='ACTIVITY 19 Restoration of Blurred Image'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_EPNyhV1xE8I/StNg3Ytu4uI/AAAAAAAAAcw/rnuPjN2s_FA/s72-c/diagram.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-3882742147419856243</id><published>2009-10-08T07:48:00.001-07:00</published><updated>2009-10-12T10:39:13.709-07:00</updated><title type='text'>ACTIVITY 18 Noise Modeling and Basic Image Restoration</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;In this activity, we explored the different types of noise and used the common filters to clean the noisy images. I used Figure 1 as my original image. The noise we introduced on the image are the common types of noise, namely, Gaussian (normal), exponential, gamma, Rayleigh, uniform and impulse (salt&amp;amp; pepper). These noises are described in equations 1 to 6. The resulting noisy images are shown in Figure 2. On the right side of the images are the histogram (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;PDF&lt;/span&gt;) of the noisy images. Given a noisy image with unknown type of noise, one can then determine the type of noise from its &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;PDF&lt;/span&gt;. However, it must be noted that the images I am talking here are &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;grayscale&lt;/span&gt; images.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNjVqt_MwI/AAAAAAAAAdA/OjtkiDRtlmc/s1600-h/image.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 201px; height: 201px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNjVqt_MwI/AAAAAAAAAdA/OjtkiDRtlmc/s400/image.jpg" alt="" id="BLOGGER_PHOTO_ID_5391762402788193026" border="0" /&gt;&lt;/a&gt;Figure 1.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt; &lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNjVTXzI-I/AAAAAAAAAc4/gx1GiOpmIOQ/s1600-h/noise.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 182px; height: 400px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNjVTXzI-I/AAAAAAAAAc4/gx1GiOpmIOQ/s400/noise.png" alt="" id="BLOGGER_PHOTO_ID_5391762396521112546" border="0" /&gt;&lt;/a&gt;Figure 2.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNkuRqVdDI/AAAAAAAAAdw/3HcMeXH4k9w/s1600-h/eq1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 386px; height: 117px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNkuRqVdDI/AAAAAAAAAdw/3HcMeXH4k9w/s400/eq1.jpg" alt="" id="BLOGGER_PHOTO_ID_5391763925070345266" border="0" /&gt;&lt;/a&gt;Equation 1. Gaussian (normal) noise.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNj7hZ6dSI/AAAAAAAAAdo/fucBMITkqFQ/s1600-h/eq2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 282px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNj7hZ6dSI/AAAAAAAAAdo/fucBMITkqFQ/s400/eq2.jpg" alt="" id="BLOGGER_PHOTO_ID_5391763053123106082" border="0" /&gt;&lt;/a&gt;Equation 2. Rayleigh noise.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNj7PI4dkI/AAAAAAAAAdg/J5_ovGzcBSg/s1600-h/eq3.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 374px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNj7PI4dkI/AAAAAAAAAdg/J5_ovGzcBSg/s400/eq3.jpg" alt="" id="BLOGGER_PHOTO_ID_5391763048219833922" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Equation 3. Erlang (gamma) noise.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNj64ZZAqI/AAAAAAAAAdY/iCVzMwXV5wQ/s1600-h/eq4.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 390px; height: 400px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNj64ZZAqI/AAAAAAAAAdY/iCVzMwXV5wQ/s400/eq4.jpg" alt="" id="BLOGGER_PHOTO_ID_5391763042115060386" border="0" /&gt;&lt;/a&gt;Equation 4. Exponential noise.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNj6R70BrI/AAAAAAAAAdQ/MO51F8J4bso/s1600-h/eq5.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 378px; height: 400px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNj6R70BrI/AAAAAAAAAdQ/MO51F8J4bso/s400/eq5.jpg" alt="" id="BLOGGER_PHOTO_ID_5391763031790454450" border="0" /&gt;&lt;/a&gt;Equation 5. Uniform noise.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNj562_98I/AAAAAAAAAdI/8Q6Wi1g1w10/s1600-h/eq6.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 159px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNj562_98I/AAAAAAAAAdI/8Q6Wi1g1w10/s400/eq6.jpg" alt="" id="BLOGGER_PHOTO_ID_5391763025596250050" border="0" /&gt;&lt;/a&gt;Equation 6. Impulse (salt &amp;amp; pepper) noise.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The filters I used are the following: arithmetic mean filter, geometric mean filter, harmonic  mean filter and &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;contraharmonic&lt;/span&gt; mean filter. Equations 7 to 10 illustrate how these filters work. Figure 3 shows the cleaned images after applying the different filters. As you can see, no filter was able to perfectly restore the noisy images to the original image. For different types of noise introduced, a filter cleans the noisy images differently. Consider the cleaned images when &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;ageometric&lt;/span&gt; mean filter was used (3rd row of Figure 3). The image with impulse noise obviously has a different cleaned image as compared to the other noises. Arithmetic mean and geometric mean slightly clean the image but it can be observed that there is partial blurring. Harmonic mean filter has the best result in some images (gamma and exponential) but it also fails to restore some images (normal and uniform). I think this is due to the type of distribution these noises produce. Gamma and exponential have similar &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;PDF&lt;/span&gt;, as well as normal and uniform. The cleaned images using &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;contraharmonic&lt;/span&gt; filter is shown in Figure 4. Recall equation 10. When Q is +/-, salt(white)/pepper (black) noise is removed. This is why the images is dark/bright when Q is +/-.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNlltsloEI/AAAAAAAAAeQ/-XntVhZtH8c/s1600-h/eq7.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 383px; height: 111px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNlltsloEI/AAAAAAAAAeQ/-XntVhZtH8c/s400/eq7.jpg" alt="" id="BLOGGER_PHOTO_ID_5391764877488791618" border="0" /&gt;&lt;/a&gt;Equation 7. Arithmetic mean filter.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNllKn3pvI/AAAAAAAAAeI/Hc2yZirNAVw/s1600-h/eq8.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 385px; height: 166px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNllKn3pvI/AAAAAAAAAeI/Hc2yZirNAVw/s400/eq8.jpg" alt="" id="BLOGGER_PHOTO_ID_5391764868073760498" border="0" /&gt;&lt;/a&gt;Equation 8. Geometric mean filter.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNlkofMi7I/AAAAAAAAAeA/MRv2_LwK1Dc/s1600-h/eq9.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 361px; height: 160px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNlkofMi7I/AAAAAAAAAeA/MRv2_LwK1Dc/s400/eq9.jpg" alt="" id="BLOGGER_PHOTO_ID_5391764858910575538" border="0" /&gt;&lt;/a&gt;Equation 9. Harmonic mean filter.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNlkPg_EjI/AAAAAAAAAd4/PEOVAK85gkY/s1600-h/eq10.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 369px; height: 201px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNlkPg_EjI/AAAAAAAAAd4/PEOVAK85gkY/s400/eq10.jpg" alt="" id="BLOGGER_PHOTO_ID_5391764852207194674" border="0" /&gt;&lt;/a&gt;Equation 10. Contraharmonic mean filter.&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss3-PEkf9_I/AAAAAAAAAYg/arJw_K8h9No/s1600-h/results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 317px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss3-PEkf9_I/AAAAAAAAAYg/arJw_K8h9No/s400/results.png" alt="" id="BLOGGER_PHOTO_ID_5390243863910676466" border="0" /&gt;&lt;/a&gt;Figure 3. The first row is the set of images with noise incorporated in the following sequence: salt &amp;amp; pepper, exponential, normal (Gaussian), gamma, uniform. In the succeeding rows are the resulting images after applying the arithmetic filter, geometric filter and harmonic filter, respectively.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss3-OBH26XI/AAAAAAAAAYY/NJZFjz01u24/s1600-h/results_conharm.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 239px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss3-OBH26XI/AAAAAAAAAYY/NJZFjz01u24/s400/results_conharm.png" alt="" id="BLOGGER_PHOTO_ID_5390243845805369714" border="0" /&gt;&lt;/a&gt;Figure 4. The first row is the set of images with noise incorporated in the following sequence: salt &amp;amp; pepper, exponential, normal (Gaussian), gamma, uniform. In the succeeding rows are the resulting images after applying the contraharmonic mean filter with Q (-) and Q (+), respectively.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In equations 7 to 10, notice that the computation of the new pixel values is confined in a window of size m x n. I investigated how the cleaning varies for different window sizes. Figure 5 shows the cleaned images. As you can see, more noise is removed when the window size is bigger. However, the images become more blurry also. So, the window size must be properly chosen such that enough noise is removed and the restored image is not so blurry.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss39ANU9G3I/AAAAAAAAAYQ/JzB5-kBiyMc/s1600-h/window+size.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 239px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss39ANU9G3I/AAAAAAAAAYQ/JzB5-kBiyMc/s400/window+size.png" alt="" id="BLOGGER_PHOTO_ID_5390242509051730802" border="0" /&gt;&lt;/a&gt;Figure 5. The resulting images after applying all the filters with different window sizes&lt;br /&gt;(1st row - 3 x 3, 2nd - 5 x 5, 3rd - 9 x 9)  in one of the noisy images.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt; I also tried applying the filters to the noisy images I downloaded from the internet (see Figure 6). From their PDFs,it can be inferred that the noise is Gaussian. The cleaned images are shown in Figures 7 to 10. As you can see, the restoration is still not perfect. The results are just the same as the cleaning of the images in Figure 2.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNpV1S3kaI/AAAAAAAAAeY/GpiSSk8jp3g/s1600-h/images_pdf.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 242px; height: 400px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNpV1S3kaI/AAAAAAAAAeY/GpiSSk8jp3g/s400/images_pdf.png" alt="" id="BLOGGER_PHOTO_ID_5391769002697003426" border="0" /&gt;&lt;/a&gt;Figure 6. PDFs of the images.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss38_u7NuhI/AAAAAAAAAYI/q8b2hE5SZ40/s1600-h/image+1+results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 396px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss38_u7NuhI/AAAAAAAAAYI/q8b2hE5SZ40/s400/image+1+results.png" alt="" id="BLOGGER_PHOTO_ID_5390242500890704402" border="0" /&gt;&lt;/a&gt;Figure 7.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss38_PGRq9I/AAAAAAAAAYA/V9Spug61Qmc/s1600-h/image+2+results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 221px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss38_PGRq9I/AAAAAAAAAYA/V9Spug61Qmc/s400/image+2+results.png" alt="" id="BLOGGER_PHOTO_ID_5390242492347165650" border="0" /&gt;&lt;/a&gt;Figure 8.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss38-WKRgXI/AAAAAAAAAX4/8jeaLdqB_ZM/s1600-h/image3+results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 266px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss38-WKRgXI/AAAAAAAAAX4/8jeaLdqB_ZM/s400/image3+results.png" alt="" id="BLOGGER_PHOTO_ID_5390242477063111026" border="0" /&gt;&lt;/a&gt;Figure 9.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss3893LMBHI/AAAAAAAAAXw/B_6SCAm-kCo/s1600-h/image+4+results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 266px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss3893LMBHI/AAAAAAAAAXw/B_6SCAm-kCo/s400/image+4+results.png" alt="" id="BLOGGER_PHOTO_ID_5390242468745446514" border="0" /&gt;&lt;/a&gt;Figure 10.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;I would give myself a grade of 10 for this activity.&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-3882742147419856243?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/3882742147419856243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-18.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/3882742147419856243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/3882742147419856243'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-18.html' title='ACTIVITY 18 Noise Modeling and Basic Image Restoration'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_EPNyhV1xE8I/StNjVqt_MwI/AAAAAAAAAdA/OjtkiDRtlmc/s72-c/image.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-7364040083030007418</id><published>2009-10-08T07:45:00.000-07:00</published><updated>2009-10-12T20:16:05.661-07:00</updated><title type='text'>ACTIVITY 17 Photometric Stereo</title><content type='html'>&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;In this activity, we used the technique photometric stereo in constructing the 3D shape of an object. This technique works under the assumption that the source is at infinity and so, the radial waves reaching the surface appear as planar waves. Moreover, it is assumed that the intensity captured by a camera at point (x,y) is directly proportional to the brightness of the surface at that point.&lt;br /&gt;&lt;br /&gt;By capturing multiple images with the sources at different locations, one can estimate the shape of the object. The sources can be represented by matrix V in equation 2 where Vn1, Vn2 and Vn3 are the component of the source n in the x-, y- and z- direction, respectively. If we know the intensity of the surface image captured by source n, then we can solve for g as illustrated in equation 3. The surface normals can then be calculated by normalizing g with its length (see equation 4). The surface elevation, z, is a function of x and y. The partial derivatives of this function with respect to x and y are shown in equation 5. Therefore, the surface elevation is given by equation 6.&lt;br /&gt;&lt;br /&gt;In this activity, we used four sources and the surface images captured by these sources are shown in Figures 1 to 4. After implementing equations 2 to 6, we were able to generate a 3D shape of the object as shown in Figure 5.&lt;br /&gt;&lt;/div&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss37mIw7eoI/AAAAAAAAAXg/zy9aXe86fr8/s1600-h/I2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss37mIw7eoI/AAAAAAAAAXg/zy9aXe86fr8/s400/I2.jpg" alt="" id="BLOGGER_PHOTO_ID_5390240961638660738" border="0" /&gt;&lt;/a&gt;Figure 1.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/Ss37lykFQOI/AAAAAAAAAXY/El-YlyxQOs0/s1600-h/I3.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/Ss37lykFQOI/AAAAAAAAAXY/El-YlyxQOs0/s400/I3.jpg" alt="" id="BLOGGER_PHOTO_ID_5390240955679195362" border="0" /&gt;&lt;/a&gt;Figure 2.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss37ldhEcjI/AAAAAAAAAXQ/6RJeXvRPYTQ/s1600-h/I4.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss37ldhEcjI/AAAAAAAAAXQ/6RJeXvRPYTQ/s400/I4.jpg" alt="" id="BLOGGER_PHOTO_ID_5390240950029414962" border="0" /&gt;&lt;/a&gt;Figure 3.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss37lF4FrhI/AAAAAAAAAXI/IhTTIPr9WZw/s1600-h/result1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 302px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss37lF4FrhI/AAAAAAAAAXI/IhTTIPr9WZw/s400/result1.bmp" alt="" id="BLOGGER_PHOTO_ID_5390240943683513874" border="0" /&gt;&lt;/a&gt;Figure 5.&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;/div&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-7364040083030007418?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/7364040083030007418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-17.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/7364040083030007418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/7364040083030007418'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-17.html' title='ACTIVITY 17 Photometric Stereo'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss37mIw7eoI/AAAAAAAAAXg/zy9aXe86fr8/s72-c/I2.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-1058307569854627872</id><published>2009-10-08T07:32:00.000-07:00</published><updated>2009-10-12T09:52:17.761-07:00</updated><title type='text'>ACTIVITY 16 Neural Networks</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;In this activity, we classify the patterns presented in Activity 14 using artificial neural networks. An advantage of this method over the algorithms reported in the previous activities is that one does not need heuristics and recognition rules to perform classification.&lt;br /&gt;&lt;br /&gt;A neural network is a computational model of the neural structure of the brain. As implied by the name, it is a network of neurons that are either sets of input values (xi) and associated weights or functions that sum the input values according to their weights and map the results to an output (y). See Figure 1 for illustration. These neurons are organized into layers as shown in Figure 2.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNZsqiGS-I/AAAAAAAAAbA/AGjqEK7Gi8U/s1600-h/diagram.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 180px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNZsqiGS-I/AAAAAAAAAbA/AGjqEK7Gi8U/s400/diagram.gif" alt="" id="BLOGGER_PHOTO_ID_5391751802759039970" border="0" /&gt;&lt;/a&gt;Figure 1.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNZsaCCudI/AAAAAAAAAa4/7eXMsg-iqhk/s1600-h/diagram+2.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 187px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNZsaCCudI/AAAAAAAAAa4/7eXMsg-iqhk/s400/diagram+2.gif" alt="" id="BLOGGER_PHOTO_ID_5391751798329620946" border="0" /&gt;&lt;/a&gt;Figure 2.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The key features of neural networks are:&lt;br /&gt;(1) the evaluation of the patterns one at a time and&lt;br /&gt;(2) the manner of learning through comparison of their classification with the known actual classification of the pattern.&lt;br /&gt;The learning process of a neural network is iterative. Moreover, the classification process is continuously modified based on the errors fed back from the previous classification stage. The modification is through the adjustment of weights associated with the input values in order to have a more accurate prediction of the class of the pattern.&lt;br /&gt;&lt;br /&gt;We are lucky enough that SciLab has a toolbox for artificial neural neutworks. We need not worry anymore of generating a code for the learning process of a neural network. All we need is initialize the necessary input parameters. A code made by Jeric Tugaff was used as a guide in understanding what the needed parameters are. Below is the discussion of the code. We also used the blog of Cole Fabros as a reference.&lt;br /&gt;&lt;br /&gt;SciLab Code:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;rand('seed',0);&lt;br /&gt;//this is to ensure that it has same starting point each time&lt;br /&gt;&lt;br /&gt;N = [a,b,c];&lt;br /&gt;//definition of network: a - number of neurons (features) in the input layer, b - number of&lt;br /&gt;hidden layers, c - number of outputs/classes to be identified&lt;br /&gt;// in this case, a = 3, b = 2 and c = 4&lt;br /&gt;&lt;br /&gt;x = [];&lt;br /&gt;x = x';&lt;br /&gt;//feature vectors of the training set (must be an m x a matrix, a - total number of patterns)&lt;br /&gt;//in this case, 20 x 3 since there are 4 classes of 5 samples each and 3 features are considered&lt;br /&gt;(see Table 1)&lt;br /&gt;//Note: If the features have very large values, these must be normalized. Otherwise, the results&lt;br /&gt;would be wrong or the neural network won't work properly.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/Ss344S0nyFI/AAAAAAAAAXA/P2QO-o8oPl4/s1600-h/FVsTRAIN.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 396px; height: 400px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/Ss344S0nyFI/AAAAAAAAAXA/P2QO-o8oPl4/s400/FVsTRAIN.png" alt="" id="BLOGGER_PHOTO_ID_5390237975041263698" border="0" /&gt;&lt;/a&gt;Table 1.&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;y = [];&lt;br /&gt;//desired output/known actual classification of the patterns (must be a c x m matrix)&lt;br /&gt;//in this case, 4 x 20 since members of the 4 classes are to be determined simultaneously&lt;br /&gt;//value is either 1 or 0, 1 if right classification and 0 if wrong classification&lt;br /&gt;//in this case, according to the order of patterns listed in Table 1, the desired output must&lt;br /&gt;be similar to the matrix shown below (1st row - members of orange class, 2nd - nagaraya,&lt;br /&gt;3rd - grapes, 4th -  eggnog).&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss344KVDVPI/AAAAAAAAAW4/JVSLqN0u-uQ/s1600-h/predicted.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 83px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss344KVDVPI/AAAAAAAAAW4/JVSLqN0u-uQ/s400/predicted.png" alt="" id="BLOGGER_PHOTO_ID_5390237972761367794" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;lp = [s,t];&lt;br /&gt;//s - learning rate; t - threshold for the error tolerated by the network&lt;br /&gt;//in this case, s is varied while t is always 0&lt;br /&gt;&lt;br /&gt;W = ann_FF_init(N);&lt;br /&gt;//initialization of weights&lt;br /&gt;&lt;br /&gt;T = r;&lt;br /&gt;//training cycles: r - number of iterations&lt;br /&gt;//in this case, r is also varied&lt;br /&gt;&lt;br /&gt;W = ann_FF_Std_online(x,y,N,W,lp,T);&lt;br /&gt;//variables are already explained above&lt;br /&gt;//adjusted weights after T iterations&lt;br /&gt;&lt;br /&gt;ann_FF_run(x,N,W)&lt;br /&gt;//testing the neural network, outputs its classification of the training patterns&lt;br /&gt;&lt;br /&gt;test = [];&lt;br /&gt;//feature vectors of the test set (must be an m1 x a matrix, m1 - total number of patterns)&lt;br /&gt;//in this case, same as training set size: 20 x 3 matrix (see Table 2)&lt;br /&gt;//Note: If the features have very large values, these must be normalized. Otherwise, the results&lt;br /&gt;would be wrong or the neural network won't work properly.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNbTohYyjI/AAAAAAAAAbI/K-UoSJZaIoI/s1600-h/FVsTEST.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 362px; height: 400px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNbTohYyjI/AAAAAAAAAbI/K-UoSJZaIoI/s400/FVsTEST.png" alt="" id="BLOGGER_PHOTO_ID_5391753571745712690" border="0" /&gt;&lt;/a&gt;Table 2.&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;class = ann_FF_run(test,N,W);&lt;br /&gt;class = round(class);&lt;br /&gt;//testing the neural network with a set of data it is not trained&lt;br /&gt;//outputs its classification of the test patterns&lt;br /&gt;// in this case, recall: 1st row - oranges, 2nd - nagaraya, 3rd - grapes, 4th - eggnog&lt;br /&gt;&lt;br /&gt;oranges = find(class(1,:) == 1)&lt;br /&gt;nagaraya = find(class(2,:) == 1)&lt;br /&gt;grapes = find(class(3,:) == 1)&lt;br /&gt;eggnog = find(class(4,:) == 1)&lt;br /&gt;//outputs the data indices of the members of the said classes &lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;First, I will disscuss the training results of the neural network. As mentioned above, the output must either be 1 or 0: 1 if the classification is right and 0 if not. But as you can notice in Table 3 and 4, the output values are not 1 or 0 but values that are near 0 and 1. This means the neural network had not learned enough to be precise in the classification of the patterns. However, the obtained values are already acceptable as classification of the patterns.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss343UzWnhI/AAAAAAAAAWw/Cp-drh1Husg/s1600-h/Lp+results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 323px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/Ss343UzWnhI/AAAAAAAAAWw/Cp-drh1Husg/s400/Lp+results.png" alt="" id="BLOGGER_PHOTO_ID_5390237958392946194" border="0" /&gt;&lt;/a&gt;Table 3. Prediction after applying neural networks. Different learning rates were tried and compared.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss3424k3vDI/AAAAAAAAAWo/y66NKjmwN-c/s1600-h/Tc+results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 303px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss3424k3vDI/AAAAAAAAAWo/y66NKjmwN-c/s400/Tc+results.png" alt="" id="BLOGGER_PHOTO_ID_5390237950816009266" border="0" /&gt;&lt;/a&gt;Table 4. Prediction after applying neural networks. Different numbers of training cycles were tried.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Before proceeding with the discussion of the training results, I want to note that the output of the code is a 4 x 20 matrix and not just 4 x 4 (size of the tables). The reason why the tables are just 4 x 4 because data of the members of one class are averaged as a summary of the results. That is the output values of the 5 patterns belonging to the classes oranges, nagaraya, grapes and eggnog are averaged.&lt;br /&gt;&lt;br /&gt;As an investigation, I varied the learning rate (s) and number of training cycles or iterations (r) to see if the output values get nearer to 1 and 0. Table 3 is the summary when the learning rate is varied while Table 4 is the summary when the number of training cycles is varied. Results show that the output values get nearer to 1 and 0 if both parameters are increased.&lt;br /&gt;&lt;br /&gt;The next thing I did is test the neural network to a set of feature vectors it is not trained. The classification of the neural network is correct, i.e., the value close to 1, if it has the same row and column label. Looking at the values in Table 5, we can say that the neural network was able to classify correctly all the patterns (100%) even the data it was not trained.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNdhoSJ26I/AAAAAAAAAbw/2fOyVqhVXJc/s1600-h/table4.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 183px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNdhoSJ26I/AAAAAAAAAbw/2fOyVqhVXJc/s400/table4.png" alt="" id="BLOGGER_PHOTO_ID_5391756011223243682" border="0" /&gt;&lt;/a&gt;Table 5.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;As another investigation, I tried disarranging the test set as illustrated in Tables 6 and 7 to test whether the neural network is dependent on the order of the patterns. Table 6 is disarranged in such a way that the eggnog and oranges were interchanged in their positions. Table 7, on the other hand, is a random arrangement of the patterns. Tables 8 and 9 are the resulting classification of the patterns for the arrangement of data in Tables 6 and 7, respectively. Results show that using the training parameters mentioned above, the neural network was still able to classify correctly all the patterns (100%). &lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNdhBEH54I/AAAAAAAAAbo/7P5AaP8En0I/s1600-h/table5.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 378px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/StNdhBEH54I/AAAAAAAAAbo/7P5AaP8En0I/s400/table5.png" alt="" id="BLOGGER_PHOTO_ID_5391756000695412610" border="0" /&gt;&lt;/a&gt;Table 6.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNdgu8iasI/AAAAAAAAAbg/6GN9bYUJ9us/s1600-h/table6.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 378px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNdgu8iasI/AAAAAAAAAbg/6GN9bYUJ9us/s400/table6.png" alt="" id="BLOGGER_PHOTO_ID_5391755995831757506" border="0" /&gt;&lt;/a&gt;Table 7.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNdgDUs1GI/AAAAAAAAAbY/1prKRid3Dp4/s1600-h/table7.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 183px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNdgDUs1GI/AAAAAAAAAbY/1prKRid3Dp4/s400/table7.png" alt="" id="BLOGGER_PHOTO_ID_5391755984121943138" border="0" /&gt;&lt;/a&gt;Table 8.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNdf4OGIFI/AAAAAAAAAbQ/BGgJfSTI4-A/s1600-h/table8.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 183px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNdf4OGIFI/AAAAAAAAAbQ/BGgJfSTI4-A/s400/table8.png" alt="" id="BLOGGER_PHOTO_ID_5391755981141450834" border="0" /&gt;&lt;/a&gt;Table 9.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Since I was able to classify correctly all the patterns and then give a nice discussion&lt;br /&gt;above (I think), I give myself a grade of 10 for this activity.&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;/div&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-1058307569854627872?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/1058307569854627872/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-16.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/1058307569854627872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/1058307569854627872'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-16.html' title='ACTIVITY 16 Neural Networks'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_EPNyhV1xE8I/StNZsqiGS-I/AAAAAAAAAbA/AGjqEK7Gi8U/s72-c/diagram.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-1997075469197459955</id><published>2009-10-07T06:59:00.000-07:00</published><updated>2009-10-12T09:17:48.704-07:00</updated><title type='text'>ACTIVITY 15 Linear Discriminant Analysis</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;For this activity, we did pattern recognition using linear discriminant analysis (LDA). The patterns I used are the images shown in the previous activity. I also used the same features and method of determining the feature values. The images were also divided into two sets: training set and test set.&lt;br /&gt;&lt;br /&gt;LDA can be used to classify patterns if the classes can be assumed to be linearly separable, i.e., classes can be separated by a linear combination of the features. Since three features of the pattern were used, the separator must be a plane.&lt;br /&gt;&lt;br /&gt;In LDA, two variables are needed:&lt;br /&gt;(1) dependent variable (y) which is the class of the pattern and&lt;br /&gt;(2) independent variable (x) which is the feature of the pattern.&lt;br /&gt;The size of y must be n x 1, where n is the total number of patterns. Moreover, x must be of size n x 3; 3 since there are three features. Same row in x and y represent one pattern. The diagram below shows the sequence of the necessary parameters needed to be calculated in LDA.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNWG8Ze73I/AAAAAAAAAaY/xSHqHYF9wPA/s1600-h/diagram.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 389px; height: 400px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNWG8Ze73I/AAAAAAAAAaY/xSHqHYF9wPA/s400/diagram.png" alt="" id="BLOGGER_PHOTO_ID_5391747856184831858" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;In evaluating f, all the variables except those with subscript T were calculated using the training set. The patterns were classified by first calculating f for all classes. It was then assigned to the class with the maximum f.&lt;br /&gt;&lt;br /&gt;Tables 1 and 3 show the feature vectors of the patterns. Table 2 and 4 are summaries of the calculated f for all classes. The column of the highlighted f (red color) is the classification of the pattern. As you can see, LDA was also able to correctly assign all the patterns to their right classes (100%).&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SsyfMPOC4OI/AAAAAAAAAWg/VWdrf1WVdFc/s1600-h/FVsTRAIN.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 396px; height: 400px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SsyfMPOC4OI/AAAAAAAAAWg/VWdrf1WVdFc/s400/FVsTRAIN.png" alt="" id="BLOGGER_PHOTO_ID_5389857886648328418" border="0" /&gt;&lt;/a&gt;Figure 1. Feature vectors (green, red, area) of the training images of oranges, nagaraya, grapes and eggnog.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/SsyfLnW7icI/AAAAAAAAAWY/wHH0sla5-LE/s1600-h/fTRAIN.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 391px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/SsyfLnW7icI/AAAAAAAAAWY/wHH0sla5-LE/s400/fTRAIN.png" alt="" id="BLOGGER_PHOTO_ID_5389857875948177858" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SsyfK9zR4xI/AAAAAAAAAWQ/YDcxNorxw2U/s1600-h/FVsTEST.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 362px; height: 400px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SsyfK9zR4xI/AAAAAAAAAWQ/YDcxNorxw2U/s400/FVsTEST.png" alt="" id="BLOGGER_PHOTO_ID_5389857864792793874" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SsyfKolawdI/AAAAAAAAAWI/V0o_-cSD1Kk/s1600-h/fTEST.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 374px; height: 400px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SsyfKolawdI/AAAAAAAAAWI/V0o_-cSD1Kk/s400/fTEST.png" alt="" id="BLOGGER_PHOTO_ID_5389857859097510354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I give myself a grade of 10 for this activity.&lt;br /&gt;&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-1997075469197459955?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/1997075469197459955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-15.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/1997075469197459955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/1997075469197459955'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-15.html' title='ACTIVITY 15 Linear Discriminant Analysis'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_EPNyhV1xE8I/StNWG8Ze73I/AAAAAAAAAaY/xSHqHYF9wPA/s72-c/diagram.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-3492110314752149090</id><published>2009-10-06T09:57:00.001-07:00</published><updated>2009-10-12T09:25:46.153-07:00</updated><title type='text'>ACTIVITY 14 Pattern Recognition</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;In the succeeding 3 activities, we generated codes that can be used in pattern recognition using different algorithms. For this activity, I discuss the results of the classification when the minimum distance algorithm is used.&lt;br /&gt;&lt;br /&gt;The patterns I used are images of oranges, nagaraya, grapes and eggnog as shown in Figures 1 to 4. The following features were determined from these patterns: redness, green-ness and area. Each pattern was represented by a feature vector, which is an ordered set of the feature values. The patterns were classified according to their class, namely, orange, nagaraya, grape and eggnog.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Sst88mxWLTI/AAAAAAAAAVQ/wlgyhu0XT54/s1600-h/Photo0006.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Sst88mxWLTI/AAAAAAAAAVQ/wlgyhu0XT54/s400/Photo0006.jpg" alt="" id="BLOGGER_PHOTO_ID_5389538759720447282" border="0" /&gt;&lt;/a&gt;Figure 1. Nagaraya Training and Testing Images.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Sst34pCJkoI/AAAAAAAAAU4/b7xK1F00PTM/s1600-h/P9015165.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Sst34pCJkoI/AAAAAAAAAU4/b7xK1F00PTM/s400/P9015165.JPG" alt="" id="BLOGGER_PHOTO_ID_5389533194050179714" border="0" /&gt;&lt;/a&gt;Figure 2. Orange Training and Testing Images.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Sst33elHZPI/AAAAAAAAAUo/SyPRKb8xmX4/s1600-h/P9015189.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Sst33elHZPI/AAAAAAAAAUo/SyPRKb8xmX4/s400/P9015189.JPG" alt="" id="BLOGGER_PHOTO_ID_5389533174064178418" border="0" /&gt;&lt;/a&gt;Figure 3. Grapes Training and Testing Images.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/Sst32_rLgWI/AAAAAAAAAUg/t09S3l59NpI/s1600-h/P9015187.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/Sst32_rLgWI/AAAAAAAAAUg/t09S3l59NpI/s400/P9015187.JPG" alt="" id="BLOGGER_PHOTO_ID_5389533165768114530" border="0" /&gt;&lt;/a&gt;Figure 4. Eggnog Training and Testing Images.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Determination of the Feature Values&lt;br /&gt;&lt;br /&gt;1. &amp;amp; 2. Redness and Green-ness&lt;br /&gt;&lt;br /&gt;First, a patch consisting of pure red, pure blue and pure green (primary colors) strips was created (see Figure 5). The patch was used in the image segmentation process. An advantage of creating a patch is there is no more need to select the portion of the pattern for the determination of the RGB values. Since it is our aim to approximate the pattern recognition capability of the humans, it is better that it is not the human who gets to decide what portion of the pattern will be considered. The code for the image segmentation (parametric, assuming Gaussian distribution) process is shown below. Since the patch used contains pure primary colors, then finding the probability that the pixels in the pattern have chromaticities r and g (p_r and p_g) is the same asdetermining how red (redness) and how green (green-ness) the pattern is. The first two rows of Figures 6 to 9 are the images of the p_r and the p_g of the patterns. As you can see, only when there is a comparable difference in the R or G values among the pixels in the image will there be a clear distinction between the pattern and the background. If there is no significant difference, then the image will just appear black at all points like the p_g of most patterns. The third row in these figures is the binarized image of the p_r*p_g of the patterns. The probabilitieswere multiplied and binarized in order to partially, if not totally, segment the pattern from its background. Finally, the redness and green-ness of the patterns were measured by getting the mean of the p_r and p_g, respectively, of the portions in the image where the binarized p_r*p_g is equal to 1 (pattern only without considering the background).&lt;br /&gt;&lt;br /&gt;SciLab Code:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;patch = imread('F:\Documents\5th year\AP186\activity 14\patch.jpg');&lt;br /&gt;&lt;br /&gt;I = patch(:,:,1) + patch(:,:,2) + patch(:,:,3);&lt;br /&gt;Pr = patch(:,:,1).*(I.^(-1));&lt;br /&gt;Pg = patch(:,:,2).*(I.^(-1));&lt;br /&gt;m_r = mean(Pr);&lt;br /&gt;m_g = mean(Pg);&lt;br /&gt;s_r = stdev(Pr);&lt;br /&gt;s_g = stdev(Pg);&lt;br /&gt;&lt;br /&gt;fname = 'F:\Documents\5th year\AP186\activity 14\orange\orange1.jpg';&lt;br /&gt;image = imread(fname);&lt;br /&gt;&lt;br /&gt;Int = image(:,:,1) +image(:,:,2) + image(:,:,3);&lt;br /&gt;Int(find(Int==0))= 100000;&lt;br /&gt;Ir = image(:,:,1).*(Int.^(-1));&lt;br /&gt;Ig = image(:,:,2).*(Int.^(-1));&lt;br /&gt;&lt;br /&gt;p_g = ((1/s_g)*(1/sqrt(2*%pi)))*exp(-((Ig - m_g).^2)/(2*(s_g^2)));&lt;br /&gt;p_g = 1-p_g;&lt;br /&gt;&lt;br /&gt;p_r = ((1/s_r)*(1/sqrt(2*%pi)))*exp(-((Ir - m_r).^2)/(2*(s_r^2)));&lt;br /&gt;p_r = 1-p_r;&lt;br /&gt;&lt;br /&gt;prod = im2bw(p_r.*p_g,0.035);&lt;br /&gt;pmG = mean(p_g(find(prod==1)));&lt;br /&gt;pmR = mean(p_r(find(prod==1)));&lt;br /&gt;area = sum(prod);&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:85%;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/Sst_3peMaxI/AAAAAAAAAV4/rfUf0c3Lrfg/s1600-h/patch.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 100px; height: 100px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/Sst_3peMaxI/AAAAAAAAAV4/rfUf0c3Lrfg/s400/patch.jpg" alt="" id="BLOGGER_PHOTO_ID_5389541973080959762" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;Figure 5. Patch consisting of the three primary colors: red, green and blue.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/Sst9co540pI/AAAAAAAAAVY/0UvaTCCCoqc/s1600-h/results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 222px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/Sst9co540pI/AAAAAAAAAVY/0UvaTCCCoqc/s400/results.png" alt="" id="BLOGGER_PHOTO_ID_5389539310048957074" border="0" /&gt;&lt;/a&gt;Figure 6. Training images of the nagaraya based on its (a) red content and (b) green content.&lt;br /&gt;(c) BW images of the nagaraya. Note: (a) - 1st row, (b) - 2nd row, (c) - 3rd row.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Sst9c-G0oSI/AAAAAAAAAVg/YfrCmzQDHkM/s1600-h/results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 238px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Sst9c-G0oSI/AAAAAAAAAVg/YfrCmzQDHkM/s400/results.png" alt="" id="BLOGGER_PHOTO_ID_5389539315740352802" border="0" /&gt;&lt;/a&gt;Figure 7. Training images of the oranges based on its (a) red content and (b) green content.&lt;br /&gt;(c) BW images of the oranges. Note: (a) - 1st row, (b) - 2nd row, (c) - 3rd row.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Sst9dSDPoPI/AAAAAAAAAVo/V9ONohVpEEI/s1600-h/results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 298px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Sst9dSDPoPI/AAAAAAAAAVo/V9ONohVpEEI/s400/results.png" alt="" id="BLOGGER_PHOTO_ID_5389539321094054130" border="0" /&gt;&lt;/a&gt;Figure 8. Training images of the grapes based on its (a) red content and (b) green content.&lt;br /&gt;&lt;div style="text-align: center;"&gt; (c) BW images of the grapes. Note: (a) - 1st row, (b) - 2nd row, (c) - 3rd row.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/Sst9eOcORDI/AAAAAAAAAVw/ygWlSsJjAtI/s1600-h/results.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 221px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/Sst9eOcORDI/AAAAAAAAAVw/ygWlSsJjAtI/s400/results.png" alt="" id="BLOGGER_PHOTO_ID_5389539337304949810" border="0" /&gt;&lt;/a&gt;Figure 9. Training images of the eggnog based on its (a) red content and (b) green content.&lt;br /&gt;&lt;div style="text-align: center;"&gt; (c) BW images of the eggnog. Note: (a) - 1st row, (b) - 2nd row, (c) - 3rd row.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;3. Area&lt;br /&gt;The area of the patterns were determined by simply getting the number (sum) of 1s in the binarized p_r*p_g (see last line of code above). Looking at the binarized images in Figures 6 to 9 (third row), you can see that there are small holes in some parts or excess regions. But since these are only few (much less than the total area), the values I got are still good approximations of the area of the patterns.&lt;br /&gt;&lt;br /&gt;After determining the feature vectors of all the patterns, I divided the images into a training set and a test set. In the training set, the average of the feature vectors of all the patterns belonging to one class were determined. Table 1 is the summary of the mean feature vectors of the different classes.It was then used in the classification of the patterns in the test set using the minimum distance algorithm, which uses the equations given below. Also shown below is the simple code implementing the said algorithm. The algorithm basically computes the distance (or difference) between the feature vector of the test pattern and the mean feature vectors in the training set. The class of the mean feature vector that gives the minimum distance is the classification of the test pattern.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNX5IYE1lI/AAAAAAAAAaw/9XfTEuX9hX0/s1600-h/eq1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 264px; height: 119px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/StNX5IYE1lI/AAAAAAAAAaw/9XfTEuX9hX0/s400/eq1.jpg" alt="" id="BLOGGER_PHOTO_ID_5391749817905239634" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNX4nfnXeI/AAAAAAAAAao/ZnDM_86nxoE/s1600-h/eq2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 56px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/StNX4nfnXeI/AAAAAAAAAao/ZnDM_86nxoE/s400/eq2.jpg" alt="" id="BLOGGER_PHOTO_ID_5391749809078492642" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNX4AVuQbI/AAAAAAAAAag/sy4pmdwJyOg/s1600-h/eq3.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 230px; height: 67px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/StNX4AVuQbI/AAAAAAAAAag/sy4pmdwJyOg/s400/eq3.jpg" alt="" id="BLOGGER_PHOTO_ID_5391749798568018354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;SciLab Code:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;for k = 1:4,&lt;br /&gt;distance(k) = sqrt((FVs(:,k) - test)'*(FVs(:,k) - test));&lt;br /&gt;end;&lt;br /&gt;classification = find(distance == min(distance));&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Table 1. Feature vectors of the objects as determined from the training images.&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Sst_4KtvSPI/AAAAAAAAAWA/vSSdJKAT5Zs/s1600-h/FVs.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 154px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Sst_4KtvSPI/AAAAAAAAAWA/vSSdJKAT5Zs/s400/FVs.png" alt="" id="BLOGGER_PHOTO_ID_5389541982004529394" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The output of the code (classification of all the test patterns) is not presented anymore since it was just a matrix of numbers 1, 2, 3 and 4 corresponding to the four classes (oranges, nagaraya, grapes and eggnog). But I was able to classify correctly all the test patterns, and even the training patterns (100%). This means the features I chose are good separators or distinctions of the four classes.&lt;br /&gt;&lt;br /&gt;I give myself a grade of 10 for this acitivity.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-3492110314752149090?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/3492110314752149090/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-14.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/3492110314752149090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/3492110314752149090'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-14.html' title='ACTIVITY 14 Pattern Recognition'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_EPNyhV1xE8I/Sst88mxWLTI/AAAAAAAAAVQ/wlgyhu0XT54/s72-c/Photo0006.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-6446151841714589808</id><published>2009-10-06T09:27:00.001-07:00</published><updated>2009-10-08T11:54:13.300-07:00</updated><title type='text'>ACTIVITY 13 Correcting Geometric Distortions</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: justify;"&gt;In this activity, we generated a SciLab code that can be used to correct distortions, specifically geometric distortions, in an image. These distortions are usually due to the manner the sensor in a capturing device detects light. Any straight line in the object space is perceived by a sensor as a curved line. The two common observable distortions are the barrel distortion and pincushion distortion. Barrel distortion happens when the edges of the image seem to be bent outwards. The image is bulging but smaller than the undistorted image.  On the other hand, pincushion distortion occurs when the edges of the image seem to be bent inwards. The boundaries are expanded, so the image is bigger than the undistorted image. However, even with the distortions, the center of the image usually remains undistorted. See Figure 1 for the illustrations of the aforementioned distortions.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss4OuzhuDjI/AAAAAAAAAYo/EUXg-SwzUmQ/s1600-h/distortion.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 217px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss4OuzhuDjI/AAAAAAAAAYo/EUXg-SwzUmQ/s400/distortion.gif" alt="" id="BLOGGER_PHOTO_ID_5390262001277472306" border="0" /&gt;&lt;/a&gt;Figure 1. Left: undistorted; center: with barrel distortion; right: with pincushion distortion.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;(Source: http://toothwalker.org/optics/distortion.html)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In generating the code, a checkerboard image with barrel distortion is used as the sample image as shown in Figures 2 and 3. The correction of the image was done on the two image properties, pixel coordinates and graylevel values. The pixel coordinates were corrected by finding the transformation function for mapping the pixel coordinates in the distorted image to the undistorted image. Moreover, the graylevel values were corrected using bilinear interpolation. A detailed discussion of the correction process can be found below.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;img src="file:///C:/Users/Winsome/AppData/Local/Temp/moz-screenshot-5.jpg" alt="" /&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src="file:///C:/Users/Winsome/AppData/Local/Temp/moz-screenshot-6.jpg" alt="" /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SstxAYCvzuI/AAAAAAAAATo/sIXEgE_Pj9w/s1600-h/sol7smile.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 358px; height: 245px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SstxAYCvzuI/AAAAAAAAATo/sIXEgE_Pj9w/s400/sol7smile.png" alt="" id="BLOGGER_PHOTO_ID_5389525630346841826" border="0" /&gt;&lt;/a&gt;Figure 2. Original Image&lt;br /&gt;&lt;span style="font-size:85%;"&gt;(Source: http://immersaview.com/images/sol7smile.png)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SstxBpcBWWI/AAAAAAAAAUA/AsNFIDc_08Q/s1600-h/distorted.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 316px; height: 215px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SstxBpcBWWI/AAAAAAAAAUA/AsNFIDc_08Q/s400/distorted.jpg" alt="" id="BLOGGER_PHOTO_ID_5389525652196120930" border="0" /&gt;&lt;/a&gt;Figure 3. The cropped portion of the image that was restored to its undistorted form.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Before correcting the image, it is important to have the correct pixel coordinates. In the sample image (checkerboard), these pixel coordinates correspond to the corners of the rectangles. For images with nonperiodic objects/structures, gridlines need to be created in the image, as well as in the reference (undistorted) image, such as those shown in Figure 4. The pixel coordinates will be the intersections of the gridlines.&lt;br /&gt;&lt;br /&gt;The pixel coordinates in the sample image were determined after isolating the corner points of each of the white rectangles in the checkerboard. Several image processing techniques were applied on the binarized image to isolate all the corner points. First, the image was reduced to only the structure of the checkerboard being shown by perfoming edge detection using the imcorrcoef() function in Scilab. Then, the image was dilated with a square to make the lines thicker. After which, the image is eroded with a cross so that only the intersections/corners would remain. A series of erosion of the image with different sizes of rectangles (depending on the size of the corners left with the previous erosion with a cross) was then performed. The goal was that only single corner points must remain. The code below ensured that only one point in every corner after every erosion was left.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;[image,n] = bwlabel(image);&lt;br /&gt;for i=1:n,&lt;br /&gt;f = find(image1==i);&lt;br /&gt;reg_size = size(f,'*');&lt;br /&gt;if reg_size &gt; 1,&lt;br /&gt;image1(f) = 0;&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;image = (image&gt;0)*1;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;However, the generated code for determining the pixel coordinates in the distorted images does not work for most images. It would only work for perfect checkerboard images. Another way to determine the pixel coordinates would be to locate the desired points in the image. This is the easiest method but requires so much time and must be accurate in locating the points. Figure 5 shows the isolated single corner points using the generated code. It must be noted that the x coordinate is the column number while the y coordinate is the row number. The said convention was carefully followed throughout the code to avoid errors.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Sstx8Xyj0tI/AAAAAAAAAUI/slcnPcYg88Y/s1600-h/coord_distorted.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 358px; height: 245px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Sstx8Xyj0tI/AAAAAAAAAUI/slcnPcYg88Y/s400/coord_distorted.jpg" alt="" id="BLOGGER_PHOTO_ID_5389526661071098578" border="0" /&gt;&lt;/a&gt;Figure 5. Corners of the white/black rectangles determined after image segmentation.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The next pixel coordinates determined were of the undistorted or the ideal checkerboard. The data needed were the following: height and width of the undistorted (central) rectangle, lowest x and y coordinates. The undistorted pixel coordinates were determined by first creating a matrix of the same size as the image. Then starting from the lowest x and y coordinates, the  other coordinates were determined by generating the set of points with a column interval equal to the width and a row interval equal to the height. Figure 6 shows the image of the ideal points, which was created by assigning a value of 1  in the determined ideal pixel coordinates of the zero matrix. The ideal checkerboard was then created from these points as shown in Figure 7.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SstyI6C1w9I/AAAAAAAAAUY/RoGTGAtIDhc/s1600-h/idealdots.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 358px; height: 245px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SstyI6C1w9I/AAAAAAAAAUY/RoGTGAtIDhc/s400/idealdots.jpg" alt="" id="BLOGGER_PHOTO_ID_5389526876424618962" border="0" /&gt;&lt;/a&gt;Figure 6. Corners of the ideal (undistorted) rectangles with the same height and width as the central rectangles (not distorted) of the image .&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SstxBEQEnfI/AAAAAAAAAT4/nH8kYHo-JRo/s1600-h/idealgrid.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 358px; height: 245px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SstxBEQEnfI/AAAAAAAAAT4/nH8kYHo-JRo/s400/idealgrid.jpg" alt="" id="BLOGGER_PHOTO_ID_5389525642213891570" border="0" /&gt;&lt;/a&gt;Figure 7. Ideal checkerboard  when there are no distortions at the edges.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;After determining the pixel coordinates in the distorted image and the ideal checkerboard, we proceeded to determining the transformation function which was used in mapping the pixel coordinates in the distorted image to the ideal checkerboard (see Figure 8). Equations 1 to 6 are the important equations describing the mapping process. As described in equation 6, coefficients C1 to C8 need to be determined first by using uquation 5. However, the first four equations require the grouping of the corner points into 4 corresponding to one rectangle. Once the pixel coordinates have been grouped into 4, the determination of the coefficients is much easier as illustrated in the code below after the equations. With the coefficients already known, the corresponding undistorted pixel coordinates were determined using equation 6. Note that it must done for all points/pixel coordinates in the distorted image and not only the corner points. The set of coefficients to be used depends on what corner points surround the distorted pixel coordinates to be mapped.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss4m2SRn-5I/AAAAAAAAAYw/9Xy-JYZU5V8/s1600-h/diagram.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 169px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss4m2SRn-5I/AAAAAAAAAYw/9Xy-JYZU5V8/s400/diagram.jpg" alt="" id="BLOGGER_PHOTO_ID_5390288518069615506" border="0" /&gt;&lt;/a&gt;Figure 8.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss4o871xhQI/AAAAAAAAAZg/dTdOvN9KjQg/s1600-h/eq1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 208px; height: 113px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss4o871xhQI/AAAAAAAAAZg/dTdOvN9KjQg/s400/eq1.jpg" alt="" id="BLOGGER_PHOTO_ID_5390290831329559810" border="0" /&gt;&lt;/a&gt;Equation 1. r and s are the transformation functions for x and y coordinates, respectively.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss4owzNNv2I/AAAAAAAAAZY/mtMj7_fdR-k/s1600-h/eq2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 110px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss4owzNNv2I/AAAAAAAAAZY/mtMj7_fdR-k/s400/eq2.jpg" alt="" id="BLOGGER_PHOTO_ID_5390290622853529442" border="0" /&gt;&lt;/a&gt;Equation 2. Expression of the r and s transformation functions.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss4owhW6xPI/AAAAAAAAAZQ/oZgvDY0fbQE/s1600-h/eq3.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 339px; height: 400px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss4owhW6xPI/AAAAAAAAAZQ/oZgvDY0fbQE/s400/eq3.jpg" alt="" id="BLOGGER_PHOTO_ID_5390290618062390514" border="0" /&gt;&lt;/a&gt;Equation 3.  Matrix equations mapping undistorted to distorted pixel coordinates.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/Ss4owFFHYWI/AAAAAAAAAZI/mRm2XVdCO9M/s1600-h/eq4.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 49px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/Ss4owFFHYWI/AAAAAAAAAZI/mRm2XVdCO9M/s400/eq4.jpg" alt="" id="BLOGGER_PHOTO_ID_5390290610471526754" border="0" /&gt;&lt;/a&gt;Equation 4. Compact form of equation 3.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss4ovzJm1KI/AAAAAAAAAZA/PKwk9EHB0v8/s1600-h/eq5.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 59px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss4ovzJm1KI/AAAAAAAAAZA/PKwk9EHB0v8/s400/eq5.jpg" alt="" id="BLOGGER_PHOTO_ID_5390290605658526882" border="0" /&gt;&lt;/a&gt;Equation 5. Solution for determining the coefficients C1 to c8.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss4ovft7-3I/AAAAAAAAAY4/6njwFKDPJCo/s1600-h/eq6.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 396px; height: 100px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Ss4ovft7-3I/AAAAAAAAAY4/6njwFKDPJCo/s400/eq6.jpg" alt="" id="BLOGGER_PHOTO_ID_5390290600442198898" border="0" /&gt;&lt;/a&gt;Equation 6. Reverse of equation 3: mapping of distorted to undistorted pixel coordinates.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-size:85%;"&gt;for i = 1:196,&lt;br /&gt; xC = cornerDx(i,:);&lt;br /&gt; yC = cornerDy(i,:);&lt;br /&gt; xT = cornerUNDx(i,:);&lt;br /&gt; yT = cornerUNDy(i,:);&lt;br /&gt; T = [xT(1) yT(1) xT(1)*yT(1) 1; xT(2) yT(2) xT(2)*yT(2) 1; xT(3) yT(3) xT(3)*yT(3) 1; xT(4) yT(4) xT(4)*yT(4) 1];&lt;br /&gt; T = inv(T);&lt;br /&gt; cx(i,1:4) = (T * xC')';&lt;br /&gt; cy(i,1:4) = (T * yC')';&lt;br /&gt;end;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The next step was to determine the graylevel values of the mapped undistorted pixel coordinates. If the obtained pixel coordinates were integers, the value at that location in the distorted image was its value. However, if the obtained pixel coordinates were non-integers,  bilinear interpolation was implemented (see equation 7). Just like in finding the transformation functions, the coefficients a, b, c and d need to be determined first. Similar equations as equations 3 to 5 were used in determining the values of  this constants. For the 4 points needed, its four neighboring points were used. Below is the code used to map the distorted points to the ideal points and calculate its graylevel value.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss4wShRX5cI/AAAAAAAAAZo/6CkXbiArj3c/s1600-h/eq7.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 58px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss4wShRX5cI/AAAAAAAAAZo/6CkXbiArj3c/s400/eq7.jpg" alt="" id="BLOGGER_PHOTO_ID_5390298898736080322" border="0" /&gt;&lt;/a&gt;Equation 7. Bilinear interpolation&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-size:85%;"&gt;imagenew = zeros(s(1),s(2));&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:85%;"&gt;for i = 1:196,&lt;br /&gt;  for y = min(cornerUNDy(i,:)):max(cornerUNDy(i,:)),&lt;br /&gt;    for x = min(cornerUNDx(i,:)):max(cornerUNDx(i,:)),&lt;br /&gt;      xnew = sum(CoeffX(i,:) .* [x y x*y 1]);&lt;br /&gt;      ynew = sum(CoeffY(i,:) .* [x y x*y 1]);&lt;br /&gt;      if xnew/floor(xnew) &gt; 1 | ynew/floor(ynew) &gt; 1,&lt;br /&gt;        xnew1 = floor(xnew);&lt;br /&gt;        ynew1 = floor(ynew);&lt;br /&gt;        neighy = [xnew1 xnew1+1];&lt;br /&gt;        neighx = [ynew1 ynew1+1];&lt;br /&gt;        dy = xnew - xnew1;&lt;br /&gt;        dx = ynew - ynew1;&lt;br /&gt;        vnew = dx*dy*image(neighy(1),neighx(1)) + (1-dx)*dy*image(neighy(1),neighx(2)) + (1-dx)*(1-dy)*image(neighy(2),neighx(2)) + dx*(1-dy)*image(neighy(2),neighx(1));&lt;br /&gt;        imagenew(y,x) = vnew;&lt;br /&gt;      else;&lt;br /&gt;        vnew = image(xnew,ynew);&lt;br /&gt;        imagenew(y,x) = vnew;&lt;br /&gt;      end;&lt;br /&gt;    end;&lt;br /&gt;  end;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-size:85%;"&gt;end;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SstxAw7cOKI/AAAAAAAAATw/prJJTILLC08/s1600-h/image_reconsBW.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 358px; height: 245px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SstxAw7cOKI/AAAAAAAAATw/prJJTILLC08/s400/image_reconsBW.jpg" alt="" id="BLOGGER_PHOTO_ID_5389525637027084450" border="0" /&gt;&lt;/a&gt;Figure 8. Restored image with no distortions at the edges anymore.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Figure 8 shows the corrected image, in which there are no more distortions. It can be observed that the boundaries/edges of the rectangles are somewhat blurry or not defined. But if you zoom the original distorted image in Figure 3, you can see that the edges are not defined also. So, it just makes sense why the corrected image looks like that.&lt;br /&gt;&lt;br /&gt;I would myself a grade of 10 for this activity since I was able to correct the distorted image.&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-6446151841714589808?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/6446151841714589808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-13.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/6446151841714589808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/6446151841714589808'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/10/activity-13.html' title='ACTIVITY 13 Correcting Geometric Distortions'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_EPNyhV1xE8I/Ss4OuzhuDjI/AAAAAAAAAYo/EUXg-SwzUmQ/s72-c/distortion.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-3517792068273538932</id><published>2009-08-06T04:41:00.001-07:00</published><updated>2009-08-07T00:46:06.666-07:00</updated><title type='text'>ACTIVITY 12 Color Image Segmentation</title><content type='html'>&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;In previous activities, the segmentation of the ROI from the background was done by binarization of the grayscale image. However, if the the grayscale image is similar to that shown below, it would be hard choose a threshold value which can properly separate the ROI from the background. Thus, new techniques of segmentation are introduced in this activity: parametric and nonparametric. There is no need to convert the truecolor image into a grayscale image. The histogram of the RGB values will be used to separate the ROI from the background.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SntE5oUxPHI/AAAAAAAAASY/8UNwbPPE_EQ/s1600-h/image.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 386px; height: 257px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SntE5oUxPHI/AAAAAAAAASY/8UNwbPPE_EQ/s400/image.jpg" alt="" id="BLOGGER_PHOTO_ID_5366959137809841266" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Before proceeding with the segmentation process, the variation in the brightness level of the 3D objects were dealt with first. Brightness information can be disregarded if the RGB values are normalized to the intensity values at each point. That is, the RGB values at a point are divided by the sum of the of the RGB values at that point. This color space, which contains  only chromaticity/color information, is called the normalized chromaticity coordinates or NCC. Figure 1 shows the NCC where the &lt;span style="font-style: italic;"&gt;x&lt;/span&gt;-axis is &lt;span style="font-style: italic;"&gt;r&lt;/span&gt; and the &lt;span style="font-style: italic;"&gt;y&lt;/span&gt;-axis is &lt;span style="font-style: italic;"&gt;g&lt;/span&gt;. &lt;span style="font-style: italic;"&gt;b&lt;/span&gt; need not be shown here because its value can already be derived from &lt;span style="font-style: italic;"&gt;r&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;g&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SnrGKwc7EoI/AAAAAAAAARg/jGU9BfsUh7k/s1600-h/Untitled.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 267px; height: 240px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SnrGKwc7EoI/AAAAAAAAARg/jGU9BfsUh7k/s400/Untitled.jpg" alt="" id="BLOGGER_PHOTO_ID_5366819794072572546" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Parametric segmentation is done by assuming that the probability distribution function (PDF) of the image is a Gaussian distribution independent along &lt;span style="font-style: italic;"&gt;r&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;g&lt;/span&gt;. The Gaussian PDF equations, form shown in the manual, for &lt;span style="font-style: italic;"&gt;r&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;g&lt;/span&gt; are established by getting the mean, standard deviation and variance of the &lt;span style="font-style: italic;"&gt;rg&lt;/span&gt; values of the ROI, which must be a monochromatic patch. The probability values along &lt;span style="font-style: italic;"&gt;r&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;g&lt;/span&gt; are then multiplied and the product is already the correlation between the color information of the points in the image and the ROI. The process of segmentation is done by determining the probability that the &lt;span style="font-style: italic;"&gt;rg&lt;/span&gt; values at points in the image belong to  the color distribution of the ROI. This means  the portion in the image that has the same color as the ROI, or high probability, will appear as bright spots in the resulting segmented image.&lt;br /&gt;&lt;br /&gt;In nonparametric segmentation, no form of PDF is assumed  and the 2D histogram of the binned&lt;span style="font-style: italic;"&gt; rg&lt;/span&gt; values is used. The histogram is a &lt;span style="font-style: italic;"&gt;N &lt;/span&gt;x &lt;span style="font-style: italic;"&gt;N&lt;/span&gt; matrix where &lt;span style="font-style: italic;"&gt;N&lt;/span&gt; is the number of bins. A sample code of creating a 2D histogram is shown in the manual. The process of segmentation is done by histogram backprojection. That is the pixel locations are assigned with new values depending on the &lt;span style="font-style: italic;"&gt;r&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;g&lt;/span&gt; values. The new value is the value in the 2D histogram of the (r*N, g*N) location. Bright spots correspond to the portions of the image with the same color information as the ROI.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SnrB_QGtFVI/AAAAAAAAARY/Y8C4bnEYl-g/s1600-h/apple.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 105px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SnrB_QGtFVI/AAAAAAAAARY/Y8C4bnEYl-g/s400/apple.png" alt="" id="BLOGGER_PHOTO_ID_5366815198364374354" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnrB-JbBVXI/AAAAAAAAARQ/bhx6QrOKdRI/s1600-h/green+apple.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 97px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnrB-JbBVXI/AAAAAAAAARQ/bhx6QrOKdRI/s400/green+apple.png" alt="" id="BLOGGER_PHOTO_ID_5366815179390670194" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/SnrB9oIdmvI/AAAAAAAAARI/pUMDLIn9oW0/s1600-h/mango.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 75px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/SnrB9oIdmvI/AAAAAAAAARI/pUMDLIn9oW0/s400/mango.png" alt="" id="BLOGGER_PHOTO_ID_5366815170454461170" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SnrB9OfSD8I/AAAAAAAAARA/LwVco9J1tW0/s1600-h/orange.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 97px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SnrB9OfSD8I/AAAAAAAAARA/LwVco9J1tW0/s400/orange.png" alt="" id="BLOGGER_PHOTO_ID_5366815163570851778" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SnrB8ojg_WI/AAAAAAAAAQ4/2Y-LzoFNTuw/s1600-h/p.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 85px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SnrB8ojg_WI/AAAAAAAAAQ4/2Y-LzoFNTuw/s400/p.png" alt="" id="BLOGGER_PHOTO_ID_5366815153388060002" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/SntCHwgjSdI/AAAAAAAAASQ/sqrBPEEvnak/s1600-h/green.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 86px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/SntCHwgjSdI/AAAAAAAAASQ/sqrBPEEvnak/s400/green.png" alt="" id="BLOGGER_PHOTO_ID_5366956081990027730" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/SntCHdylTdI/AAAAAAAAASI/zImk349W-So/s1600-h/orange+1.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 83px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/SntCHdylTdI/AAAAAAAAASI/zImk349W-So/s400/orange+1.png" alt="" id="BLOGGER_PHOTO_ID_5366956076965383634" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/SntCG66XT_I/AAAAAAAAASA/Dp7r-atfd_Q/s1600-h/grape.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 82px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/SntCG66XT_I/AAAAAAAAASA/Dp7r-atfd_Q/s400/grape.png" alt="" id="BLOGGER_PHOTO_ID_5366956067602780146" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SntCGZl0oqI/AAAAAAAAAR4/DlnP59PLg8w/s1600-h/banana.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 86px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SntCGZl0oqI/AAAAAAAAAR4/DlnP59PLg8w/s400/banana.png" alt="" id="BLOGGER_PHOTO_ID_5366956058658251426" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SntCGKI34GI/AAAAAAAAARw/auiR-JiOiQA/s1600-h/appletree.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 75px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SntCGKI34GI/AAAAAAAAARw/auiR-JiOiQA/s400/appletree.png" alt="" id="BLOGGER_PHOTO_ID_5366956054510297186" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Figure 1. Resulting images after nonparametric and parametric segmentation of the patches of the sample images (third and last column). The patches are the small images just above the sample images. The second column consists of the 2D histogram of the patches.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Figure 1 shows several examples of nonparametric and parametric segmentation (third and last columns, respectively). The first four images illustrate how the segmentation process can also be used to highlight only the portions in a monochromatic object that have the same shade as the patch. The variation in the color of a 3D object is also evident in these results. The fifth image is a clear proof that the techniques used can properly segment the ROI  from  the  background without having to convert the image into grayscale. The succeeding images segment the fruits in the image having the same color as the patch. The colors may not be exactly the same. As long as the fruit has &lt;span style="font-style: italic;"&gt;r&lt;/span&gt; or/and &lt;span style="font-style: italic;"&gt;g&lt;/span&gt; values, which are more or less the same as that in the patch, that fruit will be highlighted in the segmented image. The correlation in the in the&lt;span style="font-style: italic;"&gt; r&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;g&lt;/span&gt;  values of the image and the patch is illustrated in the variation of brightness of the highlighted spots. The nearer the color of the fruit to the color of the patch, the brighter the highlighted spots will be.&lt;br /&gt;&lt;br /&gt;The created 2D histograms were checked by comparing the bright portions in the histogram with the NCC plot above. It can be seen that the bright portions are located at the same position as the location in the NCC plot of the color of the patch.&lt;br /&gt;&lt;br /&gt;Comparing the results of parametric and nonparametric segmentation, it can be seen that the former is a better technique of highlighting portions that have color more or less the same as the patch. The trace of the fruits in the segmented image is more solid when the former technique is used as compared to when the latter technique is used. This is probably because  the Gaussian distribution generates higher probability than when using the 2D histogram of the patch. However, it must be noted that the number of bins used for the parametric segmentation above is 256. This means the colors/shades of colors are highly separated, and so fewer portions in the image will be detected having the same color as the patch. This explains why in the results above the parametric method has darker and fewer highlighted spots than the parametric method. Figure 2 shows the different results when different number of bins is used.  It can be seen that more fruits are highlighted when the bin is just 10. The trace is even more solid than the trace using parametric method. This is because with smaller bins, more colors of the same shade are grouped. From the results below, it can be seen that using 100 bins gives us the best result for highlighting only the fruits that have exactly the same color as the patch.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnuoR0BZiPI/AAAAAAAAASo/zZoSjkLSlTA/s1600-h/bins.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 200px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnuoR0BZiPI/AAAAAAAAASo/zZoSjkLSlTA/s400/bins.png" alt="" id="BLOGGER_PHOTO_ID_5367068404917831922" border="0" /&gt;&lt;/a&gt;Figure 2. Parametric segmentation of the banana and grape patches using different bins (10, 100, 256).&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I would like to thank Thirdy, Master and all other who have helped me understand what has to be done for this activity. I would give myself a grade of 10 for a job well done (according to me).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;References:&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;1. Orange image: http://msp256.photobucket.com/albums/hh194/yehitsroger/orange.jpg&lt;br /&gt;2. Mango: http://carinderia.net/blog/wp-content/uploads/2008/12/mango13.jpg&lt;br /&gt;3. Green Apple: http://2.bp.blogspot.com/_wxeBei5m--0/SeaZnk8DBfI/AAAAAAAAARE/uci2eKrBTtU/s400/apple_green_fruit_240421_l.jpg&lt;br /&gt;4. Red Apple: http://www.ableweb.org/news/winter2009/images/fruitApple1c4.jpg&lt;br /&gt;5. Fruits: http://files.myopera.com/buksiy/albums/739313/Fruits.jpg&lt;br /&gt;6. Apple Tree: http://www.kevinecotter.com/appletree.jpg&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-3517792068273538932?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/3517792068273538932/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/08/activity-12-color-image-segmentation.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/3517792068273538932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/3517792068273538932'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/08/activity-12-color-image-segmentation.html' title='ACTIVITY 12 Color Image Segmentation'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_EPNyhV1xE8I/SntE5oUxPHI/AAAAAAAAASY/8UNwbPPE_EQ/s72-c/image.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-6665036966850707037</id><published>2009-08-05T18:27:00.000-07:00</published><updated>2009-08-10T19:46:48.347-07:00</updated><title type='text'>ACTIVITY 11 Color Camera Processing</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;The main goal for this activity is to balance unbalanced images using white patch (WP) and gray world (GW) algorithms. The image is unbalanced if the portions that are supposed to be white do not appear white. Just like the images in Figure 1, the supposedly white portions appear bluish. This means the images are captured using a WB setting not appropriate for the lighting conditions of the room/surroundings.&lt;br /&gt;&lt;br /&gt;White patch algorithm divides all RGB values with the RGB values of the supposedly white portions. In doing so, these portions are forced to have a value of 1 producing a true white color. In this case, the bluish color can be thought of as an offset of the white color. Forcing the bluish color to be white allows the rest of the colors to be rendered correctly with respect to the white color. The balanced images using WP algorithm appear darker in Figure 1 (second column) because a constant (&lt; style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/Snox9I8Gj3I/AAAAAAAAAQg/g9tx_JN1uFE/s1600-h/unbalanced.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/Snox9I8Gj3I/AAAAAAAAAQg/g9tx_JN1uFE/s400/unbalanced.png" alt="" id="BLOGGER_PHOTO_ID_5366656832406720370" border="0" /&gt;&lt;/a&gt;&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;Figure 1. White balancing of unbalanced images. First column: unbalanced images; second column: using white patch algorithm; third column: using gray world algorithm.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Snox96Ye2wI/AAAAAAAAAQo/gP4zn9BSbls/s1600-h/balanced.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Snox96Ye2wI/AAAAAAAAAQo/gP4zn9BSbls/s400/balanced.png" alt="" id="BLOGGER_PHOTO_ID_5366656845679090434" border="0" /&gt;&lt;/a&gt;Figure 2. White balancing of unbalanced images. First column: unbalanced images; second column: using white patch algorithm; third column: using gray world algorithm.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Figure 3 below shows the balancing of an image containing only a single hue. The resulting images show that WP algorithm produces better results than GW algorithm. Unlike in the multicolor images (Figures 1 and 2), the single hue introduces a bias in the balancing of the image. The yellowish color in the balanced image of GW algorithm is due to the bias in the red color since the mean of the whole image (mostly red) is used and not just of the white portion.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SoDa_oEWIdI/AAAAAAAAATg/jiHAJm5MEYc/s1600-h/P7305030_patch.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 384px; height: 288px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SoDa_oEWIdI/AAAAAAAAATg/jiHAJm5MEYc/s400/P7305030_patch.jpg" alt="" id="BLOGGER_PHOTO_ID_5368531542447890898" border="0" /&gt;&lt;/a&gt;Figure 3. The white portion inside the black circle is the white patch used.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/Snox-fVuXrI/AAAAAAAAAQw/eiJGjQTMB58/s1600-h/sh.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 100px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/Snox-fVuXrI/AAAAAAAAAQw/eiJGjQTMB58/s400/sh.png" alt="" id="BLOGGER_PHOTO_ID_5366656855599636146" border="0" /&gt;&lt;/a&gt;Figure 4. White balancing of an unbalanced image with single hue. First column: unbalanced images; second column: using gray world algorithm; third column: using white patch algorithm.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;For this activity, I would give myself a grade of 10 because I was able to balance the images using both algorithms and explain the results I got. Thank you to Thirdy and all those who lent me their things for the photoshoot.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-6665036966850707037?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/6665036966850707037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/08/activity-11-color-camera-processing.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/6665036966850707037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/6665036966850707037'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/08/activity-11-color-camera-processing.html' title='ACTIVITY 11 Color Camera Processing'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_EPNyhV1xE8I/Snox9I8Gj3I/AAAAAAAAAQg/g9tx_JN1uFE/s72-c/unbalanced.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-1543175783750978670</id><published>2009-08-05T18:23:00.000-07:00</published><updated>2009-08-07T12:35:20.175-07:00</updated><title type='text'>ACTIVITY 10 Preprocessing Text</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;  The available image is titled, so it has to be rotated first using the&lt;span style="font-size:14;"&gt; &lt;/span&gt;&lt;b style=""&gt;&lt;span style="font-size:11;"&gt;mogrify()&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size:14;"&gt; &lt;/span&gt;function in SciLab. Figure 1 shows an example of a cropped image and the resulting image after rotating it by 1.21 degrees. A disadvantage of rotating the image is the resulting image has lower resolution or blurry.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="display: block;" id="formatbar_Buttons"&gt;&lt;span class="on" style="display: block;" id="formatbar_JustifyFull" title="Justify Full" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 13);ButtonMouseDown(this);"&gt;&lt;img src="http://www.blogger.com/img/blank.gif" alt="Justify Full" class="gl_align_full" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnxRfUIubfI/AAAAAAAAATI/kwYRzcbGQvE/s1600-h/mogrify.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 79px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnxRfUIubfI/AAAAAAAAATI/kwYRzcbGQvE/s400/mogrify.png" alt="" id="BLOGGER_PHOTO_ID_5367254454341889522" border="0" /&gt;&lt;/a&gt;Figure 1. Rotation of the image.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;  &lt;p class="MsoNormal"&gt;Figure 2 shows the resulting images after applying a technique on the original image or the processed image. The first image is the inverted image of the original image (black becomes white and vice versa). Inversion of the image makes the choosing of the threshold value in the binarization of the image much easier. To remove the horizontal line between the texts ‘DEMO III’ and ‘Position’, a filter mask (vertical line with a hole at the center) was multiplied to the Fourier transform of the image. This technique is simply linear filtering in the Fourier/frequency domain. The resulting image is already clean, i.e., texts well separated from the background, so no further processing needs to be done. To make the texts one-pixel thick, the &lt;b style=""&gt;thin() &lt;/b&gt;function is applied to the image. Looking at the results, it can be observed that the characters in the word 'Position' are not highly resolved probably because the the spacing is too small that they seem to be connected. The failure to extract the letters in their complete form is due to the uneven brightness of the lines forming the letters. Making the texts one-pixel thick worsens their reconstruction. This is because of our failure to extract the letters completely, as well as clearly separate from each other.&lt;/p&gt;  &lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SnxQphDOJeI/AAAAAAAAATA/OOqG3dD2qEU/s1600-h/demo.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 170px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SnxQphDOJeI/AAAAAAAAATA/OOqG3dD2qEU/s400/demo.png" alt="" id="BLOGGER_PHOTO_ID_5367253530095527394" border="0" /&gt;&lt;/a&gt;Figure 2. Processing of the 'DEMO III, POSITION' text in the image.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The next figure demonstrates the processing of plain handwritten texts in a cropped image of the form. Again, the image is inverted first and then the horizontal lines are removed by linear filtering in the Fourier domain using the same filter mask. Since the binarized image is not yet that clean, it is further processed by applying the morphological operation opening on the binarized image. The texts are then made one-pixel thick. The reconstruction is still not good especially in the one-pixel thick texts. It is not possible to discern what these letters are using the results of our reconstruction.  This is mainly because  of the  indecipherable handwriting of the person writing these texts. Acually, the reconstruction is good if we just look at the original image and not considering that these are supposed to be letters. If we think of the texts as just lines or curves, then we can say that the reconstruction is good. To illustrate how the labeling of the letters could have been done fo perfectly reconstructed texts, Figure 4 is shown below.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnxP-W4mmSI/AAAAAAAAAS4/HDOF5gWfpoU/s1600-h/handwritten.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 187px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnxP-W4mmSI/AAAAAAAAAS4/HDOF5gWfpoU/s400/handwritten.png" alt="" id="BLOGGER_PHOTO_ID_5367252788632262946" border="0" /&gt;&lt;/a&gt;Figure 3. Processing of the handwritten texts in the image.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SnxP9tI4fRI/AAAAAAAAASw/XnbMNDHUfng/s1600-h/labeled.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 140px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SnxP9tI4fRI/AAAAAAAAASw/XnbMNDHUfng/s400/labeled.png" alt="" id="BLOGGER_PHOTO_ID_5367252777426255122" border="0" /&gt;&lt;/a&gt;Figure 4. Labeling of the texts.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;For this part of the activity, we  counted the number of times the word 'DESCRIPTION' appeared in the image. We did it by using the correlation function we have learned in activity 5. The technique to have a good correlation when the word appears is to binarize the image and the template using the same threshold value. The word in the template must also be located at the center to be able to project the correct location of the words in the image of correlation values. Since there are three 'DESCRIPTIONs' in the image, there appear three very bright small dots in the image of the correlation values. Figures 5 and 6 show the location of the words in the image and the location of the bright spots in the image of correlated values, respectively.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SnxfDs2Y8sI/AAAAAAAAATY/nenUtnNoanE/s1600-h/description_image.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 249px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SnxfDs2Y8sI/AAAAAAAAATY/nenUtnNoanE/s400/description_image.png" alt="" id="BLOGGER_PHOTO_ID_5367269373102322370" border="0" /&gt;&lt;/a&gt;Figure 5. Encircled 'DESCRIPTION' in the image.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SnxfC4RPw1I/AAAAAAAAATQ/_h99gQTpEBI/s1600-h/matched.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 249px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SnxfC4RPw1I/AAAAAAAAATQ/_h99gQTpEBI/s400/matched.png" alt="" id="BLOGGER_PHOTO_ID_5367269358987887442" border="0" /&gt;&lt;/a&gt;Figure 6. Instances of the word 'DESCRIPTION' in the image.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I would like to thank Thirdy, Mandy, Jaze, Gilbert, Rommel, Alva and all others who have helped me understand this activity. I would give myself a grade of 10 because I was able to generate the necessary results and explain them.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-1543175783750978670?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/1543175783750978670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/08/activity-10.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/1543175783750978670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/1543175783750978670'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/08/activity-10.html' title='ACTIVITY 10 Preprocessing Text'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_EPNyhV1xE8I/SnxRfUIubfI/AAAAAAAAATI/kwYRzcbGQvE/s72-c/mogrify.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-5014602146179831142</id><published>2009-08-05T18:11:00.001-07:00</published><updated>2009-08-06T12:37:07.053-07:00</updated><title type='text'>ACTIVITY 9 Binary Operations</title><content type='html'>&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;The purpose for this activity is to learn the techniques of properly segmenting/separating the region of interest (ROI) from the background. One technique is the binarization of the image. However, this method is not enough sometimes especially when there is an overlap in the graylevel distribution of the background and the ROI. One way to improve the separation of the ROI from the background using this technique is by creating subimages. The goal would be to have less ROI in the subimage to avoid the overlapping in the graylevel distribution. The threshold value may differ for the different subimages. This means the more the subimages are, the higher the success that the ROI will be well segmented from the background.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;Unfortanately, binarization even with so many subimages is still not enough. A technique can be employed in the binarized subimages to further clean them. This is with the use of the morphological operations we learned in the previous activity, i.e., erosion and dilation. For this activity, we will be using new operations which utilizes both erosion and dilation. Opening is the operation in which the image is eroded first, and then the result is dilated using the same structuring element (SE) or another one. Closing, on the other hand, is the operation that dilates first, and then erodes the resulting image.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;Proper segmentation is required especially when dealing with image-based measurements. For example, in this activity, we would like to calculate the area of the circles/holes. To be able to arrive at an accurate value, the image has to be prepocessed first.&lt;br /&gt;&lt;br /&gt;The following were done to have a well-segmented ROI from the background:&lt;br /&gt;&lt;br /&gt;1.) The images were subdivided into 6 subimages. (see Figure 1)&lt;br /&gt;&lt;br /&gt;2.) For each subimage, the histogram was generated. (see Figure 2)&lt;br /&gt;&lt;br /&gt;3.) Choosing a threshold value for each subimage (~0.80), the subimages were binarized. (see Figure 3)&lt;br /&gt;&lt;br /&gt;4.) The binarized images were then further cleaned using only the opening function.  (see Figure 4) I didn't find the closing function usefeul becauses it does not separate nearly connected blobs but instead treat them as one blob. On the other hand, using both opening and closing functions do not give that much difference in the calculation of the area.&lt;br /&gt;&lt;br /&gt;5.) The blobs in the each subimage are then labeled using the function &lt;span style="font-weight: bold;"&gt;bwlabel()&lt;/span&gt;. It simply assigns an integer number to all connected pixel locations. Different groups of connected pixels have different assigned values. (see Figure 5)&lt;br /&gt;&lt;br /&gt;6.) The area of each blob in the subimage is then calculated. This was done by simply getting the size of the blob with that assigned integer number. A bar graph of the calculated areas arranged in decreasing order is then established (see Figure 6) Extreme values are not included in the calculation of the mean area and standard deviation. In this case, only data 10-52 are included. The calculated mean area is 521 pixels while the standard deviation is 23.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SnouLu0oYbI/AAAAAAAAAQY/bCv1HfQn3FY/s1600-h/subimages.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 333px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SnouLu0oYbI/AAAAAAAAAQY/bCv1HfQn3FY/s400/subimages.png" alt="" id="BLOGGER_PHOTO_ID_5366652685047587250" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Figure 1. The image subdivided into 6 parts.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SnouLWkDj_I/AAAAAAAAAQQ/RePxPw8_dDM/s1600-h/histogram.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 358px; height: 400px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SnouLWkDj_I/AAAAAAAAAQQ/RePxPw8_dDM/s400/histogram.png" alt="" id="BLOGGER_PHOTO_ID_5366652678535614450" border="0" /&gt;&lt;/a&gt;Figure 2. Histogram of the subimages.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/SnouLIA3iiI/AAAAAAAAAQI/g9MTFNy3CPs/s1600-h/binarized.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 332px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/SnouLIA3iiI/AAAAAAAAAQI/g9MTFNy3CPs/s400/binarized.png" alt="" id="BLOGGER_PHOTO_ID_5366652674629929506" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Figure 3. Binarized form of the subimages.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnouK6_SrtI/AAAAAAAAAQA/8d85YKMyHbM/s1600-h/opening.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 332px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnouK6_SrtI/AAAAAAAAAQA/8d85YKMyHbM/s400/opening.png" alt="" id="BLOGGER_PHOTO_ID_5366652671133658834" border="0" /&gt;&lt;/a&gt;Figure 4. Resulting image after applying the opening function on the subimages.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnrPIelQitI/AAAAAAAAARo/YQyLZmYr6Xg/s1600-h/bwlabel.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 332px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnrPIelQitI/AAAAAAAAARo/YQyLZmYr6Xg/s400/bwlabel.png" alt="" id="BLOGGER_PHOTO_ID_5366829650520607442" border="0" /&gt;&lt;/a&gt;Figure 5. Labeled holes of the subimages.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnouKsq71aI/AAAAAAAAAP4/WYlTLtkdWpI/s1600-h/area.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 170px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SnouKsq71aI/AAAAAAAAAP4/WYlTLtkdWpI/s400/area.jpg" alt="" id="BLOGGER_PHOTO_ID_5366652667290178978" border="0" /&gt;&lt;/a&gt;Figure 6. Calculated areas arranged in decreasing order.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I would give myself a grade of 10 for this acitvity because I believe I did this activity correctly. I would like to thank Thirdy and Jaze for their help in some parts of this acitivity.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-5014602146179831142?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/5014602146179831142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/08/activity-9-binary-operations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/5014602146179831142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/5014602146179831142'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/08/activity-9-binary-operations.html' title='ACTIVITY 9 Binary Operations'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_EPNyhV1xE8I/SnouLu0oYbI/AAAAAAAAAQY/bCv1HfQn3FY/s72-c/subimages.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-721678762436150301</id><published>2009-07-25T05:15:00.001-07:00</published><updated>2009-08-06T11:36:27.105-07:00</updated><title type='text'>ACTIVITY 8 Morphological Operations</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;br /&gt;This activity was done to illustrate what the two common morphological operations, erosion and dilation, do when applied on an image of shapes or patterns. Figure 1 shows the image of shapes used in the activity. Before using the available functions in Scilab, the resulting images after applying  erosion and dilation using the structuring elements (SE) in  Figure 2 were first predicted. Theoretically, the resulting image after dilation is the set of all possible translations of the reflected SE such that when it is intersected with the image/shape, it is not an empty set. In the case of erosion, it contains all the possible translations of SE such that it is still contained in the shape. Given the definitions above, using dilation increases the size of the shape while using erosion reduces its size.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smr6sWTQKVI/AAAAAAAAAOc/yVDWnG7Q1vg/s1600-h/shapes.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 78px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smr6sWTQKVI/AAAAAAAAAOc/yVDWnG7Q1vg/s400/shapes.png" alt="" id="BLOGGER_PHOTO_ID_5362373946145515858" border="0" /&gt;&lt;/a&gt;Figure 1. The shapes used to illustrate the effect of the morphological operations/functions, dilation and erosion, on binary images.&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SmsD9ToUcRI/AAAAAAAAAOk/IK9rBUVnCXA/s1600-h/SE.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 132px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SmsD9ToUcRI/AAAAAAAAAOk/IK9rBUVnCXA/s400/SE.png" alt="" id="BLOGGER_PHOTO_ID_5362384133090996498" border="0" /&gt;&lt;/a&gt;Figure 2. Structuring elements used to dilate and erode the images of shapes above: (4 x 4 ones), (2 x 4 ones), (4 x 2 ones) and a cross of length 5 and thickness 1.&lt;br /&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;Predictions: &lt;/span&gt;&lt;br /&gt;For dilation, I just placed the SE at the corners of the shape such that at least 1 pixel is left contained in the shape. After which, I traced the corners of the SE located at the corners of the shape. My predictions show that the dimension of the shape is, indeed, increased by twice the (width/length -1) of the SE. Also, the resulting shape has curves similar to the SE.&lt;br /&gt;For erosion, I translated the SE at the corners of the shape such that the edge of the SE and the shape coincide. Then, I chose the edges of the resulting shape such that at least one pixel of the SE is contained in that new shape. My predictions show that the dimension of the shape is reduced by twice the (width/length -1) of the SE. The resulting shape has also curves similar to the shape of the SE.&lt;br /&gt;For a clearer visualization of what I meant above, look at the figures for my predictions.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;Simulation using SciLab:&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Figures 3 to 7 show the resulting images after applying the erosion and dilation functions available in SciLab on the images in Figure 1 using the stucturing elements in Figure 2. The gray portion is the original size while the white portion is new size (erosion) or increase in size (dilation). A detailed list of the dimensions of the resulting shapes can be found in the table below. The outline/curves of the resulting shapes match my predictions. However, only or some shapes and some SEs were my predictions able to match the simulation results. The following are the reasons for the disagreement of the results with my predictions:&lt;br /&gt;1. The original size in my predictions is wrong. The shapes I created are smaller than my expected original size.&lt;br /&gt;2. I forgot that the set of translations must be positive.&lt;br /&gt;After realizing the those two things, I was able to correct my predictions and get the same results as the simulation results. Instead of the twice the (length/width of the SE- 1) increase or decrease in the dimension that I have predicted earlier, the  change in dimension must only be by (length/width of the SE- 1) .&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smr4X5--0UI/AAAAAAAAAOU/OAE0xmYZ45A/s1600-h/square.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 199px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smr4X5--0UI/AAAAAAAAAOU/OAE0xmYZ45A/s400/square.png" alt="" id="BLOGGER_PHOTO_ID_5362371395923661122" border="0" /&gt;&lt;/a&gt;Figure 3. First row: dilation of square; second row: erosion of square.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smr4XuAnxHI/AAAAAAAAAOM/xQstiTetvm4/s1600-h/circle.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 198px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smr4XuAnxHI/AAAAAAAAAOM/xQstiTetvm4/s400/circle.png" alt="" id="BLOGGER_PHOTO_ID_5362371392709313650" border="0" /&gt;&lt;/a&gt;Figure 4. First row: dilation of circle; second row: erosion of circle.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smr4Xe_kF-I/AAAAAAAAAOE/EtGnjlLgTe4/s1600-h/triangle.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 199px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smr4Xe_kF-I/AAAAAAAAAOE/EtGnjlLgTe4/s400/triangle.png" alt="" id="BLOGGER_PHOTO_ID_5362371388678346722" border="0" /&gt;&lt;/a&gt;Figure 5. First row: dilation of triangle; second row: erosion of triangle.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/Smr4XOezN6I/AAAAAAAAAN8/FV2qqQM_HZs/s1600-h/hollowsquare.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 199px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/Smr4XOezN6I/AAAAAAAAAN8/FV2qqQM_HZs/s400/hollowsquare.png" alt="" id="BLOGGER_PHOTO_ID_5362371384245958562" border="0" /&gt;&lt;/a&gt;Figure 6. First row: dilation of hollow square; second row: erosion of hollow square.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/Smr4W48sZqI/AAAAAAAAAN0/jxIN9ptzUF0/s1600-h/plussign.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 198px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/Smr4W48sZqI/AAAAAAAAAN0/jxIN9ptzUF0/s400/plussign.png" alt="" id="BLOGGER_PHOTO_ID_5362371378465760930" border="0" /&gt;&lt;/a&gt;Figure 7. First row: dilation of plus sign; second row: erosion of plus sign.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SmsbdXkD8yI/AAAAAAAAAPE/6dTTo68Jk2s/s1600-h/dimensions.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 136px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SmsbdXkD8yI/AAAAAAAAAPE/6dTTo68Jk2s/s400/dimensions.png" alt="" id="BLOGGER_PHOTO_ID_5362409972670133026" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Figures 8 and 9 are illustrations of the morphological operations, thin and skeleton, that are also available in SciLab. The thin function, basically, makes the images/shapes/patterns one-pixel thick. On the other hand, the skeleton function traces the interior/exterior skeleton of the images/shapes/patterns. It is dependent on the number of sides of the shape.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SmsTWTmYWaI/AAAAAAAAAO0/DE-OTKvioVs/s1600-h/thin.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 78px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SmsTWTmYWaI/AAAAAAAAAO0/DE-OTKvioVs/s400/thin.png" alt="" id="BLOGGER_PHOTO_ID_5362401055254010274" border="0" /&gt;&lt;/a&gt;Figure 8. Results after applying the &lt;span style="font-style: italic;"&gt;thin&lt;/span&gt; function on the images.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SmsTWF65bHI/AAAAAAAAAOs/zXq6K5Mn-7E/s1600-h/skel.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 159px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SmsTWF65bHI/AAAAAAAAAOs/zXq6K5Mn-7E/s400/skel.png" alt="" id="BLOGGER_PHOTO_ID_5362401051581967474" border="0" /&gt;&lt;/a&gt;Figure 9. Results after applying the &lt;span style="font-style: italic;"&gt;skel&lt;/span&gt; function on the images. First row: using the interior side; second row: using the exterior side.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I would give myself a grade of 9 for this activity. My predictions did not match the simulation results but I have explained above the reasons why it didn't.&lt;br /&gt;Thank you to all those who have helped me in this activity.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-721678762436150301?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/721678762436150301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/07/activity-8-morphological-operations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/721678762436150301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/721678762436150301'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/07/activity-8-morphological-operations.html' title='ACTIVITY 8 Morphological Operations'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_EPNyhV1xE8I/Smr6sWTQKVI/AAAAAAAAAOc/yVDWnG7Q1vg/s72-c/shapes.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-4705302387982208208</id><published>2009-07-22T08:42:00.001-07:00</published><updated>2009-08-07T00:54:06.884-07:00</updated><title type='text'>ACTIVITY 7 Enhancement in the Frequency Domain</title><content type='html'>&lt;span style="font-weight: bold;"&gt;7.A Convolution Theorem&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Figure 1 shows a set of patterns, which illustrates the Fourier transform of  the convolution of two images. The last three images can also be thought of as the convolution of the patterns (square, circle, Gaussian) with the two dots in the first image. Recall that the Fourier transform of a convolution is just the the product of the Fourier transforms of the images. Recalling the Fourier transform of a square and a circle, which are shown in the previous activity, Figure 1, indeed, illustrates that the Fourier transform of convolution of two images is just the product of their Fourier transform. Figures 2, 3 and 4 show the variation in the Fourier transform when the sizes of the patterns are varied. It can be seen that the size of the pattern in the Fourier transform, most obvious with the brightest spot, generally decreases with increasing size of the image pattern. Inverting the grayscale value of the image pattern yields a similar Fourier transform pattern but of inverted grayscale value also (see Figure 6).&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smc1ui0y2RI/AAAAAAAAANs/P4ZmOB5hVxY/s1600-h/FT.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 244px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smc1ui0y2RI/AAAAAAAAANs/P4ZmOB5hVxY/s400/FT.bmp" alt="" id="BLOGGER_PHOTO_ID_5361312955146361106" border="0" /&gt;&lt;/a&gt;Figure 1. Fourier transform of different image patterns.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smc1uXr3k0I/AAAAAAAAANk/H9o7KGxeo1o/s1600-h/BIGGER+DOTS.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 275px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smc1uXr3k0I/AAAAAAAAANk/H9o7KGxeo1o/s400/BIGGER+DOTS.bmp" alt="" id="BLOGGER_PHOTO_ID_5361312952156132162" border="0" /&gt;&lt;/a&gt;Figure 2. Fourier transform of square dots of different sizes.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smc1uIB8DkI/AAAAAAAAANc/l9ZRyKVs_yM/s1600-h/CIRCLES.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 260px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/Smc1uIB8DkI/AAAAAAAAANc/l9ZRyKVs_yM/s400/CIRCLES.bmp" alt="" id="BLOGGER_PHOTO_ID_5361312947953733186" border="0" /&gt;&lt;/a&gt;Figure 3. Fourier transform of circular dots of different sizes.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Smc1ty_gCgI/AAAAAAAAANU/LsG-agb0WeM/s1600-h/GAUSSIANS.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 214px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Smc1ty_gCgI/AAAAAAAAANU/LsG-agb0WeM/s400/GAUSSIANS.bmp" alt="" id="BLOGGER_PHOTO_ID_5361312942306363906" border="0" /&gt;&lt;/a&gt;Figure 4. Fourier transform of Gaussian dots of different sizes.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/Smc0pIgmtoI/AAAAAAAAANE/5TUTdNXZkN8/s1600-h/REALandIMAG.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 214px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/Smc0pIgmtoI/AAAAAAAAANE/5TUTdNXZkN8/s400/REALandIMAG.bmp" alt="" id="BLOGGER_PHOTO_ID_5361311762671384194" border="0" /&gt;&lt;/a&gt;Figure 5. Comparison of the real and imaginary parts of the Fourier transforms of the Gaussian dots and the inverted Gaussian dots.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;7.B Fingerprints: Ridge Enhancement&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Image enhancement can be done either in the spatial domain. Histogram equalization to improve the contrast of the image, which we did in activity 4 is an example of enhancing in the spatial domain. In this activity, the enhancement of the image is done in the frequency domain by blocking all unnecessary frequency (bias and noise) so that the Fourier transform contains only the information (frequencies) regarding the actual image. Basically, the remaining parts of this activity is about filtering in the frequency domain. Filter masks were created depending on the Fourier transform of the image and the frequency that has to be blocked. It is important that the masks are of inverted grayscale value (background-1, foreground/pattern-0). Basically, the masks just follow the shape of the frequency patterns that will be blocked. The concept behind linear filtering in the frequency domain is the convolution theorem. Thus, the inverse Fourier transform of the product of the filter mask and the Fourier transform of the image is the convoluted image of the original image  and the noise pattern, which is of inverted grayscale value. This results in an image without the noise patterns.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In the case of fingerprint ridges enhancement, the filter mask created is not of inverted grayscale value because it makes filtering much easier. This is because the actual frequencies of the fingerprint are much more obvious than the unnecessary frequencies. A circular filter mask is used for the actual frequencies of the fingerprint while a Gaussian dot is used for the cutoff in the central frequency, which is the  needed mask (controlling factor) for ridge enhancement. The filter used leaves all components inside the circle and Gaussian unchanged but cuts off all components outside these regions. The results are shown in Figures 6 and 8. A binarized form of the original and enhanced images are shown in Figure 7 to clearly illustrate the enhancement of the image due to the filtering process. Blotches are removed and the lines or ridges are more defined.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/Smc0o3xPu0I/AAAAAAAAAM8/_n8hn8Ot84U/s1600-h/fingerprint.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 400px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/Smc0o3xPu0I/AAAAAAAAAM8/_n8hn8Ot84U/s400/fingerprint.jpg" alt="" id="BLOGGER_PHOTO_ID_5361311758177778498" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Figure 6. Clockwise from top left: grayscale image of a fingerprint; its Fourier transform; filter mask used; enhanced grayscale image of the fingerprint.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Smc0or-tnjI/AAAAAAAAAM0/_KDRETh9sdM/s1600-h/fingerprint1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 400px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Smc0or-tnjI/AAAAAAAAAM0/_KDRETh9sdM/s400/fingerprint1.jpg" alt="" id="BLOGGER_PHOTO_ID_5361311755013037618" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Figure 7. Clockwise from top left: grayscale image of the fingerprint; equivalent binary image; enhanced grayscale image; equivalent enhanced binary image.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/Smc0oQl07EI/AAAAAAAAAMs/weYDswy8N8A/s1600-h/fingerprint+2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 400px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/Smc0oQl07EI/AAAAAAAAAMs/weYDswy8N8A/s400/fingerprint+2.jpg" alt="" id="BLOGGER_PHOTO_ID_5361311747660901442" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Figure 8. Clockwise from top left: paler grayscale image of another fingerprint; its Fourier transform; filter mask used; enhanced grayscale image of the fingerprint.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;7.C Lunar Landing Scanned Pictures: Line Removal&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Recall that the Fourier transform of equally spaced lines is approximately a line but perpendicular to the direction of the lines in the image. So, if the horizontal (vetical) lines have to be removed, the vertical (horizontal) line in the Fourier domain has to be filtered. Figure 8 shows the resulting images when only the horizontal lines are removed and when both horizontal and vertical lines are removed.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/Smcz27gMEZI/AAAAAAAAAMk/3wR560fsEAU/s1600-h/image1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 352px; height: 400px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/Smcz27gMEZI/AAAAAAAAAMk/3wR560fsEAU/s400/image1.jpg" alt="" id="BLOGGER_PHOTO_ID_5361310900186517906" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Figure 9. First column from top: original grayscale image; vertical lines removed in the image; both horizontal and vertical lines removed in the image. Second column from top: Fourier transform of the original original image; filter mask used to remove vertical lines; filter mask used to remove both horizontal and vertical lines.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;7.D Canvas Weave Modeling and Removal&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Figure 10 shows the Fourier transform of the image, filter mask used to remove the canvas weave pattern and the resulting enhanced image. Figure 11 shows the inverse Fourier transform of the inverted filter mask. It is more or less similar to the canvas weave pattern in the image. It is even shown, also in Figure 11, that when the pattern is added to the enhanced image, the original image having the canvas weave pattern is restored.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/Smczm2jydzI/AAAAAAAAAMc/vf0O1kJvhv0/s1600-h/image2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 291px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/Smczm2jydzI/AAAAAAAAAMc/vf0O1kJvhv0/s400/image2.jpg" alt="" id="BLOGGER_PHOTO_ID_5361310623981532978" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Figure 10. Clockwise from top left: original grayscale image; its Fourier transform; filter mask used; enhanced grayscale image without the canvas weave pattern.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SmczmoRzJzI/AAAAAAAAAMU/txm6A2usMv0/s1600-h/canvasweave.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 290px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SmczmoRzJzI/AAAAAAAAAMU/txm6A2usMv0/s400/canvasweave.jpg" alt="" id="BLOGGER_PHOTO_ID_5361310620147984178" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Figure 11. Clockwise from top left: inverted grayscale image of the filter mask used; reconstructed canvas weave pattern; resultant image of adding the reconstructed canvas weave pattern and the enhanced grayscale image; original image.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I created the filter masks using SciLab only because it is easier for me than creating them using Paint. There is a risk, however, for this procedure that  it will also block the needed frequencies and not totally filter the undesired frequencies. But since the images are perfectly enhanced, the filter masks that were created avoided the risks mentioned above.&lt;br /&gt;&lt;br /&gt;I would like to thank Raffy for explaining to me the process of filtering especially the  correct usafe of the fftshift() function. I would also like to thank Thirdy and all others who have helped me finish this acitivity. A grade of 10 for this activity because the images were perfectly enhanced.&lt;br /&gt;&lt;br /&gt;References:&lt;br /&gt;1. Fingerprint: http://www.staffordsheriff.com/content/childsafety/Image/Fingerprint picture 1.jpg&lt;br /&gt;2. Digital Image Processing using MATLAB by R. Gonzales, R. Woods and S. Eddins&lt;br /&gt;&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;/div&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-4705302387982208208?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/4705302387982208208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/07/activity-7-enhancement-in-frequency.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/4705302387982208208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/4705302387982208208'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/07/activity-7-enhancement-in-frequency.html' title='ACTIVITY 7 Enhancement in the Frequency Domain'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_EPNyhV1xE8I/Smc1ui0y2RI/AAAAAAAAANs/P4ZmOB5hVxY/s72-c/FT.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-3881507537824723346</id><published>2009-07-09T00:31:00.000-07:00</published><updated>2009-08-06T08:11:40.342-07:00</updated><title type='text'>ACTIVITY 6 Properties of the Fourier Transform</title><content type='html'>&lt;div align="center"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;br /&gt;6.A Familiarization with FT of Different Patterns&lt;br /&gt;&lt;span style="font-weight: normal;"&gt;&lt;br /&gt;Below are some simple patterns commonly used in image processing and their Fourier transform.  It can be seen that the Fourier transform is unique to each pattern. Complex patterns may have Fourier transform as combination of the Fourier transform of these simple patterns.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;a href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SlWihM1KG5I/AAAAAAAAALM/moroAG9HgK8/s1600-h/FT.bmp"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 400px; display: block; height: 189px;" id="BLOGGER_PHOTO_ID_5356366023090641810" alt="" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SlWihM1KG5I/AAAAAAAAALM/moroAG9HgK8/s400/FT.bmp" border="0" /&gt;&lt;/a&gt; Figure 1. &lt;em&gt;&lt;span style="font-size:85%;"&gt;click the image for a better view&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;6.B Anamorphic Property of the Fourier Transform&lt;/strong&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;The anamorphic property of Fourier transforms is being investigated here by getting the Fourier transform of sinusoid of different frequencies and at different directions. Figure 2 shows the variation in the Fourier transform when the frequency of the sinusoid is varied. The increase in frequency is illustrated in the decrease in spacing between the lines and the width of the lines itself (white lines). Notice that the image of the sinusoid can also be represented as equally spaced slits. The Fourier transform is, therefore, composed of the Fourier transform of two slits (see Figure 1). Two rectangular spots are prominent in the Fourier transform. The spacing between these two spots increases as the frequency of the sinusoid is increased. These also become longer when the frequency is increased. It can also be observed that the direction of the Fourier transform is perpendicular to the direction of the lines. In this case, the sinusoid is composed of horizontal lines and so, the Fourier transform is in the vertical direction.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SlWig0jCFBI/AAAAAAAAALE/RzbPVCzDDH8/s1600-h/FT_sinusoid.bmp"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 400px; display: block; height: 248px;" id="BLOGGER_PHOTO_ID_5356366016572167186" alt="" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SlWig0jCFBI/AAAAAAAAALE/RzbPVCzDDH8/s400/FT_sinusoid.bmp" border="0" /&gt;&lt;/a&gt; &lt;div align="center"&gt;Figure 2. &lt;em&gt;&lt;span style="font-size:85%;"&gt;click the image for a better view&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Figure 3 illustrates the effect of a constant bias to a sinusoid. It is evident from the images that adding a constant bias would just give a zero frequency in the Fourier transform, i.e., at the center. No matter how large the constant bias is, it will just be translated as a zero-frequency in the Fourier domain. To get the actual frequency of the sinusoid, one can cover/filter the zero-frequency using a filter mask that has zero value at the center and a value of 1 at other pixel locations. Filtering the zero-frequency leaves only the actual frequencies in the Fourier transform. If the bias added isnonconstant and unknown, a Fourier transform containing only the actual frequencies can still be produced by creating a filter mask which has a value of 1 only at pixel locations having the information about the actual frequencies. However, this is only possible if the actual frequencies are known, i.e., involving the common patterns such as those presented above.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SlWf2T1Y1TI/AAAAAAAAAKc/m5xQjIAZRQ4/s1600-h/FT_constantbias.bmp"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 400px; display: block; height: 101px;" id="BLOGGER_PHOTO_ID_5356363087213024562" alt="" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SlWf2T1Y1TI/AAAAAAAAAKc/m5xQjIAZRQ4/s400/FT_constantbias.bmp" border="0" /&gt;&lt;/a&gt; Figure 3. &lt;em&gt;&lt;span style="font-size:85%;"&gt;click the image for a better view&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;div style="text-align: justify;"&gt;&lt;em&gt;&lt;/em&gt;Rotating the sinusoid can also be reflected in its Fourier transform as shown in Figure 4. But the direction of rotation in the Fourier transform is always opposite or perpendicular to the direction of rotation in the image. In the figure below, the sinusoid is rotated with respect to the horizontal but the rotation in the Fourier transform is with respect to the vertical. The angle of rotation is the same for both domains.&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SlWf15xS1lI/AAAAAAAAAKU/0VJNjxe9bog/s1600-h/FT_ROTATED.bmp"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 400px; display: block; height: 100px;" id="BLOGGER_PHOTO_ID_5356363080216532562" alt="" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SlWf15xS1lI/AAAAAAAAAKU/0VJNjxe9bog/s400/FT_ROTATED.bmp" border="0" /&gt;&lt;/a&gt; Figure 4. cli&lt;em&gt;&lt;span style="font-size:85%;"&gt;ck the image for a better view&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The Fourier transform of a combination or an addition of sinusoid with different frequencies and with different angle of rotations is just the superposition of the Fourier transform of each component. As predicted, the Fourier transform in Figure 6 is the superposition of the  Fourier transform the 8 sinusoid that constitute the image. If the sinusoid are multiplied, then a Fourier transform such as that in Figure 5 will be the result.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SlWf1oxVH8I/AAAAAAAAAKM/YTGkWrAhwbQ/s1600-h/FT_XY.bmp"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 400px; display: block; height: 100px;" id="BLOGGER_PHOTO_ID_5356363075653279682" alt="" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SlWf1oxVH8I/AAAAAAAAAKM/YTGkWrAhwbQ/s400/FT_XY.bmp" border="0" /&gt;&lt;/a&gt; Figure 5. &lt;em&gt;&lt;span style="font-size:85%;"&gt;click the image for a better view&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SlWf1eQm45I/AAAAAAAAAKE/bGEgVZmc8mU/s1600-h/FT_comb.bmp"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 400px; display: block; height: 98px;" id="BLOGGER_PHOTO_ID_5356363072831677330" alt="" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SlWf1eQm45I/AAAAAAAAAKE/bGEgVZmc8mU/s400/FT_comb.bmp" border="0" /&gt;&lt;/a&gt; Figure 6. &lt;em&gt;&lt;span style="font-size:85%;"&gt;click on the image for a better view&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In summary, different patterns produce different patterns of Fourier transform. A combination of these patterns results in a superposition of their Fourier transform. The anamorphic property of Fourier transform is the characteristic difference in spacings due to the change in spacing in the image. It also explains the perpendicularity in the direction of the image and the Fourier transform lines. Any rotation in the image results in a rotation in the  Fourier transform.&lt;br /&gt;&lt;br /&gt;I give myself a grade of 10 for this activity because I was able to do everything that has to be done. I would like to thank Thirdy and all those who have helped me finish this acitvity.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-3881507537824723346?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/3881507537824723346/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/07/activity-6-properties-of-fourier.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/3881507537824723346'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/3881507537824723346'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/07/activity-6-properties-of-fourier.html' title='ACTIVITY 6 Properties of the Fourier Transform'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_EPNyhV1xE8I/SlWihM1KG5I/AAAAAAAAALM/moroAG9HgK8/s72-c/FT.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-6712584093408564609</id><published>2009-07-07T05:21:00.000-07:00</published><updated>2009-07-09T00:25:17.523-07:00</updated><title type='text'>ACTIVITY 5  Fourier Transform Model of Image Formation</title><content type='html'>&lt;span style="font-weight: bold;font-size:100%;" &gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;Programming Language: Scilab 4.1.2&lt;/span&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;&lt;br /&gt;&lt;br /&gt;6.A Familiarization with Discrete FFT &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;This part of the activity allows us to visualize the basic meaning of the fundamental functions of Fourier transform greatly needed in image formation and image processing. The first function we tried is&lt;span style="font-weight: bold;"&gt; fft()&lt;/span&gt;. The information embedded in an image is in the spatial domain. By applying &lt;span style="font-weight: bold;"&gt;fft()&lt;/span&gt; on the image, we are transforming the image information into the frequency domain (see FFT of Figures 1 and 2). However, the Fourier transform of an image is not much of a help also in understanding the information encoded in the image. The second function we tried is &lt;span style="font-weight: bold;"&gt;fftshift()&lt;/span&gt;. It rearranges the fft output in such a way that the zero-frequency component of the spectrum is shifted at the center (see FFTSHIFT of Figures 1 and 2). For the circle, the resulting image resembles the Airy disk or pattern which is the analytic Fourier transform of circles. In the case of letter A, the resulting image is the combination of the Fourier transforms of the vertical diagonal lines and a horizontal line that form the letter, i.e.  two intersecting horizontal diagonal lines and a vertical line, respectively. This is in accordance to the distributive property of Fourier transform. As an additional exercise, we also tried applying the &lt;span style="font-weight: bold;"&gt;ff()&lt;/span&gt; function twice on the image (see FFT of FFT of Figures 1 and 2). The resulting image is the inverted form of the original image. This can be explained by recalling the duality property of Fourier transforms, i.e. FT of FT of &lt;span style="font-weight: bold;"&gt;f(x) = f(-x)&lt;/span&gt;. The inversion is not evident in the circle since it is symmetric in all directions. The visualization of applying &lt;span style="font-weight: bold;"&gt;fft() &lt;/span&gt;twice is more obvious in letter A, which is inverted along the horizontal axis. So, again, applying the function &lt;span style="font-weight: bold;"&gt;fft()&lt;/span&gt; twice does not give you back the original image. If you want to get the original image, you must use the &lt;span style="font-weight: bold;"&gt;ifft()&lt;/span&gt; function or the inverse Fourier transform.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SlRL9Zd_yoI/AAAAAAAAAIk/mXYZcs-OgnY/s1600-h/circle_result.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 119px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SlRL9Zd_yoI/AAAAAAAAAIk/mXYZcs-OgnY/s400/circle_result.jpg" alt="" id="BLOGGER_PHOTO_ID_5355989375031167618" border="0" /&gt;&lt;/a&gt;Figure 1. &lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;click on the image for a better view&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/SlRL9B8p1LI/AAAAAAAAAIc/bLxPIeR9jg4/s1600-h/letter+A_result.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 111px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/SlRL9B8p1LI/AAAAAAAAAIc/bLxPIeR9jg4/s400/letter+A_result.jpg" alt="" id="BLOGGER_PHOTO_ID_5355989368717300914" border="0" /&gt;&lt;/a&gt;Figure 2. &lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;click on the image for a better view&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;6.B Simulation of an Imaging Device&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Simulation of an imaging device is similar to getting the convolution of two functions or the product of the Fourier transform of the two functions. It is also the same as "smearing" of one function against the other such that the resulting function looks similar to both functions. In the case of an imaging device, the resulting image would be how the device detects the object being viewed. For this activity, our object is the word VIP and our imaging device is the circular aperture representing a cicular lens of finite radius. Finite radius means the lens can only detect a limited number of light rays reflected off the object resulting into an image that is never 100% similar to the actual object. The resulting image is dependent on the radius of the circle as shown in Figure 3. For very small circles, the resulting image is distorted and cannot be read. This is because the light rays allowed by the lens to pass is not enough to reconstruct the word VIP. As the circle gets bigger, the resulting image becomes more like the original image. As you can see in Figure 3, the reconstructed VIP word is still gray when the medium-sized circle is used. It becomes whiter and the edges are more defined when the larger circle is used. This just means that the lens is able to collect more light rays enough to reconstruct the word VIP. The variation in the radius of the lens is reflected in the varying color of the reconstructed word from gray to white.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SlM-rTD7GDI/AAAAAAAAAH8/Smne3fwAhiU/s1600-h/VIP_result.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 214px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SlM-rTD7GDI/AAAAAAAAAH8/Smne3fwAhiU/s400/VIP_result.jpg" alt="" id="BLOGGER_PHOTO_ID_5355693295445678130" border="0" /&gt;&lt;/a&gt;Figure 3. &lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;click on the image for a better view&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;6.C Template Matching Using Correlation&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Our goal for this part is to count the number of A's in the text "THE RAIN IN SPAIN STAYS MAINLY IN SPAIN". We did this by getting the correlation between the two images containing the text and a letter A made using Microsoft Paint. It must be noted that the text and A must be of the same font size to be able to successfully correlate the two images.  As mentioned in the manual,  the correlation of the two functions&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;span&gt;representing the images measures their degree of similarity. The more identical the two images are on the same position, the higher their correlation value is. High correlation values are represented by very bright dots in the resulting image (see MATCHED in Figure 4). The mesh plot of the image supports this also. There are 5 bight dots in MATCHED and 5 spikes in the mesh plot, which means there are 5 A's in the text. We also manually counted 5 A's in the text Hence, the code we created can be used for template matching. It is also mentioned in the manual that correlation is related to convolution and if at least &lt;/span&gt;&lt;span&gt;one of the functions&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;span&gt;is even&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;, &lt;/span&gt;&lt;span&gt;the correlation is just equal to the convolution. If the A, which is symmetrical, is located at the center of the image, then the function representing it would be even. It means the correlation would just be equal to the convolution of the images.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SlM-nhNSQZI/AAAAAAAAAH0/nz2bj2E2YPo/s1600-h/C_result.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 214px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SlM-nhNSQZI/AAAAAAAAAH0/nz2bj2E2YPo/s400/C_result.jpg" alt="" id="BLOGGER_PHOTO_ID_5355693230523564434" border="0" /&gt;&lt;/a&gt;Figure 4. &lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;click on the image for a better view&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;6.D Edge Detection Using the Convolution Integral&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We were able to successfully detect the edges of the word VIP depending on the orientation of the black portions in the leftmost images (see Figure 5). If it they are oriented horizontally (vertically), then only the horizontal (vertical) lines in the edges will be detected. In the case of the All Around, all edges are detected since it contains both horizontal and vertical orientations. The diagonal lines in the edges may also be detected since they have components in both orientations (horizontal and vertical).&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SlM-gh_attI/AAAAAAAAAHs/SfXFZCt-bwY/s1600-h/edge_result.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 214px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SlM-gh_attI/AAAAAAAAAHs/SfXFZCt-bwY/s400/edge_result.jpg" alt="" id="BLOGGER_PHOTO_ID_5355693110474749650" border="0" /&gt;&lt;/a&gt;Figure 5. &lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;click on the image for a better view&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I was able to successfully generate the necessary images for this activity but I was not able to finish it before deadline, so I would just myself a grade of 9 for this activity. I would like to thank Mr. Luis Buno III, Mr. Jaya Combinido and Ms. Kaye Vergel for answering some of my questions. I would also like to thank Prof. Maricor Soriano for her suggestion about mesh plot in part C.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;References:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;1. Activity 5 Manual&lt;br /&gt;2. http://www.dspguide.com/ch24/5.htm&lt;br /&gt;3. http://www.insight-journal.org/browse/publication/125&lt;br /&gt;4. http://www.scilab.org/product/man/fftshift.html&lt;br /&gt;5. Integral Transforms and Applications by Lokenath Debnath&lt;/span&gt;&lt;br /&gt;&lt;table style="width: 650px; height: 48px;" id="volumebartable" border="0" cellpadding="0" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="volumetabspace"&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class="volumetitle"&gt;&lt;br /&gt;&lt;/td&gt;&lt;td style="vertical-align: top;"&gt;&lt;br /&gt;&lt;/td&gt;&lt;td style="vertical-align: top;"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-6712584093408564609?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/6712584093408564609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/07/activity-5-fourier-transform-model-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/6712584093408564609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/6712584093408564609'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/07/activity-5-fourier-transform-model-of.html' title='ACTIVITY 5  Fourier Transform Model of Image Formation'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_EPNyhV1xE8I/SlRL9Zd_yoI/AAAAAAAAAIk/mXYZcs-OgnY/s72-c/circle_result.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-2748226992336498925</id><published>2009-07-01T08:58:00.000-07:00</published><updated>2009-07-07T05:34:14.728-07:00</updated><title type='text'>ACTIVITY 4 Enhancement by Histogram Manipulation</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;div style="text-align: center;"&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span&gt;For this activity, we tried to enhance grayscale images with poor contrast. For an 8-bit image,  its gray levels can range from 1 to 256. However, those with poor contrast have gray levels which occupy only a small portion of the available range of values. To have a better understanding, we create a histogram of our image. Consider the probability distribution function (PDF) of the original image in Figure 1 &lt;span style="font-style: italic;"&gt;(click on the images for a better view)&lt;/span&gt;. Notice that it covers only the range 75-125 out of the 1-256 possible range. This implies that the image has poor contrast. &lt;/span&gt;&lt;span&gt;Another way to show that the image has poor contrast is by creating a cumulative distribution function (CDF). If the CDF is linear from 1 to 256, then the gray levels of the image are of "uniform density" in the entire available range of values.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;So, how did we enhance the poorly contrasted images? As mentioned above, the contrast of the image has something to do with its histogram. A narrow histogram indicates an image with poor contrast and low visibility while a widely distributed histogram means the image has good contrast and high visibility. Thus, by manipulating the histogram&lt;span&gt;, we would be able to make some changes on the contrast of the image. For this activity, we will be using the technique histogram equalization. This technique allows the transformation of a narrow histogram into a widely distributed histogram. Widely distributed signifies an approximately uniform histogram. In doing so, we are also able to to stretch the dynamic range of gray levels of the image. This means the lighter pixels of the image can still be lighter and the relatively darker pixels can be even darker. Hence, the contrast of the image is improved or increased resulting into an enhanced image.&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; &lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Basically, what we did is we assigned each pixel a new value; however, this value is dependent on the&lt;/span&gt;&lt;span&gt; original value. The relation between the new value and the original value is based on the CDF. As mentioned above, a uniform histogram produces a linear CDF. So, we generated the CDF of the original image by getting the integral of its histogram&lt;/span&gt;&lt;span&gt; and created a linear line with pixel values from 1 to 256 and CDF values from 0 to 1. The pixel value in the original image is mapped onto the equivalent pixel value in the linear line, i.e. same CDF value. The new image now contains information which produces a contrast-enhanced image, specifically histogram- equalized image. It must be noted that the assumption for this technique is that the information contained in the image is related to the probability of occurence of the pixel values as illustrated in the image histogram. I&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;t is expected that the histogram of the new image can be approximated as uniform with gray levels ranging from 1 to 256 and that the CDF is linear. &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;Listed below are the important lines of the code:&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;1.) Reads and shows the image.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;1    image = imread('F:\Documents\AP186\activity 4\grayscale10.jpg');&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;2    subplot(331)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;3    imshow((image-1)/255);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;4    title('Original Image', 'fontsize', 3)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2.) Creates a histogram or probability distribution function (PDF) of the image.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;5    s = size(image);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;6    maximum = max(image);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;7    minimum = min(image);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;8    histogram = zeros(1,256);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;9    for i = minimum:maximum,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;10      var = (image==i)*1;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;11      histogram(i) = sum(var);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;12  end&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;13  histogram = histogram/(s(1)*s(2));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;14  subplot(332)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;15  plot2d((1:256),histogram);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;16  title('PDF', 'fontsize', 3)&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;3.) &lt;/span&gt;Creates a cumulative distribution function (CDF) -- cumulative sum of the image histogram&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;17  cdf = cumsum(histogram);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;18  cdf = cdf/max(cdf);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;19  subplot(233)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;20  plot2d((1:256),cdf)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;21  title('CDF', 'fontsize', 3)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;&lt;/span&gt;4.) Assigning of new values to the pixels using the linear CDF (equation of the line/relationship between the original value and the new value: Pixel Value = CDF Value *255 +1).&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;23  newimage = image;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;24  for j = minimum:maximum,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;25       old = cdf(j);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;26      new = old*255 + 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;27      w = find(image==j);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;28      newimage(w)= new;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;29  end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The histogram and CDF of the new image were established using the same lines listed above for (2) and (3). Figures 1, 2 and 3 show some examples illustrating the technique histogram equalization in order to enhace the contrast of a poorly contrasted image. The first row shows the orginal image and its histogram, as well as its CDF. In the second row is the new image, its histogram and CDF. As you can see, the histogram of the original image is initially narrow. Moreover, the CDF increases over a small range of values only. The image has poor contrast and low visibility; the details of the image are not that clear. After performing the histogram equalization technique, the light and dark pixels are now evident. This means the contrast of the image is enhanced, as well as its visibility. As expected, the dynamic range of pixel values or gray levels is increased occupying almost the entire available range of values. The histogram is not really perfectly uniform but more or less of uniform density. This is why an approximately linear CDF is generated.&lt;span style="color: rgb(0, 0, 0);font-size:78%;" &gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SlIe_OGMeuI/AAAAAAAAAHI/I0lysECSuI4/s1600-h/moo2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 214px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SlIe_OGMeuI/AAAAAAAAAHI/I0lysECSuI4/s400/moo2.jpg" alt="" id="BLOGGER_PHOTO_ID_5355376978361613026" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 1.&lt;/span&gt; &lt;span style="font-size:85%;"&gt;http://homepages.inf.ed.ac.uk/rbf/HIPR2/histeq.htm&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SlIfwYEz1CI/AAAAAAAAAHc/m1eEEwL6kSc/s1600-h/girl.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 214px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SlIfwYEz1CI/AAAAAAAAAHc/m1eEEwL6kSc/s400/girl.jpg" alt="" id="BLOGGER_PHOTO_ID_5355377822853747746" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 2.&lt;/span&gt; &lt;span style="font-size:85%;"&gt;http://fourier.eng.hmc.edu/e161/lectures/contrast_transform/node3.html&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/SlIfmESDQBI/AAAAAAAAAHU/1DvljLmCWnU/s1600-h/soi1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 214px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/SlIfmESDQBI/AAAAAAAAAHU/1DvljLmCWnU/s400/soi1.jpg" alt="" id="BLOGGER_PHOTO_ID_5355377645741883410" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 3.&lt;/span&gt; &lt;span style="font-size:85%;"&gt;http://homepages.inf.ed.ac.uk/rbf/HIPR2/histeq.htm&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;As an additional exercise, we were asked to create a CDF that can mimic the human eye response, which is nonlinear. I chose the logarithmic function to do this and the third row of the figures above shows the new image after the transformation. This time, the equation used is Pixel Value = EXP(LOG(256)*CDF Value) instead of the equation of the line to generate the new image. Note: Logarithmic is used in converting pixel value to CDF value, so, exponential must be used for CDF value to pixel value. It can be seen that image is now relatively darker as compared to the histogram-equalized image. The histogram is more or less uniform in the available range of values (widely distributed) but it also peaks on the dark portions (extremely low pixel values). This explains why the image is darker although the contrast of the image is still enhanced. The result makes sense since the mapping CDF used, which is logarithmic, is a function that discriminates brightness. As you can see in the generated CDF plot, the CDF value rapidly increases for low pixel vales and then the increase slows down at higher values.&lt;br /&gt;Another nonlinear functions can be used to mimic human eye response like Gaussian. It is possible that these functions have a better effect in the image after transformation.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;I would give myself a grade of 10 for this activity because I believe I performed well in enhancing a poorly contrasted image depending on the function (linear and logarithmic) used, as well as creating a histogram and CDF plot of the image. I am proud of myself because I was able to create a program with not much help from others.  I would like to thank Mr. Luis C. Buno III, Mr. Jaya Combinido, Ms. Cherry Palomero, Mr. Miguel Sison and Mr. Jayson Villangca for answering some of my questions, which helped me a lot in successfully doing this activity.&lt;br /&gt;&lt;br /&gt;Reference: Image Processing by Tinku Acharya and Ajoy K. Ray&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;/div&gt;&lt;div style="text-align: center;" id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-2748226992336498925?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/2748226992336498925/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/07/activity-4-enhancement-by-histogram.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/2748226992336498925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/2748226992336498925'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/07/activity-4-enhancement-by-histogram.html' title='ACTIVITY 4 Enhancement by Histogram Manipulation'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_EPNyhV1xE8I/SlIe_OGMeuI/AAAAAAAAAHI/I0lysECSuI4/s72-c/moo2.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-1898395051181248024</id><published>2009-06-29T11:22:00.000-07:00</published><updated>2009-06-30T05:30:34.936-07:00</updated><title type='text'>ACTIVITY 2 Area Estimation for Images with Defined Edges</title><content type='html'>&lt;div style="text-align: justify;"&gt;For this activity, the area of several shapes (shown below) with defined edges was calculated both analytically and using Green's theorem. The area was calculated analytically using the known formulas for computing the area of regular polygons, i.e. circle, rectangle, triangle and trapezoid. Some of the shapes below are formed by combining the different regular polygons. Arrow = triangle + rectangle; Heart = 3 triangles; letter T = 2 rectangles. The area of these shapes were calculated by simply adding the area of the regular polygons forming the shapes. The dimensions (length/width/height) of the shapes were determined by counting the number of pixels along the border. Consider the rectangle in Figure 2 as an example. By knowing the pixel coordinates of the corners, it would now be easy to determine the dimensions of the rectangle.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Length = (192-57) + 1&lt;br /&gt;Width = (145-55) +1&lt;br /&gt;&lt;br /&gt;Area = Length x Width = 136 x 91 = 12376&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/SkkI_iFWkII/AAAAAAAAAEo/SisdL_6yx-Q/s1600-h/used.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 202px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/SkkI_iFWkII/AAAAAAAAAEo/SisdL_6yx-Q/s320/used.jpg" alt="" id="BLOGGER_PHOTO_ID_5352819519680581762" border="0" /&gt;&lt;/a&gt;&lt;a style="color: rgb(255, 255, 255);" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SkkQ7MCBPVI/AAAAAAAAAEw/uy2Ontvaq7U/s1600-h/square1.jpg"&gt;Figure 1.&lt;/a&gt; Arrow, circle, heart, triangle, letter T, rectangle, trapezoid.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SkkQ7MCBPVI/AAAAAAAAAEw/uy2Ontvaq7U/s1600-h/square1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 253px; height: 215px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SkkQ7MCBPVI/AAAAAAAAAEw/uy2Ontvaq7U/s320/square1.jpg" alt="" id="BLOGGER_PHOTO_ID_5352828241134566738" border="0" /&gt;&lt;/a&gt;Figure 2. This was done using Paint, zoomed to 800%.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Below is the programming code used to calculate the area of the shapes using Green's theorem. The Green's formula in discrete form used for computing the area of enclosed regions is given below. (x,y) are the coordinates of the points along the contour line bordering the region.&lt;img src="file:///C:/Users/Winsome/AppData/Local/Temp/moz-screenshot.jpg" alt="" /&gt;&lt;img src="file:///C:/Users/Winsome/AppData/Local/Temp/moz-screenshot-1.jpg" alt="" /&gt;&lt;img src="file:///C:/Users/Winsome/AppData/Local/Temp/moz-screenshot-2.jpg" alt="" /&gt; If it is already the last coordinate, then it must be multiplied to first coordinate to be able to close the contour line, a requirement for Green's theorem.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SkmtocgWCMI/AAAAAAAAAE4/ddo_tbaou9Q/s1600-h/eqn.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 214px; height: 69px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SkmtocgWCMI/AAAAAAAAAE4/ddo_tbaou9Q/s320/eqn.jpg" alt="" id="BLOGGER_PHOTO_ID_5353000542464772290" border="0" /&gt;&lt;/a&gt;Since the image used is in JPEG format, it has to be binarized first, i.e. in terms of 1's and 0's only (see line 2). Line 4 of the code traces the the contour of the shape and outputs the pixel coordinates along the contour line. Lines 6-13 is the code for the Green's formula. Another way of checking if the calculated area is correct is by adding the 1s in the binarized image (see line 14). However, it must be noted that the outermost pixels or portion of the white area is used as the boundary/contour line of the region. This means the two calculated areas, from Green's theorem (area 1) and by summing the 1s (area 2), can never be equal. To account for this error, the number of points along the boundary (size of the output of line 2) is added to area 1. When this is done, area 1 now becomes greater than area 2. But if only half of the size + 1 is added, the calculated areas are now equal. (+1) can be explained by looking at the plot of the points along the contour line (see Figure 3). It can be observed that the curve is not closed, lacking one point/pixel.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style="font-size:85%;"&gt;1    image = imread('F:\Documents\AP186\activity 2 &amp;amp; 3\pics\arrow.jpg');&lt;br /&gt;2    binarized_image = im2bw(image,0.5);&lt;br /&gt;3    imshow(binarized_image)&lt;br /&gt;4    [x, y] = follow(binarized_image);&lt;br /&gt;5    plot2d(x,y)&lt;br /&gt;6    s = size([x,y]);&lt;br /&gt;7    xi = [x(1:s(1)-1)];&lt;br /&gt;8    xi1 = [x(2:s(1))];&lt;br /&gt;9    yi = [y(1:s(1)-1)];&lt;br /&gt;10  yi1 = [y(2:s(1))];&lt;br /&gt;11  sum1 = sum(xi.*yi1) + x(s(1))*y(1);&lt;br /&gt;12  sum2 = sum(xi1.*yi) + x(1)*y(s(1));&lt;br /&gt;13  area 1 = 0.5*(sum1-sum2) + 0.5*s(1) + 1&lt;br /&gt;14  area 2 = sum(binarized_image)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SkoAm3dlafI/AAAAAAAAAFA/Ag-Fc0nGl2c/s1600-h/plot2d.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 250px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SkoAm3dlafI/AAAAAAAAAFA/Ag-Fc0nGl2c/s320/plot2d.jpg" alt="" id="BLOGGER_PHOTO_ID_5353091774806321650" border="0" /&gt;&lt;/a&gt;Figure 3.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;img src="file:///C:/Users/Winsome/AppData/Local/Temp/moz-screenshot-3.jpg" alt="" /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SkkGrQUYyBI/AAAAAAAAAEg/JMxysV3zP7k/s1600-h/table.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 404px; height: 214px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SkkGrQUYyBI/AAAAAAAAAEg/JMxysV3zP7k/s320/table.png" alt="" id="BLOGGER_PHOTO_ID_5352816972291164178" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The table above lists the shapes used and their area calculated analytically, using Green's theorem and by summing the 1s. The % error is very very small, so it means the code above is highly accurate in calculating the area of shapes with defined edges. There is still error probably because, although defined, the edges are still pixelated.&lt;br /&gt;&lt;br /&gt;I would give myself a grade of 9 for this activity because I was able to calculate the area of 7 shapes. Not perfect score because I cannot explain why only half the size of the border points has to be added.&lt;br /&gt;&lt;br /&gt;I would like to thank Mr. Luis Buno III, Mr. Miguel Sison and Ms. Jaziel Vitug for  answering some of my questions.&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;/div&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-1898395051181248024?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/1898395051181248024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/06/activity-2-area-estimation-for-images.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/1898395051181248024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/1898395051181248024'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/06/activity-2-area-estimation-for-images.html' title='ACTIVITY 2 Area Estimation for Images with Defined Edges'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkkI_iFWkII/AAAAAAAAAEo/SisdL_6yx-Q/s72-c/used.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-6326950563802021703</id><published>2009-06-22T20:23:00.001-07:00</published><updated>2009-07-09T10:56:57.812-07:00</updated><title type='text'>ACTIVITY 3 Image Types and Basic Image Enhancement</title><content type='html'>There are four basic image types: truecolor, grayscale, indexed and binary. Below are examples of each of the image types. We checked the image type by looking at the bit depth in its properties when we right click the image. If the bit depth is 8 and the image is black and white, then it is a grayscale image. If the image has many colors, then it must be an indexed image. For truecolor images, their bit depth would be greater than 8. Moreover, the image is binary if the bit depth is 1.&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 320px; display: block; height: 213px; cursor: pointer;" id="BLOGGER_PHOTO_ID_5350362647593777074" alt="" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SkBOewVYd7I/AAAAAAAAABU/WDbS2soQDyA/s320/burrowingowl20.jpg" border="0" /&gt;Figure 1. Truecolor Image&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style="font-size:85%;"&gt;http://home.earthlink.net/~richditch/images/burrowingowl20.jpg&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/SlYZFmDtKEI/AAAAAAAAALs/XJoHofl4YLg/s1600-h/girl.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 256px; height: 256px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/SlYZFmDtKEI/AAAAAAAAALs/XJoHofl4YLg/s400/girl.jpg" alt="" id="BLOGGER_PHOTO_ID_5356496390709913666" border="0" /&gt;&lt;/a&gt;Figure 2. Grayscale Image&lt;br /&gt;&lt;span style="font-size:85%;"&gt;http://fourier.eng.hmc.edu/e161/lectures/contrast_transform/node3.html&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBLiGUREVI/AAAAAAAAAAk/LlTJ7C7GSp8/s1600-h/tut5.gif"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 147px; display: block; height: 147px; cursor: pointer;" id="BLOGGER_PHOTO_ID_5350359406499402066" alt="" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBLiGUREVI/AAAAAAAAAAk/LlTJ7C7GSp8/s320/tut5.gif" border="0" /&gt;&lt;/a&gt;Figure 3. Indexed Image&lt;br /&gt;&lt;span style="font-size:85%;"&gt;http://www.creative-flow.net/tut5.gif&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_EPNyhV1xE8I/SlYadY_DdLI/AAAAAAAAAL0/KXka9lqxDl0/s1600-h/Neighborhood_watch_bw.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 200px; height: 140px;" src="http://1.bp.blogspot.com/_EPNyhV1xE8I/SlYadY_DdLI/AAAAAAAAAL0/KXka9lqxDl0/s400/Neighborhood_watch_bw.png" alt="" id="BLOGGER_PHOTO_ID_5356497899029230770" border="0" /&gt;&lt;/a&gt;Figure 4. Binary Image&lt;br /&gt;&lt;span style="font-size:85%;"&gt;http://en.wikipedia.org/wiki/File:Neighborhood_watch_bw.png&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Shown below in Figure 5 is a grayscale image and we want to determine the area of the apple in the image. Looking at the histogram in Figure 6, we can say that our region of interest (ROI) is well separated from its  background. Therefore, we can use the programming code generated in activity 2 to calculate the area of the apple. The detailed description of the method can be found in the previous blog. Recall that it uses discrete Green's theorem for computing the area of any enclosed region. Before proceeding, we have to convert first the grayscale image into a binary image (in terms of 1's and 0's only) using the function im2bw(). The threshold value to be used in the conversion must be properly chosen to ensure that only the ROI will be in 1's (white). Looking again at the histogram of the image, we see that or ROI has pixel values ranging from ~150 to ~256. The ratio of this is 0.68, so we used 0.65 as our threshold value. Figure 7 shows the contour traced in the image, which was used in implementing Green's theorem. The area calculated by the program is 2871. We validated it by summing the 1s in the binary image and we got the same result. Therefore, we are successful in calculating the area of the apple.  We have also shown in the previous blog that the method we used is accurate to about 1%. And for this, I would give myself a grade of 9. Just 9 because I was super late already in finishing this activity.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_EPNyhV1xE8I/SlYiamunOlI/AAAAAAAAAMM/HQ9AYd4cu74/s1600-h/image.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 256px; height: 192px;" src="http://2.bp.blogspot.com/_EPNyhV1xE8I/SlYiamunOlI/AAAAAAAAAMM/HQ9AYd4cu74/s400/image.bmp" alt="" id="BLOGGER_PHOTO_ID_5356506647271782994" border="0" /&gt;&lt;/a&gt;Figure 5. Grayscale image&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SlYiaN7uFPI/AAAAAAAAAME/6pnJreqqWUs/s1600-h/histogram.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 302px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SlYiaN7uFPI/AAAAAAAAAME/6pnJreqqWUs/s400/histogram.bmp" alt="" id="BLOGGER_PHOTO_ID_5356506640615871730" border="0" /&gt;&lt;/a&gt;Figure 6. Histogram of the grayscale image.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_EPNyhV1xE8I/SlYiZqQBG9I/AAAAAAAAAL8/_6hBo6v1o7I/s1600-h/follow.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 302px;" src="http://4.bp.blogspot.com/_EPNyhV1xE8I/SlYiZqQBG9I/AAAAAAAAAL8/_6hBo6v1o7I/s400/follow.bmp" alt="" id="BLOGGER_PHOTO_ID_5356506631037328338" border="0" /&gt;&lt;/a&gt;Figure 7. Contour of our ROI, i.e. apple.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;I would like to thank Mr. Luis Buno III and Mr. Miguel Sison for their help..&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-6326950563802021703?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/6326950563802021703/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/06/images.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/6326950563802021703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/6326950563802021703'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/06/images.html' title='ACTIVITY 3 Image Types and Basic Image Enhancement'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_EPNyhV1xE8I/SkBOewVYd7I/AAAAAAAAABU/WDbS2soQDyA/s72-c/burrowingowl20.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-1105951342914927314</id><published>2009-06-17T21:19:00.000-07:00</published><updated>2009-06-22T08:21:46.517-07:00</updated><title type='text'>ACTIVITY 1: DIGITAL SCANNING</title><content type='html'>&lt;div style="text-align: justify;"&gt;This activity is designed to experience how measurement of the actual dimension of the object is being done given only the image of the object. By knowing the relationship between the pixel location in the image and the physical variable, one can already tell the object's actual length. This method is not easy and erroneous but I guess it is the simplest technique for a rough estimation. &lt;br /&gt;&lt;br /&gt;I got the graph I used from a paper entitled Electrolytic Determination and Separations with the Use of a Rotating Anode from The Journal of American Chemical Society Volume XXIX of 1907 (January 25 1907). Thanks to the author of the paper, Julia Langness, for this graph.&lt;br /&gt;&lt;br /&gt;Thanks to Mr. Luis C. Buno III for helping me in rotating the image using MATLAB and answering some of my questions. The image had to be rotated since the scanned image is tilted.&lt;br /&gt;&lt;br /&gt;Hand-drawn graphs are indeed difficult to reconstruct. The gridlines of the graph are unevenly thick and not aligned, thus, unevenly spaced. Due to this problem, the determination of the the equivalent pixel location in the image of a point in the graph is very much prone to error. The table below shows the pixel location of the ticks in the X-axis (Minutes) and the Y-axis (Grams). It can be seen that the difference between two consecutive ticks in the X-axis greatly varies ranging from 103 to 115, a very large deviation by 12. The same deviation in the Y-axis can be observed. To minimize the error due to the large deviation in reconstructing the gridlines of the graph, the mean of the differences was used.&lt;br /&gt;&lt;br /&gt;By the way, the pixel location of the ticks in both axes was determined using the Paint program and then tabulated using Microsoft Excel. Instructions for determining the pixel location can be found in the manual for this activity.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/SjnEk3E8I3I/AAAAAAAAAAM/20hJ8w7LcdA/s1600-h/Picture1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 318px; height: 320px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/SjnEk3E8I3I/AAAAAAAAAAM/20hJ8w7LcdA/s320/Picture1.jpg" alt="" id="BLOGGER_PHOTO_ID_5348522170018177906" border="0" /&gt;&lt;/a&gt;Equations relating the pixel location to the physical variable in both axes were established. The proportionality factor was obtained by getting the ratio of the increment per division to the mean difference. It must be noted that the origin of the graph does not correspond to the (0,0) pixel location of the image. To account for this offset, the (X,Y) pixel location of the origin was subtracted from/to the pixel location of the points in the graph. Hence, the equations are the following:&lt;br /&gt;&lt;br /&gt;X-axis: minutes = 2*(1355-x)/113&lt;br /&gt;Y-axis: grams = 0.05*(y-67)/109&lt;br /&gt;&lt;br /&gt;Several points to represent the best fit line, including the data points, were selected to be able to create a smooth reconstructed curve. The pixel location of each of these points were determined. The reconstruction of the graph was done by converting the pixel locations back into their equivalent physical values using the generated equations.&lt;br /&gt;Note that the best fit line is also unevenly thick, so this introduces additional error.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The fun part in this activity was determining the pixel locations in the image of the points in the graph. Wait, was it really fun? hhhhmmmm... Yeah, I had fun especially because this is the first activity. But, it was also tiresome.. :( and painful to my eyes since I had to stare for so long at the computer. The frustrating part, on the other hand, was the next thing to be done. That is, overlaying the image of the graph on the reconstructed graph It wasn't supposed to be frustrating but I wasn't able to find out immediately how to overlay the image. And my seatmate was done already. Time was past 11am. Our class is until 11:30am only. So, I became a 'lil bit' fidgety. Thanks to the power of Google, I figured it out how to overlay an image as a background on a chart.&lt;br /&gt;&lt;br /&gt;To overlay an image in a chart using Excel, the following must be done:&lt;br /&gt;Go to Format Plot Area. Probably by pointing the mouse to the Plot Area and then right click.&lt;br /&gt;Then, in the Fill tab, choose the option Picture or texture fill. Insert the image you want to overlay.&lt;br /&gt;&lt;br /&gt;Below is the figure of the reconstructed graph with the original graph overlaid on it. The gridlines, as well as the reconstructed curve, were made thicker to compensate the errors (uneven thickness of the lines in the original graph) that were introduced above. It must be noted that the original graph has to be cropped properly so that it fits, more or less, the reconstructed graph.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_EPNyhV1xE8I/Sjnf33Z4QlI/AAAAAAAAAAc/Wa8f6Q8cWzY/s1600-h/reconstructed.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 267px;" src="http://3.bp.blogspot.com/_EPNyhV1xE8I/Sjnf33Z4QlI/AAAAAAAAAAc/Wa8f6Q8cWzY/s400/reconstructed.jpg" alt="" id="BLOGGER_PHOTO_ID_5348552183337468498" border="0" /&gt;&lt;/a&gt;Looking at the figure above, it can be seen that the graph is not perfectly reconstructed. Some of the reconstructed and original gridlines do not coincide. Same also with the curve and the data points. The reasons for this are already explained above. It is because the gridlines are unevenly thick and unevenly spaced.&lt;br /&gt;The author of this paper is probably better in drawing horizontal lines than vertical lines. :) As you can see above, more vertical gridlines are inclined.&lt;br /&gt;&lt;br /&gt;Although I was not able to perfectly reconstruct the graph, which isn't my fault (hehehe), I think I still deserve a grade of 9. :) Why? I didn't finish it on time but I believe I did this activity correctly as I have explained what I did above.&lt;br /&gt;&lt;br /&gt;Guys, please comment!!! :) Tell me what you think about what I did and what I said above.&lt;br /&gt;&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;/div&gt;&lt;div style="text-align: justify;" id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-1105951342914927314?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/1105951342914927314/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/06/this-activity-is-fun-although-little.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/1105951342914927314'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/1105951342914927314'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/06/this-activity-is-fun-although-little.html' title='ACTIVITY 1: DIGITAL SCANNING'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_EPNyhV1xE8I/SjnEk3E8I3I/AAAAAAAAAAM/20hJ8w7LcdA/s72-c/Picture1.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7918007414439081515.post-8949742880290186335</id><published>2009-06-15T19:58:00.000-07:00</published><updated>2009-06-15T20:08:11.135-07:00</updated><title type='text'>why WANNA EAT SIX KAMATIS????</title><content type='html'>WANNA - &lt;span style="font-size:180%;"&gt;&lt;span style="font-weight: bold;"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;na&lt;/span&gt;&lt;br /&gt;EAT - &lt;span style="font-size:180%;"&gt;&lt;span style="font-weight: bold;"&gt;8&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;SIX - &lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:180%;"&gt;6&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;KAMATIS - wala lang, yun kasi naisip ni thirdy&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;===&gt; &lt;/span&gt;ito ang title ko dahil ang blog na 'to ay para sa Applied Physics &lt;span style="font-size:180%;"&gt;&lt;span style="font-weight: bold;"&gt;186&lt;/span&gt;&lt;/span&gt; class namin...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7918007414439081515-8949742880290186335?l=winsomerara.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://winsomerara.blogspot.com/feeds/8949742880290186335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://winsomerara.blogspot.com/2009/06/why-wanna-eat-six-kamatis.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/8949742880290186335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7918007414439081515/posts/default/8949742880290186335'/><link rel='alternate' type='text/html' href='http://winsomerara.blogspot.com/2009/06/why-wanna-eat-six-kamatis.html' title='why WANNA EAT SIX KAMATIS????'/><author><name>Winsome Chloe Rara</name><uri>http://www.blogger.com/profile/12535208328329138756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='25' src='http://4.bp.blogspot.com/_EPNyhV1xE8I/SkBm59E2icI/AAAAAAAAACI/U5-A_pZskXw/S220/P5174745.JPG'/></author><thr:total>0</thr:total></entry></feed>
