<?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-7546939043065849431</id><updated>2012-02-16T18:56:37.473-08:00</updated><title type='text'>ap186 blog ni momoy...</title><subtitle type='html'>get h1n1 online ;p ..... reading entries = getting "the virus" for free :D</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-8125510297824066224</id><published>2009-10-12T03:17:00.000-07:00</published><updated>2009-10-12T07:57:54.540-07:00</updated><title type='text'>Activity 19: Restoration of Blurred Image</title><content type='html'>In this activity, we will apply Weiner filtering to restore an image of known degradation (in this case, blur) and additive noise. The process we followed for this activity is shown below:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/StM4l3S5W3I/AAAAAAAAAew/h73wiH9ZH7U/s1600-h/3.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 135px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/StM4l3S5W3I/AAAAAAAAAew/h73wiH9ZH7U/s400/3.png" alt="" id="BLOGGER_PHOTO_ID_5391715402042137458" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;In the Fourier space, this can be written as&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/StM5Rz3rTJI/AAAAAAAAAe4/fo1C8PoGEXI/s1600-h/4.png"&gt;&lt;img style="cursor: pointer; width: 276px; height: 36px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/StM5Rz3rTJI/AAAAAAAAAe4/fo1C8PoGEXI/s400/4.png" alt="" id="BLOGGER_PHOTO_ID_5391716157036907666" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;where G, H, F, and N are the Fourier transforms of g (resulting blurry image), h (spatial degradation function), f (original image) , and n (noise), respectively. H is also given as&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/StM63hWIySI/AAAAAAAAAfA/LKOMaxIpgXE/s1600-h/5.png"&gt;&lt;img style="cursor: pointer; width: 391px; height: 80px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/StM63hWIySI/AAAAAAAAAfA/LKOMaxIpgXE/s400/5.png" alt="" id="BLOGGER_PHOTO_ID_5391717904411052322" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The original image and the resulting blurry image are shown below. Note that for this blurry image, I used a = b =0.1and T =1.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/StM2nFKsefI/AAAAAAAAAeo/Fr8nXf7WGh0/s1600-h/gray2.jpg"&gt;&lt;img style="cursor: pointer; width: 306px; height: 265px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/StM2nFKsefI/AAAAAAAAAeo/Fr8nXf7WGh0/s400/gray2.jpg" alt="" id="BLOGGER_PHOTO_ID_5391713223922448882" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/StM2mjZ3wyI/AAAAAAAAAeg/VZocAgd76fE/s1600-h/blur.bmp"&gt;&lt;img style="cursor: pointer; width: 306px; height: 265px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/StM2mjZ3wyI/AAAAAAAAAeg/VZocAgd76fE/s400/blur.bmp" alt="" id="BLOGGER_PHOTO_ID_5391713214859297570" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To restore the image, we use the Weiner filter given below:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/StM7YlBqH-I/AAAAAAAAAfI/NQaLTtAUQQM/s1600-h/6.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 83px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/StM7YlBqH-I/AAAAAAAAAfI/NQaLTtAUQQM/s400/6.png" alt="" id="BLOGGER_PHOTO_ID_5391718472334581730" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;with&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/StM7m3pxYMI/AAAAAAAAAfQ/T7itgveD-To/s1600-h/7.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 91px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/StM7m3pxYMI/AAAAAAAAAfQ/T7itgveD-To/s400/7.png" alt="" id="BLOGGER_PHOTO_ID_5391718717852836034" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/StM74GYXWKI/AAAAAAAAAfY/_IKzIdWSpYA/s1600-h/8.png"&gt;&lt;img style="cursor: pointer; width: 328px; height: 73px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/StM74GYXWKI/AAAAAAAAAfY/_IKzIdWSpYA/s400/8.png" alt="" id="BLOGGER_PHOTO_ID_5391719013864134818" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;where K is a specified constant.&lt;br /&gt;&lt;br /&gt;For this activity, I used both equations. For the first equation, the result is shown below. Notice that improved image was obtained.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/StNB7C8jylI/AAAAAAAAAfo/4NBmDrQVEAM/s1600-h/restore.bmp"&gt;&lt;img style="cursor: pointer; width: 306px; height: 265px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/StNB7C8jylI/AAAAAAAAAfo/4NBmDrQVEAM/s400/restore.bmp" alt="" id="BLOGGER_PHOTO_ID_5391725661551577682" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;For the second equation (with different K values), the results are shown below:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/StNB6z76wSI/AAAAAAAAAfg/sUYALbKYlkI/s1600-h/10.png"&gt;&lt;img style="cursor: pointer; width: 394px; height: 400px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/StNB6z76wSI/AAAAAAAAAfg/sUYALbKYlkI/s400/10.png" alt="" id="BLOGGER_PHOTO_ID_5391725657522356514" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Notice that for this particular image, the minimal blur was obtained with K = 0.001, 0.005, 0.01, and 0.05. For higher K values, the blur is clearly seen.&lt;br /&gt;&lt;br /&gt;For this activity, I give myself a 10/10 for meeting the primary objectives of the activity. Thank you to Gilbert for the insights. ^__^&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-8125510297824066224?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/8125510297824066224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/10/activity-19-restoration-of-blurred.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/8125510297824066224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/8125510297824066224'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/10/activity-19-restoration-of-blurred.html' title='Activity 19: Restoration of Blurred Image'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_6vBS5HyEno4/StM4l3S5W3I/AAAAAAAAAew/h73wiH9ZH7U/s72-c/3.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-8332477966054668013</id><published>2009-09-16T18:39:00.000-07:00</published><updated>2009-10-12T09:00:40.925-07:00</updated><title type='text'>Activity 18: Noise Model and Basic Image Restoration</title><content type='html'>In this activity, we are to model noise on a three-value grayscale image and restore those images using different filters.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;NOISE MODEL&lt;br /&gt;&lt;br /&gt;The noise model used were Gaussian, Rayleigh, Erlang or Gamma, Exponential, Uniform, and the Impluse or Salt and Pepper noise, the probability distribution function of each are shown below:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/StNQg62hHTI/AAAAAAAAAgo/z9i8UhPmcfU/s1600-h/15.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 391px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/StNQg62hHTI/AAAAAAAAAgo/z9i8UhPmcfU/s400/15.png" alt="" id="BLOGGER_PHOTO_ID_5391741705376570674" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/StNQgVlMctI/AAAAAAAAAgg/WbjJv2pyqiU/s1600-h/16.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 370px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/StNQgVlMctI/AAAAAAAAAgg/WbjJv2pyqiU/s400/16.png" alt="" id="BLOGGER_PHOTO_ID_5391741695371801298" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Rayleigh Noise was modeled using the genrayl function in the modnum toolbox. Salt and Pepper Noise was modeled using the function imnoise and the rest were modeled using the function grand. To verify the added noise, we examined the histogram of each resulting image. It is expected that the histogram follows the shape of the noise added and since we have 3 grayscale values, we will see 3 peaks depending on the parameters used and the interval between the grayscale values. Note that a convolution of the 3 peaks will be observed for smaller grayscale value intervals. Shown below are the histogram of the original image and the images with noise and the corresponding images on the inset.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/StNQ_7mMUOI/AAAAAAAAAg4/eMkdcbUaoMA/s1600-h/p1.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 332px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/StNQ_7mMUOI/AAAAAAAAAg4/eMkdcbUaoMA/s400/p1.png" alt="" id="BLOGGER_PHOTO_ID_5391742238152478946" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/StNQ_XPX2rI/AAAAAAAAAgw/8lkXu1tMiZ0/s1600-h/p2.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 316px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/StNQ_XPX2rI/AAAAAAAAAgw/8lkXu1tMiZ0/s400/p2.png" alt="" id="BLOGGER_PHOTO_ID_5391742228393089714" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;IMAGE RESTORATION&lt;br /&gt;&lt;br /&gt;After noise modeling, we restore the images by using different filters. We apply the filters to mxn (3x3, for my case) subimage window gi centered at point (x , y) and let it run through the whole image. Four filters were used in this activity and these are shown below:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/StNRbB-dNNI/AAAAAAAAAhA/WktwBY2Bhj0/s1600-h/9.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 359px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/StNRbB-dNNI/AAAAAAAAAhA/WktwBY2Bhj0/s400/9.png" alt="" id="BLOGGER_PHOTO_ID_5391742703721329874" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Applying the above filters (in order as that above), the following images resulted:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/StNR5-gu1VI/AAAAAAAAAhY/Ro7kLu_tmiI/s1600-h/11.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 329px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/StNR5-gu1VI/AAAAAAAAAhY/Ro7kLu_tmiI/s400/11.png" alt="" id="BLOGGER_PHOTO_ID_5391743235367294290" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/StNR5QGNmHI/AAAAAAAAAhQ/EduzGtR-8LY/s1600-h/12.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 235px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/StNR5QGNmHI/AAAAAAAAAhQ/EduzGtR-8LY/s400/12.png" alt="" id="BLOGGER_PHOTO_ID_5391743222908033138" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Salt and Pepper&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/StNR4_yzM8I/AAAAAAAAAhI/edF6eqBlUK0/s1600-h/13.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 193px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/StNR4_yzM8I/AAAAAAAAAhI/edF6eqBlUK0/s400/13.png" alt="" id="BLOGGER_PHOTO_ID_5391743218531644354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/StNSZRV2jdI/AAAAAAAAAhg/9QdkrIkE43Q/s1600-h/14.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 200px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/StNSZRV2jdI/AAAAAAAAAhg/9QdkrIkE43Q/s400/14.png" alt="" id="BLOGGER_PHOTO_ID_5391743772997881298" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It is seen that Q&gt;0 in the contraharmonic filter indeed minimizes pepper noise more, Q&lt;0 eliminates the salt noise more, and Q=0 minimizes both salt and pepper noise. For this activity, I give myself a 10/10 since the objectives of the activity were met. Thanks to Jaya for helping me debug my code and Gilbert and Earl for the help.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-8332477966054668013?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/8332477966054668013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/09/activity-18-noise-model-and-basic-image.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/8332477966054668013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/8332477966054668013'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/09/activity-18-noise-model-and-basic-image.html' title='Activity 18: Noise Model and Basic Image Restoration'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_6vBS5HyEno4/StNQg62hHTI/AAAAAAAAAgo/z9i8UhPmcfU/s72-c/15.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-4715590242524916145</id><published>2009-09-11T19:29:00.000-07:00</published><updated>2009-09-11T20:35:28.029-07:00</updated><title type='text'>Activity 17: Photometric Stereo</title><content type='html'>For this activity, we are to reconstruct a 3d image from a 2d image taken at different positions of the point source.  The images used together with the location of the point source are shown below:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/SqsN1TVGvjI/AAAAAAAAAUQ/NEp7NirP910/s1600-h/pektyur.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 247px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/SqsN1TVGvjI/AAAAAAAAAUQ/NEp7NirP910/s400/pektyur.bmp" alt="" id="BLOGGER_PHOTO_ID_5380409389197213234" border="0" /&gt;&lt;/a&gt;From these 2d images, we will get the depth (z axis) of the images and construct a 3d image. To do this, we consider the intensity of the images are directly proportional to the brightness at that point.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/SqsQZUQm4EI/AAAAAAAAAUY/twQwtc0DzLM/s1600-h/intensity.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 69px; height: 33px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/SqsQZUQm4EI/AAAAAAAAAUY/twQwtc0DzLM/s400/intensity.bmp" alt="" id="BLOGGER_PHOTO_ID_5380412206945329218" border="0" /&gt;&lt;/a&gt;where&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SqsQpsrAduI/AAAAAAAAAUg/n0XZMZ5NfXU/s1600-h/v.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 79px; height: 33px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SqsQpsrAduI/AAAAAAAAAUg/n0XZMZ5NfXU/s400/v.bmp" alt="" id="BLOGGER_PHOTO_ID_5380412488376415970" border="0" /&gt;&lt;/a&gt;and S1 is the position of the point source.&lt;br /&gt;&lt;br /&gt;I and V are known from the 2d images. To compute for&lt;span style="font-weight: bold;"&gt; g&lt;/span&gt; we use&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SqsR_rHgsHI/AAAAAAAAAUo/S725V1YIyuU/s1600-h/g.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 147px; height: 32px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SqsR_rHgsHI/AAAAAAAAAUo/S725V1YIyuU/s400/g.bmp" alt="" id="BLOGGER_PHOTO_ID_5380413965427847282" border="0" /&gt;&lt;/a&gt;and then normalized it by dividing with its length. The resulting normal vectors, we can get the surface elevation.&lt;br /&gt;&lt;br /&gt;The resulting 3d image is shown below.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/SqsW0hs211I/AAAAAAAAAUw/aBmvIGsG9J8/s1600-h/plot.bmp"&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/_6vBS5HyEno4/SqsW0hs211I/AAAAAAAAAUw/aBmvIGsG9J8/s400/plot.bmp" alt="" id="BLOGGER_PHOTO_ID_5380419271479711570" border="0" /&gt;&lt;/a&gt;For this activity, I give myself a 10/10 since I was able to reconstruct a 3d image that is accurate enough :D&lt;br /&gt;&lt;br /&gt;Many thanks to Earl for helping me a lot in this activity.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-4715590242524916145?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/4715590242524916145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/09/activity-17-photometric-stereo.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/4715590242524916145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/4715590242524916145'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/09/activity-17-photometric-stereo.html' title='Activity 17: Photometric Stereo'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_6vBS5HyEno4/SqsN1TVGvjI/AAAAAAAAAUQ/NEp7NirP910/s72-c/pektyur.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-2119831054708849357</id><published>2009-09-11T07:59:00.000-07:00</published><updated>2009-09-11T19:27:54.351-07:00</updated><title type='text'>Activity 16: Neural Networks</title><content type='html'>For this activity, we again classify objects but this time using neural networks. A neural network consists of three parts - the input layer, hidden layer, and the output layer. For our purposes, the input layer consists of the features of the test objects, hidden layer consists of the features of the training objects, and the output layer is the classification of the input layer after it is compared with the hidden layer. In Scilab,to do the classification by neural networks, we need to load the ANN_toolbox and a code courtesy of Jeric Tugaff. The same features from the two previous activities were used in order to compare the efficiency of the techniques we have learned so far. It is imporatant to note that the features should be normalized to be able to classify objects using this method. After implementing the code to the test objects, the output are as follows:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/SqsF7vS5SfI/AAAAAAAAAUI/un3wutc4lVA/s1600-h/table.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 201px; height: 274px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/SqsF7vS5SfI/AAAAAAAAAUI/un3wutc4lVA/s400/table.bmp" alt="" id="BLOGGER_PHOTO_ID_5380400703690328562" border="0" /&gt;&lt;/a&gt;After rounding off the output of the program, we can see that we got a perfect classification. ^_^&lt;br /&gt;&lt;br /&gt;For this activity, I give myself a 10/10. Thank you to Gilbert for helping me in this activity.&lt;br /&gt;&lt;br /&gt;References:&lt;br /&gt;Maricor Soriano, PhD. Activity 16 - Neural Networks. AP 186 manual.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-2119831054708849357?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/2119831054708849357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/09/activity-16-neural-networks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/2119831054708849357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/2119831054708849357'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/09/activity-16-neural-networks.html' title='Activity 16: Neural Networks'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_6vBS5HyEno4/SqsF7vS5SfI/AAAAAAAAAUI/un3wutc4lVA/s72-c/table.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-6323139299212936812</id><published>2009-09-09T18:53:00.000-07:00</published><updated>2009-09-11T18:40:55.991-07:00</updated><title type='text'>Activity 15: Probabilistic Classification</title><content type='html'>In this activity, we again classify objects into classes but this time we will use probabilistic classification instead. Specifically, we used Linear Discriminant Analysis or LDA. LDA basically minimizes total error of classification by making the proportion of object that it misclassifies as small as possible [1]. It works by making the features within members of a class near each other and as far as possible to the features of another class. An object is classified into a class where the total error of classification is minimum. As what was done in the previous activity, predetermined features from objects of known classes were used.&lt;br /&gt;&lt;br /&gt;Four features were used in this activity. The area and the red, green and blue color from the  images. Recall that by using the Euclidian mean, poor classification was obtained for the red feature of the test objects. In this activity, two features are considered for classification. We expect a better classification using this method. The results obtained are as follows:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SqhjCPqd3jI/AAAAAAAAATo/gXNgRZn1IT8/s1600-h/table.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 223px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SqhjCPqd3jI/AAAAAAAAATo/gXNgRZn1IT8/s400/table.bmp" alt="" id="BLOGGER_PHOTO_ID_5379658645109595698" border="0" /&gt;&lt;/a&gt;A perfect classification resulted from this method and with these features. I tried using the blue and green feature for classification also. Recall from Activity 14 that the green feature gives poor classification and blue gives a perfect classification. The results are:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/Sqhq1hZN_HI/AAAAAAAAAUA/Nn6vP-rDwCw/s1600-h/table2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 163px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/Sqhq1hZN_HI/AAAAAAAAAUA/Nn6vP-rDwCw/s400/table2.bmp" alt="" id="BLOGGER_PHOTO_ID_5379667222623812722" border="0" /&gt;&lt;/a&gt;Also a perfect classification was obtained. However, when I tried to use the Red and Green feature, the same classification as that in Activity 14 was obtained. We can say that the red and green feature values of the beads and coins are near each other. Hence we cannot classify them perfectly using the said features. To compensate this, we can use a  feature that is distinct for each class and combine it with the problematic feature. This is the technique I have used and it worked.&lt;br /&gt;&lt;br /&gt;For this activity, I give myself a 10/10 for this activity for doing it alone and for being able to get a perfect classification.&lt;br /&gt;&lt;br /&gt;CODE:&lt;br /&gt;x=[214    0.58    0.54    0.45;&lt;br /&gt;236    0.6    0.56    0.46;&lt;br /&gt;308    0.62    0.56    0.49;&lt;br /&gt;322    0.63    0.56    0.5;&lt;br /&gt;293    0.63    0.56    0.5;&lt;br /&gt;2616    0.29    0.24    0.13;&lt;br /&gt;2604    0.35    0.31    0.14;&lt;br /&gt;2602    0.35    0.31    0.14;&lt;br /&gt;2589    0.29    0.25    0.13;&lt;br /&gt;2613    0.19    0.18    0.09];&lt;br /&gt;&lt;br /&gt;test = [247    0.57    0.52    0.44;&lt;br /&gt;208    0.54    0.51    0.42;&lt;br /&gt;192    0.55    0.53    0.43;&lt;br /&gt;194    0.52    0.5    0.41;&lt;br /&gt;193    0.52    0.5    0.41;&lt;br /&gt;2736    0.33    0.3    0.14;&lt;br /&gt;2835    0.43    0.4    0.2;&lt;br /&gt;2904    0.47    0.42    0.22;&lt;br /&gt;2925    0.47    0.42    0.24;&lt;br /&gt;2874    0.45    0.42    0.24];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;y=[    1    1    1    1    1    2    2    2    2    2];&lt;br /&gt;y=y';&lt;br /&gt;&lt;br /&gt;x1=x(1:5,:);&lt;br /&gt;x2=x(6:10,:);&lt;br /&gt;&lt;br /&gt;mu1 = [sum(x1(:,1))/5  sum(x1(:,2))/5];&lt;br /&gt;mu2 = [sum(x2(:,1))/5  sum(x2(:,2))/5];&lt;br /&gt;&lt;br /&gt;mu = [sum(x(:,1))/10  sum(x(:,2))/10];&lt;br /&gt;&lt;br /&gt;x1o=[x1(:,1)-mu(:,1)  x1(:,2)-mu(:,2)];&lt;br /&gt;x2o=[x2(:,1)-mu(:,1)  x2(:,2)-mu(:,2)];&lt;br /&gt;&lt;br /&gt;c1 = (x1o'*x1o)/5;&lt;br /&gt;c2 = (x2o'*x2o)/5;&lt;br /&gt;&lt;br /&gt;C=(c1*5 + c2*5)/10;&lt;br /&gt;Cinv = inv(C);&lt;br /&gt;&lt;br /&gt;p = [1/2; 1/2];&lt;br /&gt;&lt;br /&gt;f1=[];&lt;br /&gt;f2=[];&lt;br /&gt;&lt;br /&gt;for i = 1:10;&lt;br /&gt;  xk = test(i, :);&lt;br /&gt;  f1(i) = mu1*C*xk' - 0.5*mu1*C*mu1' + log(p(1));&lt;br /&gt;  f2(i) = mu2*C*xk' - 0.5*mu2*C*mu2' + log(p(2));&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;class = f1 - f2;&lt;br /&gt;class(class &gt;= 0) = 1;&lt;br /&gt;class(class &lt; 0) = 2;&lt;br /&gt;&lt;br /&gt;Reference:&lt;br /&gt;[1] http://people.revoledu.com/kardi/tutorial/LDA/LDA.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-6323139299212936812?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/6323139299212936812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/09/activity-15-probabilistic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/6323139299212936812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/6323139299212936812'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/09/activity-15-probabilistic.html' title='Activity 15: Probabilistic Classification'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_6vBS5HyEno4/SqhjCPqd3jI/AAAAAAAAATo/gXNgRZn1IT8/s72-c/table.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-9024360958091912670</id><published>2009-09-09T17:38:00.000-07:00</published><updated>2009-09-11T18:46:45.262-07:00</updated><title type='text'>Activity 14: Pattern recognition</title><content type='html'>In this activity, we are to classify objects to classes using the Euclidian mean approximation. A training set is used to extract certain features present in all the classes and is distinct within each class. The mean feature of the training set is used to classify objects of unknown class. The objects I used for this activity are beads from a rosary and  25-centavo coins. These are shown below.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/SqhNwBZX6qI/AAAAAAAAASw/4KSLND6CMLA/s1600-h/toots.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 265px; height: 400px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/SqhNwBZX6qI/AAAAAAAAASw/4KSLND6CMLA/s400/toots.JPG" alt="" id="BLOGGER_PHOTO_ID_5379635242297977506" border="0" /&gt;&lt;/a&gt;From this set of objects, 5 coins and 5 beads were used as a training set. To extract the features, I used parametric segmentation used in activity 12. The features extracted are the average red (R), green (G), and blue (B) color in the image. Also extracted was the area obtained from the segmented image by first inverting the image using GIMP and then binarizing it in Scilab. The resulting features and the mean features are shown in the table below.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SqhUbBx4lKI/AAAAAAAAAS4/IDXIB-K1vts/s1600-h/train.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 334px; height: 264px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SqhUbBx4lKI/AAAAAAAAAS4/IDXIB-K1vts/s400/train.bmp" alt="" id="BLOGGER_PHOTO_ID_5379642578204923042" border="0" /&gt;&lt;/a&gt;The remaining 5 images of each class were used as the test set. The same processes were done to extract the features of test objects. Afterwhich, the features from each objects were subtracted from the mean feature obtained in the training set. Specifically,&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/SqhVkm49V6I/AAAAAAAAATA/XrQI70he7I0/s1600-h/formula.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 334px; height: 47px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/SqhVkm49V6I/AAAAAAAAATA/XrQI70he7I0/s400/formula.bmp" alt="" id="BLOGGER_PHOTO_ID_5379643842297157538" border="0" /&gt;&lt;/a&gt;where Dj is the distance of one feature of the test object x from the mean feature mj of each class.&lt;br /&gt;&lt;br /&gt;An object is classified as the object in a class where Dj is minimum. The classification in this case was done in Excel. The results are as follows:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/SqhaPu_0XNI/AAAAAAAAATI/HrgqopEdzYM/s1600-h/area.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 192px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/SqhaPu_0XNI/AAAAAAAAATI/HrgqopEdzYM/s400/area.bmp" alt="" id="BLOGGER_PHOTO_ID_5379648981254298834" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SqhaTqi2TQI/AAAAAAAAATQ/RwSMzMbqQoQ/s1600-h/red.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 193px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SqhaTqi2TQI/AAAAAAAAATQ/RwSMzMbqQoQ/s400/red.bmp" alt="" id="BLOGGER_PHOTO_ID_5379649048778525954" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SqhaY7CVIlI/AAAAAAAAATY/SLT6MIScuM0/s1600-h/green.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 195px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SqhaY7CVIlI/AAAAAAAAATY/SLT6MIScuM0/s400/green.bmp" alt="" id="BLOGGER_PHOTO_ID_5379649139104883282" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SqhahsTKZ6I/AAAAAAAAATg/4u3SRtCPkg0/s1600-h/blue.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 193px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SqhahsTKZ6I/AAAAAAAAATg/4u3SRtCPkg0/s400/blue.bmp" alt="" id="BLOGGER_PHOTO_ID_5379649289767774114" border="0" /&gt;&lt;/a&gt;Note that 1 = bead and 2 = coin for the classification. From the tables, it can be readily seen that a 100% classification is obtained by examining the area and the blue color present in the images. For the green and red colors, poor classifcation was obtained. This is because the obtained red and green features from the test objects have almost nearvalues. We can conclude that classification by using the Euclidian mean is effective only to a certain extent.&lt;br /&gt;&lt;br /&gt;I give myself an 8/10 for this activity for poor classification from the red and green colors and for doing the acivity alone. ^_^&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-9024360958091912670?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/9024360958091912670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/09/activity-14-pattern-recognition.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/9024360958091912670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/9024360958091912670'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/09/activity-14-pattern-recognition.html' title='Activity 14: Pattern recognition'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_6vBS5HyEno4/SqhNwBZX6qI/AAAAAAAAASw/4KSLND6CMLA/s72-c/toots.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-864438510293515565</id><published>2009-08-06T18:37:00.000-07:00</published><updated>2009-08-06T19:44:39.314-07:00</updated><title type='text'>Activity 12: Color Image Segmentation</title><content type='html'>For&lt;span&gt;&lt;span&gt; this activity, we are to select a region in the image with a particular color.  First we have to transform the color space into a normalized chromaticity coordinates. To do this the following transformations are used:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SnuLJwPaJMI/AAAAAAAAARg/r4xMdwIQ_wI/s1600-h/eqn.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 256px; height: 50px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SnuLJwPaJMI/AAAAAAAAARg/r4xMdwIQ_wI/s400/eqn.bmp" alt="" id="BLOGGER_PHOTO_ID_5367036380626691266" border="0" /&gt;&lt;/a&gt;Since 1=r+g+b, b=1-r-g. Therefore we can transform the color space (3-D) into two coordinate space (2-D), with the brightness associated with I. The image and patch used is shown below:&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SnuMCtlAFHI/AAAAAAAAARo/sgJO2JZ2Cao/s1600-h/cups.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 282px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SnuMCtlAFHI/AAAAAAAAARo/sgJO2JZ2Cao/s400/cups.jpg" alt="" id="BLOGGER_PHOTO_ID_5367037359164494962" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt;(Image taken from&lt;/span&gt; &lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;http://www.magicbob2000.com/resources/Cups%20&amp;amp;%20Balls%20Blue.jpg&lt;/span&gt;&lt;/span&gt;)&lt;br /&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&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/_6vBS5HyEno4/SnuMi2bvapI/AAAAAAAAARw/O9NAE-MZhWA/s1600-h/patch.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 31px; height: 59px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SnuMi2bvapI/AAAAAAAAARw/O9NAE-MZhWA/s400/patch.JPG" alt="" id="BLOGGER_PHOTO_ID_5367037911297387154" border="0" /&gt;&lt;/a&gt;Patch&lt;br /&gt;&lt;/div&gt;&lt;br /&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;span&gt;Two methods were used in this activity - parametric and nonparametric. For parametric a Gaussian Probability Distribution is used. The equation of which is given by&lt;/span&gt;&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;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SnuPosaAVpI/AAAAAAAAAR4/dYu4yTIB-7E/s1600-h/eqn2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 181px; height: 59px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SnuPosaAVpI/AAAAAAAAAR4/dYu4yTIB-7E/s400/eqn2.bmp" alt="" id="BLOGGER_PHOTO_ID_5367041310219851410" border="0" /&gt;&lt;/a&gt;for the red values. The same is true for the green values (p(g)). The probability that a given pixel is inside the region of interest is dictated by prob=p(r)*p(g). For the nonparametric method, histogram backprojection is used. The pixel value in the histogram is used to backproject the value for a particular pixel. The histogram , result of parametric and nonparametric estimation of the image used is shown below:&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SnuRMEKNpFI/AAAAAAAAASA/t8lELGbC_co/s1600-h/hist.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/_6vBS5HyEno4/SnuRMEKNpFI/AAAAAAAAASA/t8lELGbC_co/s400/hist.bmp" alt="" id="BLOGGER_PHOTO_ID_5367043017403114578" border="0" /&gt;&lt;/a&gt;Histogram&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/_6vBS5HyEno4/SnuSLhUvp3I/AAAAAAAAASY/GlQ3hWo3M98/s1600-h/para.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 282px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SnuSLhUvp3I/AAAAAAAAASY/GlQ3hWo3M98/s400/para.bmp" alt="" id="BLOGGER_PHOTO_ID_5367044107563673458" border="0" /&gt;&lt;/a&gt;Parametric&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/_6vBS5HyEno4/SnuSYAah2jI/AAAAAAAAASg/VfmQdajhsI4/s1600-h/nonpara.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 281px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SnuSYAah2jI/AAAAAAAAASg/VfmQdajhsI4/s400/nonpara.bmp" alt="" id="BLOGGER_PHOTO_ID_5367044322067864114" border="0" /&gt;&lt;/a&gt;Nonparametric&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;Although both estimations would suffice, a better segmentation is achieved with parametric estimation. It is also interesting that even the red "thingy" is well seen for parametric estimation. For the image used, the objects were separated from the background and from each other. Note however that we are only interested in segmenting the blue cups. Strictly speaking we did not segment the red "thingy". It just so happened that the background is violet (both with red and blue) which are the colors of the object that is why a gray color can be observed. Recall that when segmenting, what happens is that the region of interest becomes white. Any other color has different value.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Code:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;stacksize(4e7);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;chdir("C:\Documents and Settings\mimie\Desktop\186-12");&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;patch = imread("patch.jpg");&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;image = imread("cups.jpg");&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;ave = patch(:,:,1)+patch(:,:,2)+patch(:,:,3)+1e-7;&lt;/span&gt;  &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;R = patch(:,:,1)./ave;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;G = patch(:,:,2)./ave;&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;B = patch(:,:,3)./ave;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;r = R*255;&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;g = G*255;&lt;/span&gt;  &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;&lt;br /&gt;ave2 = image(:,:,1)+image(:,:,2)+image(:,:,3)+1e-7;&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;r2 = image(:,:,1)./ave2;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;g2 = image(:,:,2)./ave2;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;b2 = image(:,:,3)./ave2;&lt;/span&gt;   &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;f = zeros(256,256);&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;for i=1:size(r,1)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;  for j=1:size(r,2)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    x = abs(round(r(i,j)))+1;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;y = abs(round(g(i,j)))+1;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    f(x,y) = f(x,y)+1;&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;end&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;//imshow((frequency+0.0000000001));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;//mesh(frequency);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;//xset("colormap",jetcolormap(256));&lt;/span&gt;  &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;&lt;br /&gt;\\\\parametric&lt;/span&gt;  &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;rmean = mean(R);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rdev = stdev(R);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;gmean = mean(G);&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;gdev = stdev(G);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rprob = (1/(rdev*sqrt(2*%pi)))*exp(-((r2-rmean).^2)/2*rdev);&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;gprob = (1/(gdev*sqrt(2*%pi)))*exp(-((g2-gmean).^2)/2*gdev);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;prob = rprob.*gprob;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;prob = prob/max(prob);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;scf(0); imshow(image);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;scf(1); imshow(prob,[]);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;\\\\nonparametric&lt;/span&gt;  &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;R2 = r2*255;&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;G2 = g2*255;&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;s = zeros(size(image,1),size(image,2));&lt;/span&gt;  &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;for i = 1:size(R2,1)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;for j = 1:size(R2,2)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;x = abs(round(R2(i,j)))+1;&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;y = round(G2(i,j))+1;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;s(i,j) = f(x,y);&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;end&lt;/span&gt;  &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;scf(1); imshow(log(s+0.000000000001),[]);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;scf(2); imshow(image);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Note:&lt;/span&gt;&lt;br /&gt;Comment the parametric to use nonparametric&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For this activity, I give myself an 8/10 since I'm not sure if I fully understand the activity.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-864438510293515565?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/864438510293515565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/08/activity-12-color-image-segmentation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/864438510293515565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/864438510293515565'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/08/activity-12-color-image-segmentation.html' title='Activity 12: Color Image Segmentation'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_6vBS5HyEno4/SnuLJwPaJMI/AAAAAAAAARg/r4xMdwIQ_wI/s72-c/eqn.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-3988697079879867330</id><published>2009-08-06T16:58:00.000-07:00</published><updated>2009-08-06T18:00:00.341-07:00</updated><title type='text'>Activity 11: Camera Processing</title><content type='html'>In this activity, we observed the effect of different white balancing options in cameras. Also, we applied the white patch and gray world algorithms on improperly white balanced images. Both RGB objects and objects with same color but different hues were used. It was found that for all images used, it is better to use the white patch algorithm.&lt;br /&gt;&lt;br /&gt;For the first part, the same set of images were captured under different white balancing options in the camera. The white balancing options used were cloudy, daylight, fluorescent, fluorescentH, and tungsten. Capturing the images under these conditions is like illuminating the object with a light source with the same color temperature as the white balancing conditions. The images are shown below. The image captured under automatic white balancing is also included for comparison. Note that in the images the order is as follows&lt;br /&gt;&lt;div style="text-align: center; font-style: italic; color: rgb(255, 0, 0);"&gt;automatic white balanced&lt;br /&gt;cloudy        daylight          fluorescent&lt;br /&gt;fluorescentH      tungsten&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/_6vBS5HyEno4/Sntze033yaI/AAAAAAAAAQA/f0FuXT59Nmo/s1600-h/rgb.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 299px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/Sntze033yaI/AAAAAAAAAQA/f0FuXT59Nmo/s400/rgb.bmp" alt="" id="BLOGGER_PHOTO_ID_5367010354368334242" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;RGB&lt;/span&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://3.bp.blogspot.com/_6vBS5HyEno4/SntznD3BRII/AAAAAAAAAQI/8wdWsFSyv3g/s1600-h/green.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 394px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SntznD3BRII/AAAAAAAAAQI/8wdWsFSyv3g/s400/green.bmp" alt="" id="BLOGGER_PHOTO_ID_5367010495830246530" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;GREEN&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: left;"&gt;From the images it can be observed that image taken under the tungsten condition is obviously improperly white balanced. The supposedly white paper appeared blue.&lt;br /&gt;&lt;br /&gt;The white patch and gray world algorithms is then applied to these images to for white balancing. Each image has RGB values. In the white patch algorithm, we get a patch from the image that is supposedly white. The RGB value of this patch is used to divide the RGB value of the whole image such that Rn = R/Rw, Gn=G/Gw and Bn=B/Bw where Rn,Gn, Bn are the white balanced RGB values, R,G,B are the original RGB values and Rw,Gw,Bw are the RGB values of the patch.&lt;br /&gt;&lt;br /&gt;For the gray world algorithm, it is assumed that the average color is gray. The key term here is "average". To operate the gray world algoirthm, we used average of the R,G, and B values and used this to divide the RGB values of the original image.&lt;br /&gt;&lt;br /&gt;The following images are the result of the white patch and gray world algorithms on the images.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;RGB IMAGES&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/Snt2zPNnA-I/AAAAAAAAAQQ/bWri1uw0ncU/s1600-h/cloudy.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 115px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/Snt2zPNnA-I/AAAAAAAAAQQ/bWri1uw0ncU/s400/cloudy.jpg" alt="" id="BLOGGER_PHOTO_ID_5367014003571098594" border="0" /&gt;&lt;/a&gt;Cloudy&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/Snt3fud4pwI/AAAAAAAAAQY/N0G2XdJwyAU/s1600-h/daylight.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 115px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/Snt3fud4pwI/AAAAAAAAAQY/N0G2XdJwyAU/s400/daylight.jpg" alt="" id="BLOGGER_PHOTO_ID_5367014767875106562" border="0" /&gt;&lt;/a&gt;Daylight&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/Snt3nZ0ZZkI/AAAAAAAAAQg/Cl5kJSc__TQ/s1600-h/fluorescent.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 114px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/Snt3nZ0ZZkI/AAAAAAAAAQg/Cl5kJSc__TQ/s400/fluorescent.jpg" alt="" id="BLOGGER_PHOTO_ID_5367014899771336258" border="0" /&gt;&lt;/a&gt;Fluorescent&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/Snt3u7zhzmI/AAAAAAAAAQo/4855hcTvOHg/s1600-h/fluorescentH.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 118px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/Snt3u7zhzmI/AAAAAAAAAQo/4855hcTvOHg/s400/fluorescentH.jpg" alt="" id="BLOGGER_PHOTO_ID_5367015029153582690" border="0" /&gt;&lt;/a&gt;FluorescentH&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/Snt314iR-rI/AAAAAAAAAQw/nZmJYroGsQc/s1600-h/tungsten.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 114px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/Snt314iR-rI/AAAAAAAAAQw/nZmJYroGsQc/s400/tungsten.jpg" alt="" id="BLOGGER_PHOTO_ID_5367015148535020210" border="0" /&gt;&lt;/a&gt;Tungsten&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Notice that better images result from the white patch algorithm. The gray world algorithm produces a very bright image. This is maybe because white dominates in the image where it was applied.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;GREEN IMAGES&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/Snt4B6Bu79I/AAAAAAAAAQ4/jOC_Xh05Lx8/s1600-h/cloudy.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 152px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/Snt4B6Bu79I/AAAAAAAAAQ4/jOC_Xh05Lx8/s400/cloudy.bmp" alt="" id="BLOGGER_PHOTO_ID_5367015355093807058" border="0" /&gt;&lt;/a&gt;Cloudy&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/Snt4Mxl-oHI/AAAAAAAAARA/qYatLtbpljc/s1600-h/daylight.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 152px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/Snt4Mxl-oHI/AAAAAAAAARA/qYatLtbpljc/s400/daylight.bmp" alt="" id="BLOGGER_PHOTO_ID_5367015541808472178" border="0" /&gt;&lt;/a&gt;Daylight&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/Snt4YvNo02I/AAAAAAAAARI/qt0y_OFPIsg/s1600-h/fluorescent.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 152px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/Snt4YvNo02I/AAAAAAAAARI/qt0y_OFPIsg/s400/fluorescent.bmp" alt="" id="BLOGGER_PHOTO_ID_5367015747327939426" border="0" /&gt;&lt;/a&gt;Fluorescent&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/Snt4kWfXhyI/AAAAAAAAARQ/jD_9skh2vJU/s1600-h/fluorescentH.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 152px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/Snt4kWfXhyI/AAAAAAAAARQ/jD_9skh2vJU/s400/fluorescentH.bmp" alt="" id="BLOGGER_PHOTO_ID_5367015946849847074" border="0" /&gt;&lt;/a&gt;FluorescentH&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/Snt4upm133I/AAAAAAAAARY/VG5OoqK_jpc/s1600-h/tungsten.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 152px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/Snt4upm133I/AAAAAAAAARY/VG5OoqK_jpc/s400/tungsten.bmp" alt="" id="BLOGGER_PHOTO_ID_5367016123780161394" border="0" /&gt;&lt;/a&gt;Tungsten&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Like in the RGB images, the white patch algorithm obviously works better. Again, brighter images are observed in the gray world algorithm. Notice though that yellow green notebook became yellow when both algorithms were applied. This may be because the yellow color of the notebook is stronger than that of its green color.&lt;br /&gt;&lt;br /&gt;The code:&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;stacksize(4e7)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rgbwp=imread("F:\186-11\wp.jpg");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rgb=imread("F:\186-11\green\tungsten.jpg");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rw=rgbwp(:,:,1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;gw=rgbwp(:,:,2);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;bw=rgbwp(:,:,3);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r=rgb(:,:,1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;g=rgb(:,:,2);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;b=rgb(:,:,3);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;//white world&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Rw = sum(rw)/(size(rgbwp,1)*size(rgbwp,2));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Gw = sum(gw)/(size(rgbwp,1)*size(rgbwp,2));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Bw = sum(bw)/(size(rgbwp,1)*size(rgbwp,2));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;//gray world&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Rg = mean(r);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Gg = mean(g);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Bg = mean(b);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rr=r/Rw;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rg=g/Gw;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rb=b/Bw;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;gr=r/Rg;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;gg=g/Gg;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;gb=b/Bg;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;chuva = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;chuva(:,:,1)=rr;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;chuva(:,:,2)=rg;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;chuva(:,:,3)=rb;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;chuva(chuva&gt;1) = 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;//scf(0), imshow(chuva);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;//scf(1), imshow(rgb);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;chuva2 = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;chuva2(:,:,1)=gr;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;chuva2(:,:,2)=gg;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;chuva2(:,:,3)=gb;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;chuva2(chuva2&gt;1) = 1;&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;//pin values to 1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;//scf(1), imshow(chuva2);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;imwrite(chuva,"F:\186-11\result\green\tungstenw.jpg");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;imwrite(chuva2,"F:\186-11\result\green\tungsteng.jpg");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Notice that the image values are all pinned to 1.&lt;br /&gt;&lt;br /&gt;For this activity, I give myself a 10/10 since I believe I was able to perform the task asked for this activity. Thank you to Neil and Earl for the discussion we had.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-3988697079879867330?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/3988697079879867330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/08/activity-11-camera-processing.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/3988697079879867330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/3988697079879867330'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/08/activity-11-camera-processing.html' title='Activity 11: Camera Processing'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_6vBS5HyEno4/Sntze033yaI/AAAAAAAAAQA/f0FuXT59Nmo/s72-c/rgb.bmp' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-5155940896688677556</id><published>2009-08-05T19:28:00.005-07:00</published><updated>2009-08-06T16:57:17.280-07:00</updated><title type='text'>Activity 10: Preprocessing Text</title><content type='html'>For this activity, we used imaging techniques we've learned so far to process a handwritten document. The goal for the first part is to isolate each letter from each other and from the lines of the form. To remove the lines, we designed a filter such that it blocks the lines. Since the lines are repetitive in the form, they will have intense lines in the Fourier space. Moreover, since I cropped the image such that only horizontal lines are seen, we used a vertical filter. Prior to filtering, the image was rotated using Gimp to make the horizontal lines straight. The original image (cropped and rotated), the filter used, and the resulting image are shown below.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/SntfpX37b9I/AAAAAAAAAPY/wyfvFqGZ6hs/s1600-h/1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 76px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/SntfpX37b9I/AAAAAAAAAPY/wyfvFqGZ6hs/s400/1.bmp" alt="" id="BLOGGER_PHOTO_ID_5366988545329950674" border="0" /&gt;&lt;/a&gt;Notice the lines in the form are not visible as it was before although some lines can still be seen in the resulting image. The next part is to isolate the letters from each other by using morphological operators. Prior to that, the image is inverted since the operations work on the white part of the image. By examining the histogram, a threshold value was obtained and was applied to the image to further isolate the text with the background. Afterwhich, morphological operations were applied to isolate each letter and make it 1 pixel thick each. For this particular case I used&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);"&gt;erode(erode(dilate(erode(inviconv,se),se),se),se2)&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;since this gave me the best result so far. The binarized image and the resulting image (after morphological operations were implemented) are shown below.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SntkQR-tORI/AAAAAAAAAPg/reAjWI3RLlo/s1600-h/2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 113px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SntkQR-tORI/AAAAAAAAAPg/reAjWI3RLlo/s400/2.bmp" alt="" id="BLOGGER_PHOTO_ID_5366993611809175826" border="0" /&gt;&lt;/a&gt;Notice in the figure that not all letters are 1 pixel thick and some letters are not visible anymore. This is the downside of the morphological operations on the letters. Since in the binarized image the thickness of each letter varies significantly, when morphological operations are applied, some letters (or parts of it) which are originally thin, are erased. A better image is expected if we have almost the same thickness for the letters :P&lt;br /&gt;&lt;br /&gt;To make the handwritten more readable, we have to compensate the thickness. Using this operator instead&lt;br /&gt;&lt;div style="text-align: center; font-style: italic; color: rgb(51, 51, 255);"&gt;ero=erode(dilate(erode(inviconv,se),se),se)&lt;br /&gt;&lt;/div&gt;give a more a readable result and the erased the remaining lines visible in the binarized object. Although some of you may object that it is not readable enough, my claim is that thatpart is subjective :P&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/SntmExgUU-I/AAAAAAAAAPo/sv6lm4j1AoE/s1600-h/3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 113px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/SntmExgUU-I/AAAAAAAAAPo/sv6lm4j1AoE/s400/3.bmp" alt="" id="BLOGGER_PHOTO_ID_5366995613136475106" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;For the second part, we are to perform the correlation of the word "DESCRIPTION" in the text. Assuming that the word has the same size in the image althroughout, strictly speaking, only 3 intense bright spots (corresponding to high correlation) should be observed in the Fourier Transform (FT) since "DESCRIPTION" was appeared only 3 times. However if we are to look at the FT, we have other bright spots. This is because there are white parts that can acoomodate the whole area of "DESCRIPTION". This results to higher correlation and hence a bright spot. An example is the logo on top of the form.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/SntrMciGA-I/AAAAAAAAAPw/y2J4osglJj0/s1600-h/4.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 163px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/SntrMciGA-I/AAAAAAAAAPw/y2J4osglJj0/s400/4.bmp" alt="" id="BLOGGER_PHOTO_ID_5367001242503873506" border="0" /&gt;&lt;/a&gt;To verify this result, I cropped the image such thatthe logo is annot included anymore. Here we observed the 3 intense spots as what was expected.&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SntsNE5SQ6I/AAAAAAAAAP4/fOXewxQdrKg/s1600-h/5.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 234px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SntsNE5SQ6I/AAAAAAAAAP4/fOXewxQdrKg/s400/5.bmp" alt="" id="BLOGGER_PHOTO_ID_5367002352850191266" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;For this activity, I give myself a 7/10 since I was not able to isolate the letters from each other, and make a readable 1 pixel thick letter. For me, this seems to be the hardest activity.&lt;br /&gt;&lt;br /&gt;Many thanks to Ma'am Jing, Gilbert and Neil for the insights :)&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-5155940896688677556?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/5155940896688677556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/08/activity-10-preprocessing-text.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/5155940896688677556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/5155940896688677556'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/08/activity-10-preprocessing-text.html' title='Activity 10: Preprocessing Text'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_6vBS5HyEno4/SntfpX37b9I/AAAAAAAAAPY/wyfvFqGZ6hs/s72-c/1.bmp' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-6535170744513932336</id><published>2009-08-05T19:28:00.003-07:00</published><updated>2009-08-06T15:02:07.771-07:00</updated><title type='text'>Activity 9: Binary Operations</title><content type='html'>In this activity, we are to estimate the size of one punched paper by examining an ensemble. By applying the closing and opening operators in Scilab, we tried to separate nearly touching circles and clean the edges of circles. From here, we plotted the obtained areas and the peak which corresponds to more frequent areas within the ensemble is taken as the area of an individual circle.&lt;br /&gt;&lt;br /&gt;The figure below is the image of the ensemble of punched papers. This image is further subdivided into 256x256 subimages. For our discussion, we will refer only to one subimage. All subimages undergone the same morphological operations.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/Snsc3VBupMI/AAAAAAAAAOw/LQbgMMY-uY8/s1600-h/Circles001.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 330px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/Snsc3VBupMI/AAAAAAAAAOw/LQbgMMY-uY8/s400/Circles001.jpg" alt="" id="BLOGGER_PHOTO_ID_5366915117804856514" border="0" /&gt;&lt;/a&gt;ORIGINAL&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/_6vBS5HyEno4/Snsd582w8qI/AAAAAAAAAO4/eWccwFxhNFI/s1600-h/12.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 256px; height: 256px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/Snsd582w8qI/AAAAAAAAAO4/eWccwFxhNFI/s400/12.jpg" alt="" id="BLOGGER_PHOTO_ID_5366916262367654562" border="0" /&gt;&lt;/a&gt;SUBIMAGE&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The subimage is binarized. The proper threshold value is obtained from its histogram. In depth discussion of which is found in the previous activities. If we are to consider a subimage with only one circle, thresholding is enough. However, an ensemble of circles needs further operations since overlapping of circles may occur. Another reason for further operation is that the area of each circle may vary. The opening and closing operators were implemented on the subimages. Bwlabel in scilab renders a particular color to a blob. A blob is anything white in the binarized image. So long as one circle is connected even with only 1 pixel, bwlabel reads that as one blob. Note that the structuring element used is a circle with a diameter of 4 pixels.&lt;br /&gt;&lt;br /&gt;After the subimage undergone the operation it looked like the one below. The subimage (original and binarized) was also posted for comparison.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/SnsiS8h9P8I/AAAAAAAAAPI/Z4dvJnyklhw/s1600-h/this.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 134px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/SnsiS8h9P8I/AAAAAAAAAPI/Z4dvJnyklhw/s400/this.bmp" alt="" id="BLOGGER_PHOTO_ID_5366921089823621058" border="0" /&gt;&lt;/a&gt;In the binarized image we can see that the circles were well separated from the background. However, there are still circles that are overlapping. After applying the operator we could see that we were able to separate one circle as one blob which corresponds to a particular area. Note that the extracted areas were the areas of blobs. By tallying the areas we obtained the most occuring area for each subimage. This was done for all 13 subimages. The resulting histogram (below) shows that the most occuring area is at around 541 pixels. To verify this area, I isolated one circle and measured its diameter. The diameter obtained was 26 which orresponds to an area of 530. This is near the value extracted from the histogram.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SnslT_CubhI/AAAAAAAAAPQ/gLs-tlsM4ro/s1600-h/histo.bmp"&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/_6vBS5HyEno4/SnslT_CubhI/AAAAAAAAAPQ/gLs-tlsM4ro/s400/histo.bmp" alt="" id="BLOGGER_PHOTO_ID_5366924406212685330" border="0" /&gt;&lt;/a&gt;HISTOGRAM&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;For this activity I give myself an 8/10 since I am not sure if the operation I used is enough.&lt;br /&gt;Collaborators:&lt;br /&gt;neil, gary, gilbert&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-6535170744513932336?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/6535170744513932336/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.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/7546939043065849431/posts/default/6535170744513932336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/6535170744513932336'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/08/activity-9-binary-operations.html' title='Activity 9: Binary Operations'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_6vBS5HyEno4/Snsc3VBupMI/AAAAAAAAAOw/LQbgMMY-uY8/s72-c/Circles001.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-2429227317008949242</id><published>2009-07-19T09:52:00.000-07:00</published><updated>2009-07-25T19:11:26.457-07:00</updated><title type='text'>Activity 7: Enhancement in the Filter Domain</title><content type='html'>In this activity, the convolution theorem is used to enhance images. In the first part of the activity, we explored the convolution theorem. The succeeding parts deals with ridge enhancement, line removal, and canvas weave modeling and removal from images. All of which were done by exploiting the convolution theorem in the Fourier space.&lt;br /&gt;&lt;br /&gt;A. Convolution Theorem&lt;br /&gt;For this part, the Fourier transform (FT) of images were done. The images used are two dots of 1 pixel each, circles of different radii, squares of different area symmetric about the center. A Gaussian function of varying variance also was used instead of dots. The following are the images described above and their corresponding FTs.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/SmSCwodgogI/AAAAAAAAALo/1xROPdiywd8/s1600-h/group1.bmp"&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/_6vBS5HyEno4/SmSCwodgogI/AAAAAAAAALo/1xROPdiywd8/s400/group1.bmp" alt="" id="BLOGGER_PHOTO_ID_5360553228484256258" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SmSFt_BZt5I/AAAAAAAAALw/qJap7dPA7FM/s1600-h/group2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 325px; height: 243px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SmSFt_BZt5I/AAAAAAAAALw/qJap7dPA7FM/s400/group2.bmp" alt="" id="BLOGGER_PHOTO_ID_5360556481535653778" border="0" /&gt;&lt;/a&gt;It can be observed from the above images that with increasing area for circles and squares, the FT becomes smaller. It can also be seen that the FTs are sine and a sinc for circles and a squares, respectively. For FTs for the Gaussian functions decreases in area with increasing variance (or effectively increasing area).&lt;br /&gt;&lt;br /&gt;B. Ridge Enhancement&lt;br /&gt;Using the FT of an image, we can create a filter such that only the high frequencies can pass. This is what we did here. High frequencies in your image correspond to bright areas in your Fourier space. These high frequencies are repetitive in your image. Particularly for a fingerprint, these are the ridges. This is the reason why the particular filter below was used. The following shows the original fingerprint, the enhanced fingerprint, the filter used and the FT of the original image. Notice that in the reconstructed image, the blotches were minimized. they were acutally spread out, thus a more enhanced ridges were obtained. However, there is a downside with this enhancement. The reconstructed image was blurry on other areas. This maybe due to the filtered frequencies that should not be filtered out.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/SmSLhS4mJLI/AAAAAAAAAL4/x3-32LAL1G0/s1600-h/group3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 105px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/SmSLhS4mJLI/AAAAAAAAAL4/x3-32LAL1G0/s400/group3.bmp" alt="" id="BLOGGER_PHOTO_ID_5360562860598895794" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;C. Line Removal&lt;br /&gt;For this part, The inverse of part B was done. Here, we actually filtered out the bright areas in the image. This bright areas correspond to the lines you like to remove in the image. We designed a filter such that these high frequencies cannot pass. Indeed, we obtained an image without the lines. Again, the following are the image,its FT, the filter used, and the reconstructed image.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SmSPcAIIbPI/AAAAAAAAAMI/khblQeDMkTo/s1600-h/group4.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 310px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SmSPcAIIbPI/AAAAAAAAAMI/khblQeDMkTo/s400/group4.bmp" alt="" id="BLOGGER_PHOTO_ID_5360567167710948594" border="0" /&gt;&lt;/a&gt;D. Canvas Weave Modeling and Removal&lt;br /&gt;The same technique as that in C is applied here. The repetitive patterns of the canvas weave correspond to high frequencies in the Fourier space. To remove the canvas weave in the image, we designed a filter such that these high frequencies are blocked. In the canvas weave modeling, the filter (only the black dots) used is basically the canvas weave patterns. So taking its inverse FT is like modeling the canvas weave itself. However, results showed that the canvas weave model is angled either 90 or 180 degrees with respect to the original canvas. Results are shown below.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SmSSbtnfFQI/AAAAAAAAAMQ/ouG1a_ZHiWo/s1600-h/group5.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 307px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SmSSbtnfFQI/AAAAAAAAAMQ/ouG1a_ZHiWo/s400/group5.bmp" alt="" id="BLOGGER_PHOTO_ID_5360570461277066498" border="0" /&gt;&lt;/a&gt;Canvas Weave Removal&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/Smu7IejVtEI/AAAAAAAAAMY/AqhwGRKiZXY/s1600-h/canvasweave.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 148px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/Smu7IejVtEI/AAAAAAAAAMY/AqhwGRKiZXY/s400/canvasweave.bmp" alt="" id="BLOGGER_PHOTO_ID_5362585535629341762" border="0" /&gt;&lt;/a&gt;Canvas weave Model&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;*** To enhance the image properly, make sure that the FT of the image coincides with the filter design. The problem I encountered was I cannot get an enhanced image. This is because my filter did not actually filtered the frequencies I wanted since it did not coincide with the FT of the image.&lt;br /&gt;&lt;br /&gt;I give myself an 8/10 for this activity since I am not sure if I did the ridge enhancement properly. Remember that a blurry image was formed.&lt;br /&gt;&lt;br /&gt;Thank you to Gary and Gilbert for suggesting to use "imwrite" instead of" imshow" in obtaining the FTs and designing the filters.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-2429227317008949242?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/2429227317008949242/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/07/activity-7-enhancement-in-filter-domain.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/2429227317008949242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/2429227317008949242'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/07/activity-7-enhancement-in-filter-domain.html' title='Activity 7: Enhancement in the Filter Domain'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_6vBS5HyEno4/SmSCwodgogI/AAAAAAAAALo/1xROPdiywd8/s72-c/group1.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-7276649806958480768</id><published>2009-07-08T19:20:00.000-07:00</published><updated>2009-07-09T11:38:37.600-07:00</updated><title type='text'>Activity 6: Properties of the 2D Fourier Transform</title><content type='html'>In this activity, the properties of the 2D Fourier Transform (FT) were investigated. For the first part, the FT of a square, donut, square annulus, two slits, and two dots were obtained. The following images show the images with its corresponding FT's.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SlYo6wKDKjI/AAAAAAAAAI0/O_YAShNqiwM/s1600-h/part+1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 157px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SlYo6wKDKjI/AAAAAAAAAI0/O_YAShNqiwM/s400/part+1.bmp" alt="" id="BLOGGER_PHOTO_ID_5356513796628359730" border="0" /&gt;&lt;/a&gt;The second part is to create a 2d sinusoids with different frequencies and obtain their FT's. Results showed that as you increase the frequency, the spacing between the dots in the FT's also increases. This is because at higher frequencies, the spacing between the sinusoids decreases. This is equivalent to an increase in the spacing of the delta function (or in this case, the dots) in the frequency domain. Note that the FT of a sinusoid is a delta function.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/SlYxHAMp8yI/AAAAAAAAAKw/DXw68PuItAM/s1600-h/part+2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 129px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/SlYxHAMp8yI/AAAAAAAAAKw/DXw68PuItAM/s400/part+2.bmp" alt="" id="BLOGGER_PHOTO_ID_5356522803185709858" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;On the next part of the activity, we investigated the effect of adding a constant bias on the sinusoid. From the results, it can be seen that adding a negative or positive value of bias does not change the FT as long as the magnitudes are equal. Note that frequency = 4 for all was used.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SlYw6cMeWJI/AAAAAAAAAKo/876iN9lsm5s/s1600-h/part+3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 103px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SlYw6cMeWJI/AAAAAAAAAKo/876iN9lsm5s/s400/part+3.bmp" alt="" id="BLOGGER_PHOTO_ID_5356522587362842770" border="0" /&gt;&lt;/a&gt;When the sinusoids are rotated from 0-120, their FTs also rotates, which is in accrodance to the Introduction part of the manual. [1] (frequency = 4)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/SlYyXX1kF2I/AAAAAAAAAK4/0pWJvAzFogI/s1600-h/part+4.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 126px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/SlYyXX1kF2I/AAAAAAAAAK4/0pWJvAzFogI/s400/part+4.bmp" alt="" id="BLOGGER_PHOTO_ID_5356524183920842594" border="0" /&gt;&lt;/a&gt;The product of two sinusoids is a checkerboard with circles or ellipses. Circles are obtained when both the coefficients for X and Y are the same, otherwise, an ellipse. The FTs produced are dots arranged in a square (for circles) and in rectangles (for ellipses) . Notice also that the distribution of the dots has the same shape as the component of the checkerboard. What follows are the images of the generated sinusoids and their corresponding FT's.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/SlY0vN8wcBI/AAAAAAAAALA/lLkUl4k0E34/s1600-h/part+5.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 118px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/SlY0vN8wcBI/AAAAAAAAALA/lLkUl4k0E34/s400/part+5.bmp" alt="" id="BLOGGER_PHOTO_ID_5356526792606773266" border="0" /&gt;&lt;/a&gt;For the last part of the activity, the FTs of combinations of the sinusoids with varying rotating angle and the product of two sinusoids were first predicted. Superposition of the waves were basically done. From the linearity property of FT, the FT of the sum of two waves is just the FT of the first wave plus the FT of the second wave. Here, we expect to get the same result as the previous only this time they are rotated. Results verified this linearity property.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SlY3LzzfphI/AAAAAAAAALI/_Zz2wNynHew/s1600-h/11.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 205px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SlY3LzzfphI/AAAAAAAAALI/_Zz2wNynHew/s400/11.bmp" alt="" id="BLOGGER_PHOTO_ID_5356529482828064274" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SlY3Y8m7mjI/AAAAAAAAALg/IUJu1l0YT8U/s1600-h/32.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 207px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SlY3Y8m7mjI/AAAAAAAAALg/IUJu1l0YT8U/s400/32.bmp" alt="" id="BLOGGER_PHOTO_ID_5356529708529588786" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SlY3UrydWnI/AAAAAAAAALY/hyEdCH8KYtM/s1600-h/31.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 204px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SlY3UrydWnI/AAAAAAAAALY/hyEdCH8KYtM/s400/31.bmp" alt="" id="BLOGGER_PHOTO_ID_5356529635295058546" border="0" /&gt;&lt;/a&gt;For this activity, I give myself an 8/10. Thank you to Raffy for introducing the 'mesh()' function. It was fun to look at the sinusoids in 3D! :D Thank you also to Ma'am Jing for the code :)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;**Scilab code can be found in Reference 1.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Note that to see better results, open the image on a new tab :)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Reference:&lt;br /&gt;Dr. Maricor Soriano. AP 186 Activity 6 Manual&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-7276649806958480768?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/7276649806958480768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/07/activity-6-properties-of-2d-fourier.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/7276649806958480768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/7276649806958480768'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/07/activity-6-properties-of-2d-fourier.html' title='Activity 6: Properties of the 2D Fourier Transform'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_6vBS5HyEno4/SlYo6wKDKjI/AAAAAAAAAI0/O_YAShNqiwM/s72-c/part+1.bmp' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-7883618160264861334</id><published>2009-07-06T17:40:00.001-07:00</published><updated>2009-07-07T07:46:15.101-07:00</updated><title type='text'>Activity 5: Fourier Transform Model of Image Formation</title><content type='html'>For this activity, Fourier Transform was implemented on images.  The first part of the activity is to get the FFT of a circle and the letter 'A'. Shown below are the original image, the shifted FFT of that image, and the FFT of its FFT. Notice that the third image is just a reconstruction of the original image, only this time it is inverted. This is a property of the inverse FFT  - that the inverse FFT is just the same as the forward FFT with the image inverted. [1] This is not readily seen in the circle since it is symmetric in all directions.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SlNFbXrov-I/AAAAAAAAAEc/_UVcheKu_k4/s1600-h/g+circle.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 133px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SlNFbXrov-I/AAAAAAAAAEc/_UVcheKu_k4/s400/g+circle.bmp" alt="" id="BLOGGER_PHOTO_ID_5355700718389477346" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/SlNGWk_lnaI/AAAAAAAAAEk/iImULiYE7FA/s1600-h/g+A.bmp"&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/_6vBS5HyEno4/SlNGWk_lnaI/AAAAAAAAAEk/iImULiYE7FA/s400/g+A.bmp" alt="" id="BLOGGER_PHOTO_ID_5355701735575100834" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The second part of the activity deals with convolution of two images. The system resembles an imaging system with the circle serving as an aperture and the text 'VIP' as the object. The radius of the circle is varied and the following results were obtained.&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/_6vBS5HyEno4/SlNRh7qtqaI/AAAAAAAAAEs/6C-FUbE1s_M/s1600-h/gvip10r.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 276px; height: 143px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/SlNRh7qtqaI/AAAAAAAAAEs/6C-FUbE1s_M/s400/gvip10r.bmp" alt="" id="BLOGGER_PHOTO_ID_5355714025268029858" border="0" /&gt;&lt;/a&gt;r=5&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/_6vBS5HyEno4/SlNRvWMAlgI/AAAAAAAAAE0/X7Wi-TLgkNs/s1600-h/gvip20r.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 281px; height: 144px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SlNRvWMAlgI/AAAAAAAAAE0/X7Wi-TLgkNs/s400/gvip20r.bmp" alt="" id="BLOGGER_PHOTO_ID_5355714255725303298" border="0" /&gt;&lt;/a&gt;r=10&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/SlNSiuk9GZI/AAAAAAAAAE8/ENJiStZ_v-A/s1600-h/gvip30r.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 268px; height: 137px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/SlNSiuk9GZI/AAAAAAAAAE8/ENJiStZ_v-A/s400/gvip30r.bmp" alt="" id="BLOGGER_PHOTO_ID_5355715138445711762" border="0" /&gt;&lt;/a&gt;r=15&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/SlNTbmNtyqI/AAAAAAAAAFE/MV8jkrLB_q4/s1600-h/gvip48_5r.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 270px; height: 139px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/SlNTbmNtyqI/AAAAAAAAAFE/MV8jkrLB_q4/s400/gvip48_5r.bmp" alt="" id="BLOGGER_PHOTO_ID_5355716115453299362" border="0" /&gt;&lt;/a&gt;r = 48.5&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;As can be seen, the larger the radius of the aperture, the better the reconstruction. This is because the number of frequencies that can pass through is dependent on the size of the aperture. For larger apertures, more frequencies can pass through. Hence a better reconstruction is obtained as opposed to that of apertures with smaller radii.&lt;br /&gt;&lt;br /&gt;The third part of the activity is to find the correlation of the letter 'A' in the sentence "THE RAIN IN SPAIN STAYS MAINLY ON THE PLANE." To do this, the FFT of 'A' is multiplied element per element with the  FFT of the text. The result shows that the letter A's in the text are highlighted because of high correlation.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SlNWllp_rEI/AAAAAAAAAFs/nULFBEfDjFA/s1600-h/g+text.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 139px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SlNWllp_rEI/AAAAAAAAAFs/nULFBEfDjFA/s400/g+text.bmp" alt="" id="BLOGGER_PHOTO_ID_5355719585637051458" border="0" /&gt;&lt;/a&gt;The figure above shows the text (1st), the letter 'A' with the same font style and font size, and the resulting image when their FFTs are multiplied element per element.&lt;br /&gt;&lt;br /&gt;The last part of the activity shows edge detection using the convolution integral. Four patterns were used (horizontal, vertical, diagonal, and spot). The following results were obtained.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SlNar3VmWlI/AAAAAAAAAF0/nhSt8E9FTM8/s1600-h/glast.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 121px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SlNar3VmWlI/AAAAAAAAAF0/nhSt8E9FTM8/s400/glast.bmp" alt="" id="BLOGGER_PHOTO_ID_5355724091509070418" border="0" /&gt;&lt;/a&gt;The pattern allows only certain components to be seen. For example, the reconstruction for the horizontal pattern allows only almost horizontal components. Most vertical components are missing in the horizontal pattern, most horizontal components are missing in the vertical pattern, other vertical and horizontal patterns are missing in the diagonal pattern, and most components are present in the spot pattern.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 102, 255); font-style: italic;"&gt;The code (taken from Reference 1): &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;//first part&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;I=imread("C:\Documents and Settings\2004-28298\Desktop\activity 5\circle.bmp");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Igray=im2gray(I);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;FIgray= fft2(Igray);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;fc=abs(fftshift(FIgray))/max(abs(fftshift(FIgray)));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;ffc=abs(fft2(FIgray))/max(abs(fft2(FIgray)));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;imwrite(fc,"C:\Documents and Settings\mimie\Desktop\activity 5\fc.bmp");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;imwrite(ffc,"C:\Documents and Settings\mimie\Desktop\activity 5\ffc.bmp");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;//2nd part&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;o=imread("C:\Documents and Settings\mimie\Desktop\activity 5\vip.bmp");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;I=imread("C:\Documents and Settings\mimie\Desktop\activity 5\30r.bmp");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;lgray=im2gray(I);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;ogray=im2gray(o);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;fl=fftshift(lgray);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;fo=fft2(ogray);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;col=fo.*(fl);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;icol=fft2(col);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;fimage=abs(icol);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;fimagenorm=fimage/max(fimage);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;imwrite(fimagenorm,""C:\Documents and Settings\mimie\Desktop\activity 5\vip30r.bmp");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;//3rd part&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;t=imread("C:\Documents and Settings\mimie\Desktop\activity 5\text.bmp");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;a2=imread("C:\Documents and Settings\mimie\Desktop\activity 5\A2.bmp");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;tgray=im2gray(t);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;a2gray=im2gray(a2);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;ft=fft2(tgray);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;fa2=fft2(a2gray);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;cft=conj(ft);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;cta2=fa2.*(cft);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;fcta2=fft(cta2);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;ta2=fftshift(abs(fcta2))/max(fftshift(abs(fcta2)));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;imwrite(ta2,"C:\Documents and Settings\mimie\Desktop\activity 5\ta2.bmp");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;//last part&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;i=imread("C:\Documents and Settings\mimie\Desktop\activity 5\vip.bmp");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;igray=im2gray(i);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;pattern1=[-1,-1,-1; 2,2,2; -1,-1,-1];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;pattern2=[-1,2,-1; -1,2,-1;-1,2,-1];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;pattern3=[-1,-1,-1; -1,8,-1;-1,2,-1];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;pattern4=[2,-1,-1;-1,2,-1;-1,-1,2];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;c1=imcorrcoef(igray,pattern1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;c2=imcorrcoef(igray,pattern2);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;c3=imcorrcoef(igray,pattern3);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;c4=imcorrcoef(igray,pattern4);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;c1norm=c1/max(c1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;c2norm=c2/max(c2);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;c3norm=c3/max(c3);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;c4norm=c4/max(c4);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;imwrite(c1norm,"C:\Documents and Settings\mimie\Desktop\activity 5\c1norm.bmp");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;imwrite(c2norm,"C:\Documents and Settings\mimie\Desktop\activity 5\c2norm.bmp");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;imwrite(c3norm,"C:\Documents and Settings\mimie\Desktop\activity 5\c3norm.bmp");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;imwrite(c4norm,"C:\Documents and Settings\mimie\Desktop\activity 5\c4norm.bmp");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 204, 204);"&gt;**Remember to comment the part of the code you don't need.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Many thanks to Ma'am Jing for providing the code which guided me through this activity. Thank you also to Kaye and Miguel for the discussions we had, and to Raffy for helping me. I give myself a 9/10 for this activity because I did what was expected from the activity.&lt;br /&gt;&lt;br /&gt;[1] Dr. Maricor Soriano. Activity 5 Manual.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-7883618160264861334?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/7883618160264861334/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.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/7546939043065849431/posts/default/7883618160264861334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/7883618160264861334'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/07/activity-5-fourier-transform-model-of.html' title='Activity 5: Fourier Transform Model of Image Formation'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_6vBS5HyEno4/SlNFbXrov-I/AAAAAAAAAEc/_UVcheKu_k4/s72-c/g+circle.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-4485756842559450309</id><published>2009-07-06T05:30:00.000-07:00</published><updated>2009-07-07T23:34:36.595-07:00</updated><title type='text'>Activity 4: Enhancement by Histogram Manipulation</title><content type='html'>For this activity, a poor contrast image is enhanced by histogram manipulation by following the steps below. The code (if applicable) used and the results accompany the steps.&lt;br /&gt;&lt;br /&gt;1. Get an image from the internet or from own collection. Crop if necessary.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/SlQ4h04Dp-I/AAAAAAAAAIk/OtjmfmgeCzw/s1600-h/Old+Yreka+High.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 314px; height: 400px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/SlQ4h04Dp-I/AAAAAAAAAIk/OtjmfmgeCzw/s400/Old+Yreka+High.bmp" alt="" id="BLOGGER_PHOTO_ID_5355968010630965218" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;I=imread('C:\Documents and Settings\mimie\Desktop\New Folder (2)\activity 4 images\crop.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2. Change image to grayscale and get its histogram and corresponding Cumulative Distribution Function (CDF).&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SlQWb4ryv8I/AAAAAAAAAHc/QAPmgWDbcKE/s1600-h/I.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 232px; height: 217px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SlQWb4ryv8I/AAAAAAAAAHc/QAPmgWDbcKE/s400/I.png" alt="" id="BLOGGER_PHOTO_ID_5355930525178707906" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/SlQVYIefVuI/AAAAAAAAAHM/dzM40aN6jyI/s1600-h/g+orig2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 168px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/SlQVYIefVuI/AAAAAAAAAHM/dzM40aN6jyI/s400/g+orig2.png" alt="" id="BLOGGER_PHOTO_ID_5355929361186772706" border="0" /&gt;&lt;/a&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;I=im2gray(I);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;gcrop=I/max(I);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;imwrite(gcrop, "C:\Documents and Settings\mimie\Desktop\New Folder (2)\activity 4 images\gcrop.bmp");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;xsize=size(I,1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;ysize=size(I,2);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;x = matrix(0:255,[1,256]);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;y = x.*0;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;a = 1;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;for i = 0:255&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;m = find(I== i);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;y(a) = length(m);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;a = a + 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;cs=cumsum(y);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;csnorm=cs/max(cs);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. Backproject the CDF of original image to a linear CDF. Get resulting image, its histogram and its cdf.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/SlQXQYxKzUI/AAAAAAAAAHk/pDaLGBzQkZE/s1600-h/compare.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/_6vBS5HyEno4/SlQXQYxKzUI/AAAAAAAAAHk/pDaLGBzQkZE/s400/compare.png" alt="" id="BLOGGER_PHOTO_ID_5355931427144387906" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/SlQau_9QUgI/AAAAAAAAAH8/uSSa-0LeQx8/s1600-h/g+line.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 166px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/SlQau_9QUgI/AAAAAAAAAH8/uSSa-0LeQx8/s400/g+line.png" alt="" id="BLOGGER_PHOTO_ID_5355935251595022850" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;//linear desired cdf&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;for i=1:xsize&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;for j=1:ysize&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;n=find(x==I(i,j));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;newI(i,j)=cs(n);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;4. Backproject to a nonlinear CDF and get resulting image, histogram, and CDF of reconstructed image.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SlQ2CLrI9oI/AAAAAAAAAIU/JHbIqR9ZKtA/s1600-h/compare2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 188px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SlQ2CLrI9oI/AAAAAAAAAIU/JHbIqR9ZKtA/s400/compare2.png" alt="" id="BLOGGER_PHOTO_ID_5355965267971733122" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SlQ31XU_5XI/AAAAAAAAAIc/uMrqGJ5kl2Q/s1600-h/g+n.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 171px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SlQ31XU_5XI/AAAAAAAAAIc/uMrqGJ5kl2Q/s400/g+n.png" alt="" id="BLOGGER_PHOTO_ID_5355967246785045874" border="0" /&gt;&lt;/a&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;//nonlinear&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;z = [0:255];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;g = tanh(30.*(x-128)./255);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;g = (g - min(g))./2;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;plot(x,g);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;for i = 1:xsize&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;  for j = 1:ysize&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    n1 = find(x == I(i,j)); //get index of x from image&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    y1 = csnorm(n1); //get corresponding y value&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    n2 = find(g&lt;=y1); //equate with y in desired cdf&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    newI2(i,j) = csnorm(n2(max(n2)));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;  end&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The original image has poor contrast since its pixel values does not cover the entire 0-255 values. By backprojecting its original CDF to a linear CDF with pixel values from 0-255, a better contrast is obtained. When we say backproject, it means that it follows the new CDF, but not perfectly, of course. This can be seen from the CDF of the reconstructed image using a desired linear CDF. When the nonlinear CDF (for this case, hyperbolic tangent)  is used, the quality of the image degraded. Notice that the histogram of the reconstructed image is narrower than that of original image. Hence a poorer image contrast was obtained.  We can conclude in this activity that image contrast of an image can either be improved or degraded depending on the CDF to which these images are backprojected.&lt;br /&gt;&lt;br /&gt;For this activity, I give  myself an 7/10. Thank you to Ma'am Jing, Ma'am Gay, Raffy, Kaye, and Neil for the help.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;***&lt;/span&gt;&lt;br /&gt;&lt;ul style="color: rgb(51, 51, 255);"&gt;&lt;li&gt;Note that to get the histogram and CDF of the reconstructed image, we have to multiply the image to 255 since we had it normalize to 255 before displaying it.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;to change the color of plot to &lt;span style="color: rgb(102, 255, 153);"&gt;green&lt;/span&gt; : plot(x,y,,['g']) may apply to other colors as well :)&lt;/li&gt;&lt;/ul&gt;References&lt;br /&gt;1. Dr. Maricor Soriano. Activity 4 manual.&lt;br /&gt;2. image taken from: http://yrekahigh.com/Portals/1/YrekahighPics/Misc_%20Pictures/Old%20Yreka%20High.bmp&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-4485756842559450309?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/4485756842559450309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/07/activity-4-enhancement-by-histogram.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/4485756842559450309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/4485756842559450309'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/07/activity-4-enhancement-by-histogram.html' title='Activity 4: Enhancement by Histogram Manipulation'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_6vBS5HyEno4/SlQ4h04Dp-I/AAAAAAAAAIk/OtjmfmgeCzw/s72-c/Old+Yreka+High.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-7712191738615897675</id><published>2009-06-24T07:31:00.000-07:00</published><updated>2009-07-05T04:31:53.648-07:00</updated><title type='text'>Activity 3: Image Types and Basic Image Enhancement</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6vBS5HyEno4/Skjno-prR5I/AAAAAAAAADU/VARsBTN0E9U/s1600-h/rgb.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 386px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/Skjno-prR5I/AAAAAAAAADU/VARsBTN0E9U/s400/rgb.jpg" alt="" id="BLOGGER_PHOTO_ID_5352782848328419218" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: center;"&gt;True Color (RGB)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;FileSize: 139787&lt;br /&gt;Format: JPEG&lt;br /&gt;Width: 800&lt;br /&gt;Height: 771&lt;br /&gt;Depth: 8&lt;br /&gt;StorageType: truecolor&lt;br /&gt;NumberOfColors: 0&lt;br /&gt;ResolutionUnit: inch&lt;br /&gt;XResolution: 72.000000&lt;br /&gt;YResolution: 72.000000&lt;br /&gt;&lt;br /&gt;http://us.fun.marinov.net/store/Village%20Scenery/Village%20Scenery%20-%201.jpg&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/Skjnys5FXkI/AAAAAAAAADc/CnmUjlpqEd8/s1600-h/indexed.gif"&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/_6vBS5HyEno4/Skjnys5FXkI/AAAAAAAAADc/CnmUjlpqEd8/s400/indexed.gif" alt="" id="BLOGGER_PHOTO_ID_5352783015359897154" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: center;"&gt;Indexed&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;FileSize: 28933&lt;br /&gt;Format: GIF&lt;br /&gt;Width: 500&lt;br /&gt;Height: 344&lt;br /&gt;Depth: 8&lt;br /&gt;StorageType: indexed&lt;br /&gt;NumberOfColors: 8&lt;br /&gt;ResolutionUnit: centimeter&lt;br /&gt;XResolution: 72.000000&lt;br /&gt;YResolution: 72.000000&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;http://www.wingo.com/opinion/watch_out_kid.gif&lt;br /&gt;&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/_6vBS5HyEno4/SkjoDKVTO0I/AAAAAAAAADk/efIH5-2pthU/s1600-h/sem8.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 304px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/SkjoDKVTO0I/AAAAAAAAADk/efIH5-2pthU/s400/sem8.jpg" alt="" id="BLOGGER_PHOTO_ID_5352783298140781378" border="0" /&gt;&lt;/a&gt;Grayscale&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;FileSize: 97685&lt;br /&gt;Format: JPEG&lt;br /&gt;Width: 450&lt;br /&gt;Height: 342&lt;br /&gt;Depth: 8&lt;br /&gt;StorageType: indexed&lt;br /&gt;NumberOfColors: 256&lt;br /&gt;ResolutionUnit: inch&lt;br /&gt;XResolution: 72.000000&lt;br /&gt;YResolution: 72.00000&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;http://gsc.nrcan.gc.ca/labs/ebeam/images/sem8.jpg&lt;br /&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/_6vBS5HyEno4/SkjoT_nPSYI/AAAAAAAAADs/MOIwAjvYA1Q/s1600-h/binary_counter.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 196px;" src="http://1.bp.blogspot.com/_6vBS5HyEno4/SkjoT_nPSYI/AAAAAAAAADs/MOIwAjvYA1Q/s400/binary_counter.bmp" alt="" id="BLOGGER_PHOTO_ID_5352783587321006466" border="0" /&gt;&lt;/a&gt;Binary&lt;br /&gt;&lt;div style="text-align: left;"&gt;FileSize: 38062&lt;br /&gt;Format: BMP&lt;br /&gt;Width: 775&lt;br /&gt;Height: 380&lt;br /&gt;Depth: 8&lt;br /&gt;StorageType: indexed&lt;br /&gt;NumberOfColors: 2&lt;br /&gt;ResolutionUnit: centimeter&lt;br /&gt;XResolution: 118.430000&lt;br /&gt;YResolution: 118.430000&lt;br /&gt;&lt;br /&gt;http://baec.tripod.com/AUGUST01/pics/binary_counter.bmp&lt;br /&gt;&lt;br /&gt;************************************************&lt;br /&gt;For the second part of the activity, a scanned image was enhanced using the threshold value from the histogram. Thresholding is basically making the region of interest (ROI) of the image well separated  from the background. In this activity, a scanned image of a leaf was used.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SlCBP6aBGhI/AAAAAAAAAD0/S8j6a_cW26U/s1600-h/leaf.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 258px; height: 142px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SlCBP6aBGhI/AAAAAAAAAD0/S8j6a_cW26U/s400/leaf.JPG" alt="" id="BLOGGER_PHOTO_ID_5354922067319921170" border="0" /&gt;&lt;/a&gt;The image cropped using gimp. The colors were also inverted since I wanted the leaf to be the region of interest. Using scilab, the image was converted to grayscale. Its  histogram and image properties were also obtained using the code below. The results then followed.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;I=imread("C:\Documents and Settings\mimie\Desktop\leafginv.jpg");&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;I=im2gray(I);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;//histogram&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;a = 1;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;x= [];&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;y= [];&lt;/span&gt;  &lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;for i = 0:256&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;  &lt;br /&gt;   m = find(I== i);&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;  &lt;br /&gt;   x(a) = i;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;  &lt;br /&gt;   y(a) = length(m);&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;  &lt;br /&gt;   a = a + 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;end&lt;/span&gt;  &lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;br /&gt;scf(1)&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;plot(x,y/max(y)) //end of histogram routine&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;imshow(I)&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;imfinfo('C:\Documents and Settings\mimie\Desktop\leafginv.jpg')&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6vBS5HyEno4/SlCJtTZmkII/AAAAAAAAAD8/40Que_Y1ANM/s1600-h/image+histogram.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 323px;" src="http://2.bp.blogspot.com/_6vBS5HyEno4/SlCJtTZmkII/AAAAAAAAAD8/40Que_Y1ANM/s400/image+histogram.JPG" alt="" id="BLOGGER_PHOTO_ID_5354931368338296962" border="0" /&gt;&lt;/a&gt;&lt;span style="font-style: italic;"&gt;Image Properties:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;filename:  C:\Documents and Settings\mimie\Desktop\leafginv.jpg&lt;/span&gt; &lt;span style="color: rgb(51, 102, 255);"&gt;&lt;br /&gt;filesize:7359&lt;/span&gt; &lt;span style="color: rgb(51, 102, 255);"&gt;&lt;br /&gt;format: jpeg&lt;/span&gt; &lt;span style="color: rgb(51, 102, 255);"&gt;&lt;br /&gt;width: 207&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;height: 138&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;depth: 8&lt;/span&gt; &lt;span style="color: rgb(51, 102, 255);"&gt;&lt;br /&gt;storage type: indexed&lt;/span&gt; &lt;span style="color: rgb(51, 102, 255);"&gt;&lt;br /&gt;number of colors: 256&lt;/span&gt; &lt;span style="color: rgb(51, 102, 255);"&gt;&lt;br /&gt;resolution unit: inch&lt;/span&gt; &lt;span style="color: rgb(51, 102, 255);"&gt;&lt;br /&gt;x resolution: 0&lt;/span&gt; &lt;span style="color: rgb(51, 102, 255);"&gt;&lt;br /&gt;y resolution: 0&lt;/span&gt;  &lt;span style="color: rgb(51, 102, 255);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;br /&gt;The histogram of a grayscale image runs from 0 to 255, 0 being black and 255 being white. From the histogram obtained, it can be seen that the ROI (around the second peak) is well separated from the background (the first peak). Also,the threshold value when this image is to be converted into binary is somewhere between 50/255 to 120/255. I used the average [(120+50)/2]/255 as the threshold value and obtained&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6vBS5HyEno4/SlCMzjA-ObI/AAAAAAAAAEE/1Xt4_Tjh7NI/s1600-h/leafbnw.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 216px; height: 145px;" src="http://3.bp.blogspot.com/_6vBS5HyEno4/SlCMzjA-ObI/AAAAAAAAAEE/1Xt4_Tjh7NI/s400/leafbnw.JPG" alt="" id="BLOGGER_PHOTO_ID_5354934774144055730" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 204, 204);"&gt;Converting to binary image (in the command window):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center; color: rgb(255, 0, 0);"&gt;i=im2bw(I,85/255);&lt;br /&gt;imshow(i)                 &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Using the area calculation from 1, the area obtained using Green's theorem, by pixel counting, and the relative error between the two are:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;area = 15979&lt;/span&gt; &lt;span style="color: rgb(51, 102, 255);"&gt;&lt;br /&gt;theo = 15978&lt;/span&gt; &lt;span style="color: rgb(51, 102, 255);"&gt;&lt;br /&gt;%error: 0.0062586&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To verify the threshold values obtained using scilab, Gimp can be used.&lt;br /&gt;&lt;br /&gt;1. Click 'Colors' --&gt;'Threshold' (This will turn the grayscale image into black and white.)&lt;br /&gt;2. Adjust the arrows (or the values) until the ROI is well separated from the background&lt;br /&gt;3. The threshold value for the image is just the minimum/maximum.&lt;br /&gt;&lt;br /&gt;Acknowledgemets to Jeric Tugaff for the histogram code (posted in Ma'am Jing's blog) and Ma'am Jing for her suggestions.&lt;br /&gt;&lt;br /&gt;I give myself a 9/10 for this activity.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-7712191738615897675?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/7712191738615897675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/06/activity-3-image-types-and-basic-image.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/7712191738615897675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/7712191738615897675'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/06/activity-3-image-types-and-basic-image.html' title='Activity 3: Image Types and Basic Image Enhancement'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_6vBS5HyEno4/Skjno-prR5I/AAAAAAAAADU/VARsBTN0E9U/s72-c/rgb.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-1679937802628546117</id><published>2009-06-24T07:19:00.000-07:00</published><updated>2009-07-06T05:28:47.376-07:00</updated><title type='text'>Activity 2: Area Estimation for Images with Defined Edges</title><content type='html'>&lt;span style="font-size:85%;"&gt;For this&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt; &lt;/span&gt;&lt;span style="font-size:85%;"&gt;activity, Green's theorem is used to estimate the area of a binary image with defined edges. The edges of the images were obtained using the "follow" comma&lt;/span&gt;&lt;span style="font-size:85%;"&gt;nd in Scilab. Area estimation of Green's theorem is&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SkY4oA83HqI/AAAAAAAAABE/Chq-0VYzV5Y/s1600-h/greens.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 196px; height: 67px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SkY4oA83HqI/AAAAAAAAABE/Chq-0VYzV5Y/s320/greens.bmp" alt="" id="BLOGGER_PHOTO_ID_5352027467277606562" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SkY4oA83HqI/AAAAAAAAABE/Chq-0VYzV5Y/s1600-h/greens.bmp"&gt; &lt;/a&gt;The theoretical value for the area was obtained&lt;/span&gt;&lt;span style="font-size:85%;"&gt; by counting how many pixels with values of 1.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;The code&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;1&lt;/span&gt;&lt;span style="font-size:85%;"&gt;    Image=imread("C:\Documents and Settings\mimie\Desktop\hand.bmp"); //read image file&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;2 &lt;/span&gt;&lt;span style="font-size:85%;"&gt;   I = im2bw(Image,1); //convert image to binary&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;3&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;4&lt;/span&gt;&lt;span style="font-size:85%;"&gt;    [x,y]=follow(I); //get the contour of the image&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;5&lt;/span&gt;&lt;span style="font-size:85%;"&gt;    A=[];&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;6&lt;/span&gt;&lt;span style="font-size:85%;"&gt;    lx=length(x);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;7&lt;/span&gt;&lt;span style="font-size:85%;"&gt;    ly=length(y);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;8&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;9&lt;/span&gt;&lt;span style="font-size:85%;"&gt;    //close the contour&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;10&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  x(lx + 1)=x(1);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;11&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  y(ly + 1)=y(1);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;12&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;13&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  for i=2:lx;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;14 &lt;/span&gt;&lt;span style="font-size:85%;"&gt;       A(i) = (x(i)*y(i+1))-(x(i+1)*y(i)); //area of the ith triangle&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;15&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  end&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;16&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;17&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  Area = (0.5*sum(A)) //Green's Theorem&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;18&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  theo = sum(I)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;19&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  err = abs((Area-theo)/theo);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;20&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  %err = 100.*err //percent error&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;The above code is implemented on the images below:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SkY_FjFt8GI/AAAAAAAAABU/muXlEENeris/s1600-h/star.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 157px; height: 129px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SkY_FjFt8GI/AAAAAAAAABU/muXlEENeris/s320/star.bmp" alt="" id="BLOGGER_PHOTO_ID_5352034571727532130" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SkZDDk_tGaI/AAAAAAAAABs/q1p_pPW6vEs/s1600-h/flower.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 146px; height: 139px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SkZDDk_tGaI/AAAAAAAAABs/q1p_pPW6vEs/s320/flower.bmp" alt="" id="BLOGGER_PHOTO_ID_5352038935925954978" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SkZCdZYuVMI/AAAAAAAAABc/qNVJA4I066U/s1600-h/hand.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 90px; height: 85px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SkZCdZYuVMI/AAAAAAAAABc/qNVJA4I066U/s320/hand.bmp" alt="" id="BLOGGER_PHOTO_ID_5352038279974638786" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SkZCrVBeGmI/AAAAAAAAABk/zKC88PjwjJw/s1600-h/batman.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 243px; height: 91px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SkZCrVBeGmI/AAAAAAAAABk/zKC88PjwjJw/s320/batman.bmp" alt="" id="BLOGGER_PHOTO_ID_5352038519321533026" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;with th&lt;/span&gt;&lt;span style="font-size:85%;"&gt;e&lt;/span&gt;&lt;span style="font-size:85%;"&gt; foll&lt;/span&gt;&lt;span style="font-size:85%;"&gt;owing results&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/Skha_mPvR0I/AAAAAAAAACk/JrGoN--5QfI/s1600-h/results2.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 74px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/Skha_mPvR0I/AAAAAAAAACk/JrGoN--5QfI/s400/results2.jpg" alt="" id="BLOGGER_PHOTO_ID_5352628205774653250" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The error is mainly because of the "follow" command. Since this command is a contour follower, the effective area as estimated by the Green's theorem is lessen by the pixel counts containing the contour. For example a 100x100 square image  should have an area of 10000. Using the code above, an area of 9806 is obtained which corresponds to about 99x99 square. This means that the calculation for area starts  &lt;span style="font-style: italic; color: rgb(51, 102, 255); font-weight: bold;"&gt;inside&lt;/span&gt; the contour and not &lt;span style="font-style: italic; color: rgb(51, 102, 255); font-weight: bold;"&gt;at&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt; &lt;/span&gt;the contour itself. To compensate this, an extra 0.5 lx term is subtracted from the pixel count &lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;(line 18: theo = sum(I) - 0.5*lx)&lt;/span&gt;&lt;span style="font-size:85%;"&gt;. The relative error is lessened when this is done.&lt;br /&gt;&lt;br /&gt;Raffy and Cherry helped me in this activity. Thank you also to Miguel for troubleshooting the SIP toolbox. For this activity, I give myself a 9/10.  &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-1679937802628546117?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/1679937802628546117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/06/ap186-activity-2-area-estimation-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/1679937802628546117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/1679937802628546117'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/06/ap186-activity-2-area-estimation-for.html' title='Activity 2: Area Estimation for Images with Defined Edges'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_6vBS5HyEno4/SkY4oA83HqI/AAAAAAAAABE/Chq-0VYzV5Y/s72-c/greens.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7546939043065849431.post-1459579033141523976</id><published>2009-06-17T20:25:00.000-07:00</published><updated>2009-07-06T05:29:09.287-07:00</updated><title type='text'>Activity 1: DIGITAL SCANNING</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/Sjn0bojio3I/AAAAAAAAAAc/E5gZfswqL8U/s1600-h/mimie.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 301px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/Sjn0bojio3I/AAAAAAAAAAc/E5gZfswqL8U/s320/mimie.jpg" alt="" id="BLOGGER_PHOTO_ID_5348574788059308914" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In this activity, ratio and proportion was used to find the numerical values of a digitally scanned plot above. The following steps were followed:&lt;br /&gt;&lt;br /&gt;1. The plot was cropped using Paint.&lt;br /&gt;2. Paint was used to find the pixel locations of the data points considered in the plot.&lt;br /&gt;3. MS Excel was used to determine the numerical values in the scanned plot.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;         All pixel locations were adjusted such that the pixel location of the origin (121,452) becomes (0,0). Hence all pixel locations of the data points were adjusted using the formula&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: center;"&gt;                                                       X = Xpixel - 121&lt;br /&gt;                                    Y = 452 - Ypixel&lt;br /&gt;&lt;/div&gt;                 where Xpixel and Ypixel are the pixel locations of the data points.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;         The numerical values were determined using the formula&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: center;"&gt;                                                                   Xphys = (X*Xp)+5&lt;br /&gt;                                                                Yphys = Y*Yp&lt;br /&gt;&lt;/div&gt;                    where Xp = 5/107.1429 and Yp = 2/53.30769 are number of pixels per division in the X and Y axis, respectively.&lt;br /&gt;&lt;br /&gt;      Note that the +5 in Xphys value is due to the fact that the original plot started at (5,0) and not at (0,0).&lt;br /&gt;&lt;br /&gt;The reconstructed plot superimposed with the original plot is shown below:&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6vBS5HyEno4/SjnzGElEyjI/AAAAAAAAAAU/GgYPW0P66f4/s1600-h/plot.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 253px;" src="http://4.bp.blogspot.com/_6vBS5HyEno4/SjnzGElEyjI/AAAAAAAAAAU/GgYPW0P66f4/s320/plot.jpg" alt="" id="BLOGGER_PHOTO_ID_5348573318113184306" border="0" /&gt;&lt;/a&gt;Notice also that the reconstructed plot has a minimum of -12 instead -10 in its axis. This is because the lowest point in  the plot has a y value of less than -10 as can be seen from the original plot. The formula used to get the numerical values are applicable only if the plot considered has axes of equal intervals per division. It can also be used without the +5 offset if the plot considered has an origin at (0,0)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;For this activity, I give myself a score of 8/10 since I didn't finish it during class hours. I would also like to acknowledge Janno and Raffy for teaching me how to superimpose the original and reconstructed plots using Open Office and Kaye for her suggestions on offsetting the pixel locations.&lt;br /&gt;&lt;br /&gt;The original plot was taken from the book "Outlines of Biochemistry" by Gortner, R. published in 1938. **&lt;br /&gt;&lt;br /&gt;**no title page was available from the book&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7546939043065849431-1459579033141523976?l=ap186-ni-moy.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ap186-ni-moy.blogspot.com/feeds/1459579033141523976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/06/ap186-activity-1-digital-scanning.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/1459579033141523976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7546939043065849431/posts/default/1459579033141523976'/><link rel='alternate' type='text/html' href='http://ap186-ni-moy.blogspot.com/2009/06/ap186-activity-1-digital-scanning.html' title='Activity 1: DIGITAL SCANNING'/><author><name>momoy</name><uri>http://www.blogger.com/profile/11482361405194273767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_6vBS5HyEno4/Sjn0bojio3I/AAAAAAAAAAc/E5gZfswqL8U/s72-c/mimie.jpg' height='72' width='72'/><thr:total>1</thr:total></entry></feed>
