<?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-1657424262821979330</id><updated>2011-07-29T10:49:26.620+08:00</updated><title type='text'>Liknayang Inaplay 186</title><subtitle type='html'>Gilbert's Applied Physics 186 Blog</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>19</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-2626209877673799292</id><published>2009-09-24T08:49:00.070+08:00</published><updated>2009-10-08T22:44:33.930+08:00</updated><title type='text'>Activity 19 - Restoration of Blurred Image</title><content type='html'>&lt;div style="text-align: justify;"&gt;This last activity is about demonstration of restoration of a corrupted grayscale image with a known degradation function which in this case is motion blur and additive noise using Weiner filtering.&lt;br /&gt;&lt;br /&gt;The following schematic diagram is a model of the image degradation and restoration process.&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/_kx7Z922tJd0/Ss2YphgUmTI/AAAAAAAABAo/F16LYdU8Nus/s1600-h/degrade+restore.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 112px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Ss2YphgUmTI/AAAAAAAABAo/F16LYdU8Nus/s320/degrade+restore.bmp" alt="" id="BLOGGER_PHOTO_ID_5390132168168347954" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;From the diagram, &lt;span style="font-style: italic;"&gt;f_hat(x, y)&lt;/span&gt; is the approximate original image after the degraded image passes through one or more restoration filters, then the degraded image in the spatial domain can then be written in an equation as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss2eKDRrY4I/AAAAAAAABAw/4I5bOuVYFZY/s1600-h/spatial+degrade.bmp"&gt;&lt;img style="cursor: pointer; width: 184px; height: 21px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss2eKDRrY4I/AAAAAAAABAw/4I5bOuVYFZY/s320/spatial+degrade.bmp" alt="" id="BLOGGER_PHOTO_ID_5390138224547685250" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Here, &lt;span style="font-style: italic;"&gt;h(x, y)&lt;/span&gt; represents the degradation function, &lt;span style="font-style: italic;"&gt;f(x, y)&lt;/span&gt; is the original image and &lt;span style="font-style: italic;"&gt;n(x, y) &lt;/span&gt;embodies the added noise. Meanwhile, its frequency representation in Fourier space is shown below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss2eKmzNruI/AAAAAAAABA4/lW4nrD5BXCs/s1600-h/frequency+degrade.bmp"&gt;&lt;img style="cursor: pointer; width: 177px; height: 21px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss2eKmzNruI/AAAAAAAABA4/lW4nrD5BXCs/s320/frequency+degrade.bmp" alt="" id="BLOGGER_PHOTO_ID_5390138234083585762" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The transfer function of image degradation implemented here is the following.&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/_kx7Z922tJd0/Ss2eLdng0WI/AAAAAAAABBE/PFnWrUb6AbI/s1600-h/blur+function.bmp"&gt;&lt;img style="cursor: pointer; width: 246px; height: 40px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Ss2eLdng0WI/AAAAAAAABBE/PFnWrUb6AbI/s320/blur+function.bmp" alt="" id="BLOGGER_PHOTO_ID_5390138248798458210" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The variable &lt;span style="font-style: italic;"&gt;T&lt;/span&gt; corresponds to the duration of exposure while &lt;span style="font-style: italic;"&gt;a&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;b&lt;/span&gt; are the blurring displacements in the horizontal or &lt;span style="font-style: italic;"&gt;x&lt;/span&gt; and vertical or &lt;span style="font-style: italic;"&gt;y&lt;/span&gt; direction respectively.&lt;br /&gt;In restoring the original image, the estimate image &lt;span style="font-style: italic;"&gt;f_hat&lt;/span&gt; and the corrupted image &lt;span style="font-style: italic;"&gt;f&lt;/span&gt; must have minimum mean square error between them. This condition is satisfied through the expression as follows called the minimum mean square error filter or the Weiner filter.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss2eMIUfpMI/AAAAAAAABBQ/KLInm06ZXiE/s1600-h/weiner+filter.bmp"&gt;&lt;img style="cursor: pointer; width: 254px; height: 90px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss2eMIUfpMI/AAAAAAAABBQ/KLInm06ZXiE/s320/weiner+filter.bmp" alt="" id="BLOGGER_PHOTO_ID_5390138260261414082" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Note that the power spectrum of the noise and the original image are included in the Weiner filter which are shown below.&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/_kx7Z922tJd0/Ss2eVzUe2II/AAAAAAAABBo/5ud7Ge0hbE0/s1600-h/power+spectrum.bmp"&gt;&lt;img style="cursor: pointer; width: 109px; height: 56px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Ss2eVzUe2II/AAAAAAAABBo/5ud7Ge0hbE0/s320/power+spectrum.bmp" alt="" id="BLOGGER_PHOTO_ID_5390138426422909058" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The power spectrum is similar to the modulus of the degradation transfer function as in the following equation.&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/_kx7Z922tJd0/Ss2eWRaZWtI/AAAAAAAABBw/noVFMhtqPG4/s1600-h/H+modulus.bmp"&gt;&lt;img style="cursor: pointer; width: 153px; height: 28px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Ss2eWRaZWtI/AAAAAAAABBw/noVFMhtqPG4/s320/H+modulus.bmp" alt="" id="BLOGGER_PHOTO_ID_5390138434500778706" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;As usual the first factor in the right hand side of the expression above denotes the complex conjugate of &lt;span style="font-style: italic;"&gt;H(u, v)&lt;/span&gt;.&lt;br /&gt;In most cases, the power spectrum of the noise and undergraded image are not known, hence the Weiner filter can be approximated in the expression as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss2eMkuCTVI/AAAAAAAABBc/cyY6ByppEsU/s1600-h/weiner+filter+K.bmp"&gt;&lt;img style="cursor: pointer; width: 221px; height: 56px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss2eMkuCTVI/AAAAAAAABBc/cyY6ByppEsU/s320/weiner+filter+K.bmp" alt="" id="BLOGGER_PHOTO_ID_5390138267884735826" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Instead of the power spectra, it is replaced by &lt;span style="font-style: italic;"&gt;K&lt;/span&gt; which is a constant that can be varied.&lt;br /&gt;&lt;br /&gt;At first, the following grayscale image is obtained from the internet.&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/_kx7Z922tJd0/Ss2VVkJUzdI/AAAAAAAABAg/htJd1p4F4WY/s1600-h/bwdissidia.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Ss2VVkJUzdI/AAAAAAAABAg/htJd1p4F4WY/s320/bwdissidia.bmp" alt="" id="BLOGGER_PHOTO_ID_5390128526744931794" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Source: &lt;span style="font-style: italic;"&gt;http://tvtropes.org/pmwiki/pmwiki.php/Main/Ptitlefjcz80qe&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A Gaussian noise with mean and standard deviation of 0.02 is then applied to the image. Next, the degradation transfer function parameters a, b, and T are varied resulting to the set of images as shown below (Arranged from top to bottom, left to right).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;For &lt;span style="font-style: italic;"&gt;T = 1&lt;/span&gt;: (1) &lt;span style="font-style: italic;"&gt;a = 0.1, b = 0.1&lt;/span&gt;; (2) &lt;span style="font-style: italic;"&gt;a = 0.01, b = 0.01&lt;/span&gt;; (3) &lt;span style="font-style: italic;"&gt;a = 0.001, b = 0.001&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss3rx0Hh0yI/AAAAAAAABB4/PK9sBDfCq3k/s1600-h/noisy+blurred_a01_b01_T1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss3rx0Hh0yI/AAAAAAAABB4/PK9sBDfCq3k/s320/noisy+blurred_a01_b01_T1.bmp" alt="" id="BLOGGER_PHOTO_ID_5390223570068689698" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss3ryMA7xoI/AAAAAAAABCA/2q6K3RouZ0I/s1600-h/noisy+blurred_a001_b001_T1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss3ryMA7xoI/AAAAAAAABCA/2q6K3RouZ0I/s320/noisy+blurred_a001_b001_T1.bmp" alt="" id="BLOGGER_PHOTO_ID_5390223576483481218" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss3rymzxxFI/AAAAAAAABCI/QeNHcRNX3lc/s1600-h/noisy+blurred_a0001_b0001_T1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss3rymzxxFI/AAAAAAAABCI/QeNHcRNX3lc/s320/noisy+blurred_a0001_b0001_T1.bmp" alt="" id="BLOGGER_PHOTO_ID_5390223583676056658" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;For &lt;span style="font-style: italic;"&gt;a = 0.01, b = 0.01&lt;/span&gt;: (1) &lt;span style="font-style: italic;"&gt;T = 0.01&lt;/span&gt;; (2) &lt;span style="font-style: italic;"&gt;T = 0.1&lt;/span&gt;; (3) &lt;span style="font-style: italic;"&gt;T = 10&lt;/span&gt;; (4) &lt;span style="font-style: italic;"&gt;T = 100&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss3tSzY5kQI/AAAAAAAABCQ/VdIXZEzCk7c/s1600-h/noisy+blurred_a001_b001_T001.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss3tSzY5kQI/AAAAAAAABCQ/VdIXZEzCk7c/s320/noisy+blurred_a001_b001_T001.bmp" alt="" id="BLOGGER_PHOTO_ID_5390225236320424194" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss3tTTPPevI/AAAAAAAABCY/aiwtfeCJBWc/s1600-h/noisy+blurred_a001_b001_T01.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss3tTTPPevI/AAAAAAAABCY/aiwtfeCJBWc/s320/noisy+blurred_a001_b001_T01.bmp" alt="" id="BLOGGER_PHOTO_ID_5390225244869851890" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/Ss3tT-vnsJI/AAAAAAAABCg/TE2hxC-UXTQ/s1600-h/noisy+blurred_a001_b001_T10.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Ss3tT-vnsJI/AAAAAAAABCg/TE2hxC-UXTQ/s320/noisy+blurred_a001_b001_T10.bmp" alt="" id="BLOGGER_PHOTO_ID_5390225256548380818" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss3tUKX4_sI/AAAAAAAABCo/McY0HNpNSlM/s1600-h/noisy+blurred_a001_b001_T100.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss3tUKX4_sI/AAAAAAAABCo/McY0HNpNSlM/s320/noisy+blurred_a001_b001_T100.bmp" alt="" id="BLOGGER_PHOTO_ID_5390225259670077122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;For constant exposure time, it can be observed that the degraded image becomes more discernible as the blurring displacements &lt;span style="font-style: italic;"&gt;a&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;b&lt;/span&gt; decrease. Meanwhile, for constant blurring displacements, the added Gaussian noise is masked by the blurred image as the exposure time &lt;span style="font-style: italic;"&gt;T&lt;/span&gt; increases.&lt;br /&gt;Shown as follows are the restored images using Weiner filtering with the spectrum of the noise and undergraded image for different degradation transfer function parameters (Arranged from top to bottom, left to right).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;For &lt;span style="font-style: italic;"&gt;T = 1&lt;/span&gt;: (1) &lt;span style="font-style: italic;"&gt;a = 0.1, b = 0.1&lt;/span&gt;; (2) &lt;span style="font-style: italic;"&gt;a = 0.01, b = 0.01&lt;/span&gt;; (3) &lt;span style="font-style: italic;"&gt;a = 0.001, b = 0.001&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Ss3x1IwJLfI/AAAAAAAABCw/hO7djqLlKZI/s1600-h/restore_a01_b01_T1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Ss3x1IwJLfI/AAAAAAAABCw/hO7djqLlKZI/s320/restore_a01_b01_T1.bmp" alt="" id="BLOGGER_PHOTO_ID_5390230224217124338" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Ss3x1p1TVaI/AAAAAAAABC4/DxYjjMns41M/s1600-h/restore_a001_b001_T1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Ss3x1p1TVaI/AAAAAAAABC4/DxYjjMns41M/s320/restore_a001_b001_T1.bmp" alt="" id="BLOGGER_PHOTO_ID_5390230233097131426" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Ss3x2LT9btI/AAAAAAAABDA/cvEvMbHjhoo/s1600-h/restore_a0001_b0001_T1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Ss3x2LT9btI/AAAAAAAABDA/cvEvMbHjhoo/s320/restore_a0001_b0001_T1.bmp" alt="" id="BLOGGER_PHOTO_ID_5390230242084089554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;For &lt;span style="font-style: italic;"&gt;a = 0.01, b = 0.01&lt;/span&gt;: (1) &lt;span style="font-style: italic;"&gt;T = 0.01&lt;/span&gt;; (2) &lt;span style="font-style: italic;"&gt;T = 0.1&lt;/span&gt;; (3) &lt;span style="font-style: italic;"&gt;T = 10&lt;/span&gt;; (4) &lt;span style="font-style: italic;"&gt;T = 100&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss3yhAp30FI/AAAAAAAABDI/U48i64w0okw/s1600-h/restore_a001_b001_T001.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss3yhAp30FI/AAAAAAAABDI/U48i64w0okw/s320/restore_a001_b001_T001.bmp" alt="" id="BLOGGER_PHOTO_ID_5390230977957580882" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss3yhRcvuZI/AAAAAAAABDQ/dOLDIZBjQjQ/s1600-h/restore_a001_b001_T01.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss3yhRcvuZI/AAAAAAAABDQ/dOLDIZBjQjQ/s320/restore_a001_b001_T01.bmp" alt="" id="BLOGGER_PHOTO_ID_5390230982465927570" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/Ss3yh25DNxI/AAAAAAAABDY/wmpb_pegpiI/s1600-h/restore_a001_b001_T10.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Ss3yh25DNxI/AAAAAAAABDY/wmpb_pegpiI/s320/restore_a001_b001_T10.bmp" alt="" id="BLOGGER_PHOTO_ID_5390230992516757266" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss3yiYfaNGI/AAAAAAAABDg/_iZAIIsmmeA/s1600-h/restore_a001_b001_T100.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss3yiYfaNGI/AAAAAAAABDg/_iZAIIsmmeA/s320/restore_a001_b001_T100.bmp" alt="" id="BLOGGER_PHOTO_ID_5390231001536017506" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Apparently, the restoration approaches the original image as the blurring displacements decrease as well as the exposure time increases.&lt;br /&gt;The following last set of images is composed of restored images using Weiner filter with varying &lt;span style="font-style: italic;"&gt;K&lt;/span&gt; values (Arranged from top to bottom, left to right).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;For &lt;span style="font-style: italic;"&gt;a = 0.01, b = 0.01, T = 1&lt;/span&gt;: (1) &lt;span style="font-style: italic;"&gt;K = 0&lt;/span&gt;; (2) &lt;span style="font-style: italic;"&gt;K = 0.000001&lt;/span&gt;; (3) &lt;span style="font-style: italic;"&gt;K = 0.00001&lt;/span&gt;; (4) &lt;span style="font-style: italic;"&gt;K = 0.0001&lt;/span&gt;; (5) &lt;span style="font-style: italic;"&gt;K = 0.001&lt;/span&gt;; (6) &lt;span style="font-style: italic;"&gt;K = 0.01&lt;/span&gt;; (7) &lt;span style="font-style: italic;"&gt;K = 0.1&lt;/span&gt;; (8) &lt;span style="font-style: italic;"&gt;K = 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss31alvu9nI/AAAAAAAABDo/wphHO1VcKhM/s1600-h/restoreK0.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss31alvu9nI/AAAAAAAABDo/wphHO1VcKhM/s320/restoreK0.bmp" alt="" id="BLOGGER_PHOTO_ID_5390234166190077554" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Ss31bONNaMI/AAAAAAAABDw/rLw73RKGHh8/s1600-h/restoreK0000001.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Ss31bONNaMI/AAAAAAAABDw/rLw73RKGHh8/s320/restoreK0000001.bmp" alt="" id="BLOGGER_PHOTO_ID_5390234177051125954" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/Ss31bU1Jf6I/AAAAAAAABD4/vpUWhHNpcCc/s1600-h/restoreK000001.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Ss31bU1Jf6I/AAAAAAAABD4/vpUWhHNpcCc/s320/restoreK000001.bmp" alt="" id="BLOGGER_PHOTO_ID_5390234178829254562" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Ss31b4Qy17I/AAAAAAAABEA/ctDqA6wWfvs/s1600-h/restoreK00001.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Ss31b4Qy17I/AAAAAAAABEA/ctDqA6wWfvs/s320/restoreK00001.bmp" alt="" id="BLOGGER_PHOTO_ID_5390234188340451250" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss311nPhMWI/AAAAAAAABEI/rMmiZsLVFLY/s1600-h/restoreK0001.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss311nPhMWI/AAAAAAAABEI/rMmiZsLVFLY/s320/restoreK0001.bmp" alt="" id="BLOGGER_PHOTO_ID_5390234630448296290" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss312H_4TFI/AAAAAAAABEQ/KtO4OSx_Io8/s1600-h/restoreK001.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss312H_4TFI/AAAAAAAABEQ/KtO4OSx_Io8/s320/restoreK001.bmp" alt="" id="BLOGGER_PHOTO_ID_5390234639241071698" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss312tUVVmI/AAAAAAAABEY/zrqqFG0rafQ/s1600-h/restoreK01.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Ss312tUVVmI/AAAAAAAABEY/zrqqFG0rafQ/s320/restoreK01.bmp" alt="" id="BLOGGER_PHOTO_ID_5390234649258972770" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss313C60lKI/AAAAAAAABEg/mAqLZg_NmUI/s1600-h/restoreK1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 238px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Ss313C60lKI/AAAAAAAABEg/mAqLZg_NmUI/s320/restoreK1.bmp" alt="" id="BLOGGER_PHOTO_ID_5390234655057548450" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be noticed that since a constant, which is based from the ratio of the power spectrum of the noise to the undergraded image, is added in all the elements of the matrix in the process Weiner filtering, the added Gaussian noise is eliminated at the same time magnifying the blurring effect as &lt;span style="font-style: italic;"&gt;K&lt;/span&gt; increases.&lt;br /&gt;Weiner filtering with the power spectrum of the noise and the undergraded image is then recommended to be used when the power spectrum of the added noise and the undergraded image is known and also with minimal degradation while Weiner filtering with the constant &lt;span style="font-style: italic;"&gt;K&lt;/span&gt; is more applicable for various corrupted image even without the power spectra as long as &lt;span style="font-style: italic;"&gt;K&lt;/span&gt; is carefully chosen.&lt;br /&gt;&lt;br /&gt;Since I am able to demonstrate a corrupted image with motion blur and additive noise, and restore it using Weiner filtering successfully, I grade myself 10/10.&lt;br /&gt;&lt;br /&gt;I have worked individually in this activity however I have shared my insights to my classmates.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code below is utilized in this activity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;stacksize(4e7);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;image = gray_imread('dissidia.jpg');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(image, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(normal(image), 'bwdissidia.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;s = size(image);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;noise_gauss = grand(s(1), s(2), 'nor', 0.02, 0.02);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;noisy_image = image + noise_gauss;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;N = fft2(noise_gauss);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;F = fft2(image);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a = 0.01;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;b = 0.01;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;T = 1;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;H = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 1:s(1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for j = 1:s(2)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;H(i, j) = (T/(%pi*(i*a + j*b)))*(sin(%pi*(i*a + j*b)))*exp(-%i*%pi*(i*a + j*b));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;G = H.*F + N;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;noisy_blurred = abs(ifft(G));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(noisy_blurred, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(normal(noisy_blurred), 'noisy blurred_a001_b001_T1.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;SN = N.*conj(N);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;SF = F.*conj(F);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;restore1 = (((1)./H).*((H.*conj(H))./((H.*conj(H)) + (SN./SF)))).*G;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;restore1 = abs(ifft(restore1));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(restore1, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(normal(restore1), 'restore_a001_b001_T1.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;K = 0.01;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;restore2 = (((1)./H).*((H.*conj(H))./((H.*conj(H)) + K))).*G;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;restore2 = abs(ifft(restore2));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(restore2, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(normal(restore2), 'restoreK001.bmp');&lt;/span&gt;&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/1657424262821979330-2626209877673799292?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/2626209877673799292/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/09/activity-19-restoration-of-blurred.html#comment-form' title='39 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/2626209877673799292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/2626209877673799292'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/09/activity-19-restoration-of-blurred.html' title='Activity 19 - Restoration of Blurred Image'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_kx7Z922tJd0/Ss2YphgUmTI/AAAAAAAABAo/F16LYdU8Nus/s72-c/degrade+restore.bmp' height='72' width='72'/><thr:total>39</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-6190222948883074823</id><published>2009-09-15T09:06:00.150+08:00</published><updated>2009-09-24T22:34:11.736+08:00</updated><title type='text'>Activity 18 - Noise Models and Basic Image Restoration</title><content type='html'>&lt;div style="text-align: justify;"&gt;In this activity, various noise models are applied in grayscale images, then different basic image restoration techniques are tested in recovering the original images.&lt;br /&gt;&lt;br /&gt;Like in a grayscale image, noise is characterized by a probability distribution function (PDF). However, its PDF consists of random variables with parameters such as mean and standard deviation that may be altered.&lt;br /&gt;The following are the most common noise models encountered in image processing. First below is the PDF of Gaussian noise which obviously follows a Gaussian curve with &lt;span style="font-style: italic;"&gt;mu&lt;/span&gt; as its mean and &lt;span style="font-style: italic;"&gt;sigma&lt;/span&gt; as its standard deviation.&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/_kx7Z922tJd0/SrYF6_Fu7lI/AAAAAAAAAzY/wCdtqpccHfo/s1600-h/gaussian.bmp"&gt;&lt;img style="cursor: pointer; width: 169px; height: 48px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrYF6_Fu7lI/AAAAAAAAAzY/wCdtqpccHfo/s320/gaussian.bmp" alt="" id="BLOGGER_PHOTO_ID_5383496915494039122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The random variable &lt;span style="font-style: italic;"&gt;z&lt;/span&gt; represents the grayscale value in the noise.&lt;br /&gt;The PDF of Rayleigh noise is given as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYF7GYnG2I/AAAAAAAAAzg/V_U6ribmhtk/s1600-h/rayleigh.bmp"&gt;&lt;img style="cursor: pointer; width: 208px; height: 69px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYF7GYnG2I/AAAAAAAAAzg/V_U6ribmhtk/s320/rayleigh.bmp" alt="" id="BLOGGER_PHOTO_ID_5383496917452266338" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Its mean and variance are the following.&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/_kx7Z922tJd0/SrYF7qJWcsI/AAAAAAAAAzo/zvmm1gFz7hM/s1600-h/rayleigh+mean.bmp"&gt;&lt;img style="cursor: pointer; width: 74px; height: 42px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrYF7qJWcsI/AAAAAAAAAzo/zvmm1gFz7hM/s320/rayleigh+mean.bmp" alt="" id="BLOGGER_PHOTO_ID_5383496927051936450" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYF7ylI4ZI/AAAAAAAAAzw/qGdR3Z0Tjk0/s1600-h/rayleigh+stdv.bmp"&gt;&lt;img style="cursor: pointer; width: 81px; height: 38px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYF7ylI4ZI/AAAAAAAAAzw/qGdR3Z0Tjk0/s320/rayleigh+stdv.bmp" alt="" id="BLOGGER_PHOTO_ID_5383496929315971474" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Next below is the PDF of Erlang or Gamma noise.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrYF8cKxw6I/AAAAAAAAAz4/yWN2_m2leUY/s1600-h/gamma.bmp"&gt;&lt;img style="cursor: pointer; width: 168px; height: 61px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrYF8cKxw6I/AAAAAAAAAz4/yWN2_m2leUY/s320/gamma.bmp" alt="" id="BLOGGER_PHOTO_ID_5383496940479693730" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Whereas its mean and variance are shown as follows.&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/_kx7Z922tJd0/SrYGJWQPOiI/AAAAAAAAA0A/rLwbRlGGuSg/s1600-h/gamma+mean.bmp"&gt;&lt;img style="cursor: pointer; width: 38px; height: 38px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrYGJWQPOiI/AAAAAAAAA0A/rLwbRlGGuSg/s320/gamma+mean.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497162230282786" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYGJrTJXnI/AAAAAAAAA0I/wu6YQHp-H-8/s1600-h/gamma+stdv.bmp"&gt;&lt;img style="cursor: pointer; width: 56px; height: 40px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYGJrTJXnI/AAAAAAAAA0I/wu6YQHp-H-8/s320/gamma+stdv.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497167879626354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;PDF of exponential noise is described by the following equations.&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/_kx7Z922tJd0/SrYGKBz1lvI/AAAAAAAAA0Q/sw5O83-iupw/s1600-h/exp.bmp"&gt;&lt;img style="cursor: pointer; width: 132px; height: 40px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrYGKBz1lvI/AAAAAAAAA0Q/sw5O83-iupw/s320/exp.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497173922322162" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Its mean and variance are shown below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYGKbBuvGI/AAAAAAAAA0Y/DBvn6fW23LM/s1600-h/exp+mean.bmp"&gt;&lt;img style="cursor: pointer; width: 38px; height: 38px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYGKbBuvGI/AAAAAAAAA0Y/DBvn6fW23LM/s320/exp+mean.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497180691479650" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYGK0WYrUI/AAAAAAAAA0g/wSuZ8qfKW4g/s1600-h/exp+stdv.bmp"&gt;&lt;img style="cursor: pointer; width: 56px; height: 40px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYGK0WYrUI/AAAAAAAAA0g/wSuZ8qfKW4g/s320/exp+stdv.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497187489000770" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Uniform noise has the following PDF.&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/_kx7Z922tJd0/SrYGaLTZciI/AAAAAAAAA0o/Pdyzsb4q_lg/s1600-h/uni.bmp"&gt;&lt;img style="cursor: pointer; width: 126px; height: 56px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrYGaLTZciI/AAAAAAAAA0o/Pdyzsb4q_lg/s320/uni.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497451348521506" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Then its mean and variance are as follows.&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/_kx7Z922tJd0/SrYGaXZX0cI/AAAAAAAAA0w/AO2rELSiJtc/s1600-h/uni+mean.bmp"&gt;&lt;img style="cursor: pointer; width: 57px; height: 37px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrYGaXZX0cI/AAAAAAAAA0w/AO2rELSiJtc/s320/uni+mean.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497454594806210" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYGa7wYsQI/AAAAAAAAA04/jHd2Fjt2cfQ/s1600-h/uni+stdv.bmp"&gt;&lt;img style="cursor: pointer; width: 81px; height: 40px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYGa7wYsQI/AAAAAAAAA04/jHd2Fjt2cfQ/s320/uni+stdv.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497464355008770" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Lastly, impulse or better known as salt-and-pepper noise is considered here. This has PDF expressed below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrYGbJQukEI/AAAAAAAAA1A/4drxkUef9mI/s1600-h/impulse.bmp"&gt;&lt;img style="cursor: pointer; width: 108px; height: 61px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrYGbJQukEI/AAAAAAAAA1A/4drxkUef9mI/s320/impulse.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497467980320834" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Meanwhile, there are four basic image restoration techniques implemented in this activity. These are spatial filters which reduce added noise in the image.&lt;br /&gt;Arithmetic mean filter operates through the following equation.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYGbgkRlII/AAAAAAAAA1I/jWKz9tkTsHI/s1600-h/arithmetic.bmp"&gt;&lt;img style="cursor: pointer; width: 137px; height: 46px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYGbgkRlII/AAAAAAAAA1I/jWKz9tkTsHI/s320/arithmetic.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497474236322946" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;S_xy&lt;/span&gt; is a set of coordinates within a chosen rectangular sub-image window with size &lt;span style="font-style: italic;"&gt;m x n&lt;/span&gt; in the noisy image centered at &lt;span style="font-style: italic;"&gt;(x, y)&lt;/span&gt;. Hence, it filters the noise by averaging the grayscale value at &lt;span style="font-style: italic;"&gt;(x, y)&lt;/span&gt;.&lt;br /&gt;A noisy image under geometric mean filtering works with the equation as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrYGqWcFG7I/AAAAAAAAA1Q/VWSgSeCBMeQ/s1600-h/geometric.bmp"&gt;&lt;img style="cursor: pointer; width: 142px; height: 66px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrYGqWcFG7I/AAAAAAAAA1Q/VWSgSeCBMeQ/s320/geometric.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497729215634354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The harmonic mean filter which is shown below works well for salt noise or noisy pixels with grayscale values close to white but not with pepper noise or noisy pixels with grayscale values near to black.&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/_kx7Z922tJd0/SrYGqqWypGI/AAAAAAAAA1Y/8B22VdYbqyw/s1600-h/harmonic.bmp"&gt;&lt;img style="cursor: pointer; width: 129px; height: 65px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrYGqqWypGI/AAAAAAAAA1Y/8B22VdYbqyw/s320/harmonic.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497734562161762" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Lastly, contraharmonic mean filter has expression given by the following.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYGrHuDCVI/AAAAAAAAA1g/jgLhlCxF6no/s1600-h/contraharmonic.bmp"&gt;&lt;img style="cursor: pointer; width: 138px; height: 80px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYGrHuDCVI/AAAAAAAAA1g/jgLhlCxF6no/s320/contraharmonic.bmp" alt="" id="BLOGGER_PHOTO_ID_5383497742444333394" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The variable &lt;span style="font-style: italic;"&gt;Q&lt;/span&gt; is called the order of the filter which may be positive that is good for pepper noise or negative that eliminates salt noise. Hence, it cannot remove both noise simultaneously.&lt;br /&gt;&lt;br /&gt;Initially, a grayscale image as follows is created from &lt;span style="font-style: italic;"&gt;Paint&lt;/span&gt; which only consists of three grayscale values.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrYwkltU29I/AAAAAAAAA1o/6pPwMy0bjGs/s1600-h/image.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrYwkltU29I/AAAAAAAAA1o/6pPwMy0bjGs/s320/image.bmp" alt="" id="BLOGGER_PHOTO_ID_5383543809723653074" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Its PDF with grayscale values ranging from 0 to 255 is plotted in the following figure.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYxGQS6_1I/AAAAAAAAA1w/t_HLeypFeM0/s1600-h/pdf+no+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrYxGQS6_1I/AAAAAAAAA1w/t_HLeypFeM0/s320/pdf+no+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383544388091314002" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Apparently, the three peaks correspond to the three grayscale values of the image. Then, using the built-in function &lt;span style="font-style: italic;"&gt;grand&lt;/span&gt; of &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt;, majority of the noise models are generated with the same size as the image (150 x 150). The image degradation is then simulated by simply adding the generated noise to the test image. Note that the parameters such as mean and standard deviation of the noise models in &lt;span style="font-style: italic;"&gt;grand&lt;/span&gt; are carefully set to prevent the merging of the three grayscale levels in the original or test image and so the noisy image is still recognizable.&lt;br /&gt;After adding Gaussian noise with mean 0.5 and standard deviation of 0.075 to the image, the image and its PDF becomes the following.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrY0TF8XaAI/AAAAAAAAA2A/CLotNQnodb8/s1600-h/image+gamma+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrY0TF8XaAI/AAAAAAAAA2A/CLotNQnodb8/s320/image+gamma+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383547907185534978" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SrYyt4rho3I/AAAAAAAAA14/Hip4FddFUic/s1600-h/pdf+gauss+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrYyt4rho3I/AAAAAAAAA14/Hip4FddFUic/s320/pdf+gauss+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383546168458453874" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;As can be observed, the Gaussian profiles have maximum near the three grayscale values implying that the noisy image is still discernable. The next set of figures are the filtered images using the arithmetic, geometric, harmonic, and contraharmonic mean filter arranged from left to right, top to bottom.&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/_kx7Z922tJd0/SrY4Zpb_9AI/AAAAAAAAA2I/WNTSvAAJ4OU/s1600-h/gauss+filtered1.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrY4Zpb_9AI/AAAAAAAAA2I/WNTSvAAJ4OU/s320/gauss+filtered1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383552417839182850" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrY4aKCy6TI/AAAAAAAAA2Q/aJbIumsSSa4/s1600-h/gauss+filtered2.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrY4aKCy6TI/AAAAAAAAA2Q/aJbIumsSSa4/s320/gauss+filtered2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383552426591840562" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SrY4aQKrpBI/AAAAAAAAA2Y/j8l95r3adA4/s1600-h/gauss+filtered3.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrY4aQKrpBI/AAAAAAAAA2Y/j8l95r3adA4/s320/gauss+filtered3.bmp" alt="" id="BLOGGER_PHOTO_ID_5383552428235531282" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrY4ajwjhTI/AAAAAAAAA2g/0fO1oOoKe4E/s1600-h/gauss+filtered4.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrY4ajwjhTI/AAAAAAAAA2g/0fO1oOoKe4E/s320/gauss+filtered4.bmp" alt="" id="BLOGGER_PHOTO_ID_5383552433494656306" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The sub-image window used for all the filters has size 3 x 3. However, the algorithm does not apply at the corners and edges of the noisy image, thus necessary boundary conditions are considered at these locations. For the contraharmonic mean filter, &lt;span style="font-style: italic;"&gt;Q&lt;/span&gt; is equal to 1. It can be observed that the arithmetic and the contraharmonic mean filters are better compared in the geometric and harmonic mean filter for the added Gaussian noise.&lt;br /&gt;Next, the Rayleigh noise is generated by first downloading a module called &lt;span style="font-style: italic;"&gt;modnum&lt;/span&gt;. Rayleigh noise generator can then be used when the loader file of the module is loaded. The function &lt;span style="font-style: italic;"&gt;genrayl&lt;/span&gt; in the module is then used with noise generator parameter set to 0.1. The resulting noisy image and its PDF after adding the Rayleigh noise are shown below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrY9Rvh9hyI/AAAAAAAAA2o/w1Tnb--vmS4/s1600-h/image+ray+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrY9Rvh9hyI/AAAAAAAAA2o/w1Tnb--vmS4/s320/image+ray+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383557779593987874" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SrY9SJIsoeI/AAAAAAAAA2w/9I2eZZDwbss/s1600-h/pdf+ray+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrY9SJIsoeI/AAAAAAAAA2w/9I2eZZDwbss/s320/pdf+ray+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383557786467344866" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The filtered images are as follows.&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/_kx7Z922tJd0/SrY95isyFZI/AAAAAAAAA24/OV_uP29xbzo/s1600-h/ray+filtered1.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrY95isyFZI/AAAAAAAAA24/OV_uP29xbzo/s320/ray+filtered1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383558463344481682" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrY96IMOr0I/AAAAAAAAA3A/h6toFMHN08U/s1600-h/ray+filtered2.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrY96IMOr0I/AAAAAAAAA3A/h6toFMHN08U/s320/ray+filtered2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383558473408491330" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrY96dgUSdI/AAAAAAAAA3I/YmIA9gCqVDs/s1600-h/ray+filtered3.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrY96dgUSdI/AAAAAAAAA3I/YmIA9gCqVDs/s320/ray+filtered3.bmp" alt="" id="BLOGGER_PHOTO_ID_5383558479129889234" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrY967frimI/AAAAAAAAA3Q/8sWLOTNXFpY/s1600-h/ray+filtered4.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrY967frimI/AAAAAAAAA3Q/8sWLOTNXFpY/s320/ray+filtered4.bmp" alt="" id="BLOGGER_PHOTO_ID_5383558487180282466" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In this type of noise, all filters work well in restoring the test image.&lt;br /&gt;Gamma noise is then added to the test image again using &lt;span style="font-style: italic;"&gt;grand&lt;/span&gt;. Its parameters shape and scale are set to 1 and 10 respectively. The following are the resulting noisy image and its PDF.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrY_mpD8EOI/AAAAAAAAA3Y/M2gmGFORzTQ/s1600-h/image+gamma+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrY_mpD8EOI/AAAAAAAAA3Y/M2gmGFORzTQ/s320/image+gamma+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383560337657958626" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrY_nMgGx8I/AAAAAAAAA3g/95bCr7TPJHQ/s1600-h/pdf+gamma+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrY_nMgGx8I/AAAAAAAAA3g/95bCr7TPJHQ/s320/pdf+gamma+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383560347171342274" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The figures with Gamma noise after using the four filters are shown below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZAX52sWAI/AAAAAAAAA3o/sb1nNNw83kc/s1600-h/gamma+filtered1.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZAX52sWAI/AAAAAAAAA3o/sb1nNNw83kc/s320/gamma+filtered1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383561183979395074" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZAYCVGStI/AAAAAAAAA3w/5M8sMWaT-SU/s1600-h/gamma+filtered2.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZAYCVGStI/AAAAAAAAA3w/5M8sMWaT-SU/s320/gamma+filtered2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383561186254408402" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZAYnftSOI/AAAAAAAAA34/vDG3Ixgj_j4/s1600-h/gamma+filtered3.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZAYnftSOI/AAAAAAAAA34/vDG3Ixgj_j4/s320/gamma+filtered3.bmp" alt="" id="BLOGGER_PHOTO_ID_5383561196231018722" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SrZAY0bNaqI/AAAAAAAAA4A/qpodwg0HnvQ/s1600-h/gamma+filtered4.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrZAY0bNaqI/AAAAAAAAA4A/qpodwg0HnvQ/s320/gamma+filtered4.bmp" alt="" id="BLOGGER_PHOTO_ID_5383561199701813922" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The contraharmonic mean filter somehow fails in restoring the test image for the Gamma noise while the harmonic mean filter is the best filter for this case.&lt;br /&gt;The test image with added exponential noise and its PDF are as follows. The mean of the exponential noise is set to 0.1.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZBdYYdaCI/AAAAAAAAA4I/Vb10I9DSY7U/s1600-h/image+exp+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZBdYYdaCI/AAAAAAAAA4I/Vb10I9DSY7U/s320/image+exp+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383562377585059874" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZBd4CX5II/AAAAAAAAA4Q/a4dgAQ8jY_A/s1600-h/pdf+exp+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZBd4CX5II/AAAAAAAAA4Q/a4dgAQ8jY_A/s320/pdf+exp+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383562386082358402" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Notice that the PDF is similar when Gamma noise is applied. The following set of figures is the result after using the four filters in the test image with Gamma noise.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZCXEpXmXI/AAAAAAAAA4Y/kiILchHegOM/s1600-h/exp+filtered1.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZCXEpXmXI/AAAAAAAAA4Y/kiILchHegOM/s320/exp+filtered1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383563368719686002" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrZCXaDY8VI/AAAAAAAAA4g/_k_zG9zpcnE/s1600-h/exp+filtered2.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrZCXaDY8VI/AAAAAAAAA4g/_k_zG9zpcnE/s320/exp+filtered2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383563374465970514" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZCX_BPw2I/AAAAAAAAA4o/_C54MKOEPwA/s1600-h/exp+filtered3.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZCX_BPw2I/AAAAAAAAA4o/_C54MKOEPwA/s320/exp+filtered3.bmp" alt="" id="BLOGGER_PHOTO_ID_5383563384389092194" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZCYK62tfI/AAAAAAAAA4w/D5_7LCbzPxY/s1600-h/exp+filtered4.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZCYK62tfI/AAAAAAAAA4w/D5_7LCbzPxY/s320/exp+filtered4.bmp" alt="" id="BLOGGER_PHOTO_ID_5383563387583510002" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;And so the filtered images are similar to the added Gamma noise.&lt;br /&gt;Again from &lt;span style="font-style: italic;"&gt;grand&lt;/span&gt;, another noise model which is uniform noise is generated here where a uniform distribution is set from 0 to 0.2. Shown below are the noisy image and its PDF with this uniform noise.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZC-MKPTaI/AAAAAAAAA44/SzXrE7cRlHI/s1600-h/image+uniform+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZC-MKPTaI/AAAAAAAAA44/SzXrE7cRlHI/s320/image+uniform+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383564040751500706" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZC-uG5aaI/AAAAAAAAA5A/n-O49yy1d5c/s1600-h/pdf+uniform+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZC-uG5aaI/AAAAAAAAA5A/n-O49yy1d5c/s320/pdf+uniform+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383564049864288674" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The PDF indeed illustrate a uniform random grayscale values within the range of the three graylevels. Then, the restored noisy images with uniform noise through the four filters are as follows.&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/_kx7Z922tJd0/SrZDUX2T6iI/AAAAAAAAA5I/Ero99PTLFLo/s1600-h/uni+filtered1.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrZDUX2T6iI/AAAAAAAAA5I/Ero99PTLFLo/s320/uni+filtered1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383564421846264354" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZDUvHt5NI/AAAAAAAAA5Q/Zz6IB3Il8Kk/s1600-h/uni+filtered2.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZDUvHt5NI/AAAAAAAAA5Q/Zz6IB3Il8Kk/s320/uni+filtered2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383564428093285586" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrZDVGqZ1JI/AAAAAAAAA5Y/1MkmtIefVuk/s1600-h/uni+filtered3.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrZDVGqZ1JI/AAAAAAAAA5Y/1MkmtIefVuk/s320/uni+filtered3.bmp" alt="" id="BLOGGER_PHOTO_ID_5383564434412786834" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrZDVVywzXI/AAAAAAAAA5g/oOVMBpuENYg/s1600-h/uni+filtered4.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrZDVVywzXI/AAAAAAAAA5g/oOVMBpuENYg/s320/uni+filtered4.bmp" alt="" id="BLOGGER_PHOTO_ID_5383564438474378610" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Noting that uniform noise is present, the four filters are effective in enhancing the noisy image.&lt;br /&gt;The impulse or salt-and-pepper noise is simulated through the function &lt;span style="font-style: italic;"&gt;imnoise&lt;/span&gt; where the noise density or probability of making salt or pepper noise is set to 0.01. The resulting noisy image and its PDF are the following.&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/_kx7Z922tJd0/SrZD4ufm3KI/AAAAAAAAA5o/uMWcCVhRVEQ/s1600-h/image+impulse+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrZD4ufm3KI/AAAAAAAAA5o/uMWcCVhRVEQ/s320/image+impulse+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383565046400343202" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZD4wLoD_I/AAAAAAAAA5w/JPm_6s9smbE/s1600-h/pdf+impulse+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZD4wLoD_I/AAAAAAAAA5w/JPm_6s9smbE/s320/pdf+impulse+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383565046853406706" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The PDF is similar to the PDF of the test image without any noise because impulse noise only adds white (salt) or black (pepper) pixels while the test image is composed of only white, black, and gray pixels. Thus, what is only different in this PDF is the frequency of the three graylevels. Illustrated below are the filtered noisy image with impulse noise through the four filters.&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/_kx7Z922tJd0/SrZETl2XeLI/AAAAAAAAA54/0qms6u5AolM/s1600-h/impulse+filtered1.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrZETl2XeLI/AAAAAAAAA54/0qms6u5AolM/s320/impulse+filtered1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383565507936352434" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZET9HDDpI/AAAAAAAAA6A/TOAl0q4K-zc/s1600-h/impulse+filtered2.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZET9HDDpI/AAAAAAAAA6A/TOAl0q4K-zc/s320/impulse+filtered2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383565514180333202" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZEUCfewmI/AAAAAAAAA6I/aftpIOiEKRI/s1600-h/impulse+filtered3.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrZEUCfewmI/AAAAAAAAA6I/aftpIOiEKRI/s320/impulse+filtered3.bmp" alt="" id="BLOGGER_PHOTO_ID_5383565515624989282" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZEUgM9wyI/AAAAAAAAA6Q/rY7mbigWdaQ/s1600-h/impulse+filtered4Q1.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZEUgM9wyI/AAAAAAAAA6Q/rY7mbigWdaQ/s320/impulse+filtered4Q1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383565523600392994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be observed that the arithmetic mean filter is best in the test image with impulse noise. It is proven here that the harmonic mean filter eliminates salt noise but fails in pepper noise. Meanwhile, the contraharmonic mean filter with &lt;span style="font-style: italic;"&gt;Q = 1&lt;/span&gt; removes pepper noise but some salt noise still remain. Different &lt;span style="font-style: italic;"&gt;Q&lt;/span&gt; values of the contraharmonic mean filter are also tested here. The filtered noisy image with &lt;span style="font-style: italic;"&gt;Q&lt;/span&gt; equals to -1, 2, -2, and 0 arranged from left to right, top to bottom are as follows.&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/_kx7Z922tJd0/SrZFMnT-yEI/AAAAAAAAA6Y/Mac9tDvnm9c/s1600-h/impulse+filtered4Q-1.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrZFMnT-yEI/AAAAAAAAA6Y/Mac9tDvnm9c/s320/impulse+filtered4Q-1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383566487581542466" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZFNKcjwVI/AAAAAAAAA6g/l0IEod2I8F4/s1600-h/impulse+filtered4Q2.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZFNKcjwVI/AAAAAAAAA6g/l0IEod2I8F4/s320/impulse+filtered4Q2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383566497012760914" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZFNfeaYtI/AAAAAAAAA6o/d1UVMQyMiIw/s1600-h/impulse+filtered4Q-2.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrZFNfeaYtI/AAAAAAAAA6o/d1UVMQyMiIw/s320/impulse+filtered4Q-2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383566502657680082" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrZFNnrDGbI/AAAAAAAAA6w/gkWNbjzkYTg/s1600-h/impulse+filtered4Q0.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 150px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrZFNnrDGbI/AAAAAAAAA6w/gkWNbjzkYTg/s320/impulse+filtered4Q0.bmp" alt="" id="BLOGGER_PHOTO_ID_5383566504858163634" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;From the results above, positive &lt;span style="font-style: italic;"&gt;Q&lt;/span&gt; values in the contraharmonic mean filter indeed eliminate pepper noise and not salt noise while negative &lt;span style="font-style: italic;"&gt;Q&lt;/span&gt; values are truly good to salt noise but not to pepper noise. However, with &lt;span style="font-style: italic;"&gt;Q&lt;/span&gt; equal to 0, both salt and pepper noise are minimized.&lt;br /&gt;&lt;br /&gt;The whole process is also tested for a grayscale image which is not restricted to only three discrete grayscale values. The grayscale image of a beach obtained from the internet is shown below.&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/_kx7Z922tJd0/SrDo3leZrLI/AAAAAAAAAzQ/fgj0i8EHNjY/s1600-h/beach.jpg"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrDo3leZrLI/AAAAAAAAAzQ/fgj0i8EHNjY/s320/beach.jpg" alt="" id="BLOGGER_PHOTO_ID_5382057596357815474" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Source: &lt;span style="font-style: italic;"&gt;http://www.advimglib.com/samples.html&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The PDF of the image above is shown as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbRjD72lxI/AAAAAAAAA64/nfR3U5sSiig/s1600-h/b+pdf+no+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbRjD72lxI/AAAAAAAAA64/nfR3U5sSiig/s320/b+pdf+no+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383720804849981202" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Apparently, the PDF of this test image does not contain only three graylevels. The test image with Gaussian noise and its PDF are the following.&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/_kx7Z922tJd0/SrbTsTtjU0I/AAAAAAAAA7A/zSxqCf_xWFo/s1600-h/b+image+gaussian+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbTsTtjU0I/AAAAAAAAA7A/zSxqCf_xWFo/s320/b+image+gaussian+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383723162727043906" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbTsk1OPqI/AAAAAAAAA7I/YY1DQNwkFQg/s1600-h/b+pdf+gauss+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbTsk1OPqI/AAAAAAAAA7I/YY1DQNwkFQg/s320/b+pdf+gauss+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383723167322619554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Below are the filtered test image with Gaussian noise using the four filters.&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/_kx7Z922tJd0/SrbURVqYd0I/AAAAAAAAA7Q/-tssQpnsxts/s1600-h/b+gauss+filtered1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbURVqYd0I/AAAAAAAAA7Q/-tssQpnsxts/s320/b+gauss+filtered1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383723798905780034" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbURocXhHI/AAAAAAAAA7Y/fvnXOI0kO0A/s1600-h/b+gauss+filtered2.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbURocXhHI/AAAAAAAAA7Y/fvnXOI0kO0A/s320/b+gauss+filtered2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383723803947271282" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbUSEOAHQI/AAAAAAAAA7g/6d4DSLmUln0/s1600-h/b+gauss+filtered3.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbUSEOAHQI/AAAAAAAAA7g/6d4DSLmUln0/s320/b+gauss+filtered3.bmp" alt="" id="BLOGGER_PHOTO_ID_5383723811403209986" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbUSjY3nzI/AAAAAAAAA7o/sFqc3b7AaIk/s1600-h/b+gauss+filtered4.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbUSjY3nzI/AAAAAAAAA7o/sFqc3b7AaIk/s320/b+gauss+filtered4.bmp" alt="" id="BLOGGER_PHOTO_ID_5383723819770289970" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The test image with Rayleigh noise and its PDF are as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbXRIZXlRI/AAAAAAAAA7w/mdsUCjp8Ozw/s1600-h/b+image+ray+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbXRIZXlRI/AAAAAAAAA7w/mdsUCjp8Ozw/s320/b+image+ray+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383727093879641362" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbXRoXwgEI/AAAAAAAAA74/s7rh1bMHA1o/s1600-h/b+pdf+ray+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbXRoXwgEI/AAAAAAAAA74/s7rh1bMHA1o/s320/b+pdf+ray+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383727102462820418" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The results of the filtered test image with Rayleigh noise through the four filters are the following.&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/_kx7Z922tJd0/SrbX98oZOQI/AAAAAAAAA8A/Z3TtG7dZjMg/s1600-h/b+ray+filtered1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbX98oZOQI/AAAAAAAAA8A/Z3TtG7dZjMg/s320/b+ray+filtered1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383727863815551234" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbX-bTwn-I/AAAAAAAAA8I/oFVU0Xnipwo/s1600-h/b+ray+filtered2.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbX-bTwn-I/AAAAAAAAA8I/oFVU0Xnipwo/s320/b+ray+filtered2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383727872050503650" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbX-tYeTcI/AAAAAAAAA8Q/kqgiVkC0qAk/s1600-h/b+ray+filtered3.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbX-tYeTcI/AAAAAAAAA8Q/kqgiVkC0qAk/s320/b+ray+filtered3.bmp" alt="" id="BLOGGER_PHOTO_ID_5383727876902112706" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbX_BF6-CI/AAAAAAAAA8Y/TbsK0cCWr_k/s1600-h/b+ray+filtered4.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbX_BF6-CI/AAAAAAAAA8Y/TbsK0cCWr_k/s320/b+ray+filtered4.bmp" alt="" id="BLOGGER_PHOTO_ID_5383727882193008674" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Shown below are the test image with Gamma noise and its PDF.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbdT880eNI/AAAAAAAAA8g/LrGnQtBlLlw/s1600-h/b+image+gamma+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbdT880eNI/AAAAAAAAA8g/LrGnQtBlLlw/s320/b+image+gamma+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383733739416484050" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbdUU1ET2I/AAAAAAAAA8o/5AjA0Hc5EPU/s1600-h/b+pdf+gamma+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbdUU1ET2I/AAAAAAAAA8o/5AjA0Hc5EPU/s320/b+pdf+gamma+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383733745826418530" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The filtered test image with Gamma noise using the four filters are as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbduQjWpLI/AAAAAAAAA8w/4l0hoAZ1sPM/s1600-h/b+gamma+filtered1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbduQjWpLI/AAAAAAAAA8w/4l0hoAZ1sPM/s320/b+gamma+filtered1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383734191354979506" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Srbdu2JzxjI/AAAAAAAAA84/HW4mUtE5aSc/s1600-h/b+gamma+filtered2.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Srbdu2JzxjI/AAAAAAAAA84/HW4mUtE5aSc/s320/b+gamma+filtered2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383734201448384050" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbdvSkw2VI/AAAAAAAAA9A/VSfw4XczoQM/s1600-h/b+gamma+filtered3.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbdvSkw2VI/AAAAAAAAA9A/VSfw4XczoQM/s320/b+gamma+filtered3.bmp" alt="" id="BLOGGER_PHOTO_ID_5383734209077631314" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbdvqZQGXI/AAAAAAAAA9I/aiRQk6gaNDA/s1600-h/b+gamma+filtered4.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbdvqZQGXI/AAAAAAAAA9I/aiRQk6gaNDA/s320/b+gamma+filtered4.bmp" alt="" id="BLOGGER_PHOTO_ID_5383734215471798642" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Next are the test image with exponential noise and its PDF.&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/_kx7Z922tJd0/SrbeSxwFXmI/AAAAAAAAA9Q/Fz8bjNpsUsM/s1600-h/b+image+exp+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbeSxwFXmI/AAAAAAAAA9Q/Fz8bjNpsUsM/s320/b+image+exp+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383734818742034018" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbeTOYfTnI/AAAAAAAAA9Y/hkm-dWShbTU/s1600-h/b+pdf+exp+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbeTOYfTnI/AAAAAAAAA9Y/hkm-dWShbTU/s320/b+pdf+exp+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383734826427698802" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The following set of figures is the filtered test image with exponential noise.&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/_kx7Z922tJd0/SrbeshAKCfI/AAAAAAAAA9g/M3DtTbPdRWk/s1600-h/b+exp+filtered1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbeshAKCfI/AAAAAAAAA9g/M3DtTbPdRWk/s320/b+exp+filtered1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383735260922644978" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Srbesxx4g5I/AAAAAAAAA9o/C3ycJavuYaM/s1600-h/b+exp+filtered2.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Srbesxx4g5I/AAAAAAAAA9o/C3ycJavuYaM/s320/b+exp+filtered2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383735265426178962" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbetXTOEYI/AAAAAAAAA9w/KSoNFh5W1qE/s1600-h/b+exp+filtered3.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbetXTOEYI/AAAAAAAAA9w/KSoNFh5W1qE/s320/b+exp+filtered3.bmp" alt="" id="BLOGGER_PHOTO_ID_5383735275498115458" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbetthYb4I/AAAAAAAAA94/fGwe8bQu2w4/s1600-h/b+exp+filtered4.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbetthYb4I/AAAAAAAAA94/fGwe8bQu2w4/s320/b+exp+filtered4.bmp" alt="" id="BLOGGER_PHOTO_ID_5383735281463095170" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Then, the test image with uniform noise and its PDF are shown below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbfTi0dutI/AAAAAAAAA-A/Emt11o3o89w/s1600-h/b+image+uni+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbfTi0dutI/AAAAAAAAA-A/Emt11o3o89w/s320/b+image+uni+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383735931425372882" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbfUNsq4pI/AAAAAAAAA-I/kIQ1_bdEd7Q/s1600-h/b+pdf+uniform+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbfUNsq4pI/AAAAAAAAA-I/kIQ1_bdEd7Q/s320/b+pdf+uniform+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383735942935405202" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The filtered test image with uniform noise after applying the four filters are as follows.&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/_kx7Z922tJd0/Srbfs6KmPrI/AAAAAAAAA-Q/BUWoLJoSPas/s1600-h/b+uni+filtered1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Srbfs6KmPrI/AAAAAAAAA-Q/BUWoLJoSPas/s320/b+uni+filtered1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383736367188950706" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbftGmwAdI/AAAAAAAAA-Y/PYASNAV45tE/s1600-h/b+uni+filtered2.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbftGmwAdI/AAAAAAAAA-Y/PYASNAV45tE/s320/b+uni+filtered2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383736370528256466" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbftjatBcI/AAAAAAAAA-g/o8nhHGHjkAE/s1600-h/b+uni+filtered3.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbftjatBcI/AAAAAAAAA-g/o8nhHGHjkAE/s320/b+uni+filtered3.bmp" alt="" id="BLOGGER_PHOTO_ID_5383736378262357442" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbfuPKhYZI/AAAAAAAAA-o/gbaWK7wnPsQ/s1600-h/b+uni+filtered4.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbfuPKhYZI/AAAAAAAAA-o/gbaWK7wnPsQ/s320/b+uni+filtered4.bmp" alt="" id="BLOGGER_PHOTO_ID_5383736390005645714" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Lastly, the following are the test image with impulse noise and its PDF.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbgVc0FEwI/AAAAAAAAA-w/JfKNIjpk4Uw/s1600-h/b+image+impulse+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SrbgVc0FEwI/AAAAAAAAA-w/JfKNIjpk4Uw/s320/b+image+impulse+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383737063684510466" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbgV7kGCEI/AAAAAAAAA-4/NFF0N3kf5dc/s1600-h/b+pdf+impulse+noise.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbgV7kGCEI/AAAAAAAAA-4/NFF0N3kf5dc/s320/b+pdf+impulse+noise.bmp" alt="" id="BLOGGER_PHOTO_ID_5383737071938963522" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Below are the filtered test image with impulse noise through the four filters.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbhTYxOXXI/AAAAAAAAA_g/mMhsWym5b2Q/s1600-h/b+impulse+filtered1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbhTYxOXXI/AAAAAAAAA_g/mMhsWym5b2Q/s320/b+impulse+filtered1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383738127750684018" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbhT9Z1P0I/AAAAAAAAA_o/pmqeI5K3kJE/s1600-h/b+impulse+filtered2.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbhT9Z1P0I/AAAAAAAAA_o/pmqeI5K3kJE/s320/b+impulse+filtered2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383738137584680770" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbhUH5pjYI/AAAAAAAAA_w/SFSjyx2BtGw/s1600-h/b+impulse+filtered3.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbhUH5pjYI/AAAAAAAAA_w/SFSjyx2BtGw/s320/b+impulse+filtered3.bmp" alt="" id="BLOGGER_PHOTO_ID_5383738140402486658" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbhUvChIkI/AAAAAAAAA_4/eI5aIG3nBWM/s1600-h/b+impulse+filtered4Q1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SrbhUvChIkI/AAAAAAAAA_4/eI5aIG3nBWM/s320/b+impulse+filtered4Q1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383738150908666434" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;Q&lt;/span&gt; values of the contraharmonic mean filter are also varied to -1, 2, -2, and 0 resulting to the figures as follows.&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/_kx7Z922tJd0/SrbiE5w9M5I/AAAAAAAABAA/ZPsJ9iblL6c/s1600-h/b+impulse+filtered4Q-1.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbiE5w9M5I/AAAAAAAABAA/ZPsJ9iblL6c/s320/b+impulse+filtered4Q-1.bmp" alt="" id="BLOGGER_PHOTO_ID_5383738978421519250" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbiFV7vyyI/AAAAAAAABAI/h0RpHN0rl_Y/s1600-h/b+impulse+filtered4Q2.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbiFV7vyyI/AAAAAAAABAI/h0RpHN0rl_Y/s320/b+impulse+filtered4Q2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383738985982970658" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbiFr7zmpI/AAAAAAAABAQ/HOSqMaOKoH8/s1600-h/b+impulse+filtered4Q-2.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SrbiFr7zmpI/AAAAAAAABAQ/HOSqMaOKoH8/s320/b+impulse+filtered4Q-2.bmp" alt="" id="BLOGGER_PHOTO_ID_5383738991888800402" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbiGELE8tI/AAAAAAAABAY/9xN7nDCGW8c/s1600-h/b+impulse+filtered4Q0.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SrbiGELE8tI/AAAAAAAABAY/9xN7nDCGW8c/s320/b+impulse+filtered4Q0.bmp" alt="" id="BLOGGER_PHOTO_ID_5383738998395302610" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Since the test image now has distribution of grayscale values, the four filters resulted to almost the same filtered image except in the test image with impulse noise unlike in the test image with only three grayscale values where a certain filter is preferred over the others. Overall, it can be deduced that the arithmetic mean filter is consistent in restoring both test image with three discrete graylevels and with distributed grayscale values to every type of noise added.&lt;br /&gt;&lt;br /&gt;I grade myself 10/10 because I am able to simulate all the noise models introduced in this activity and I have successfully implemented the four basic image restoration techniques in the test images with different the noise models applied to them.&lt;br /&gt;&lt;br /&gt;I thank Neil in providing me the test image with only three grayscale values.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;Below is the whole &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code utilized in this activity.&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;stacksize(4e7);&lt;br /&gt;&lt;br /&gt;image = gray_imread('beach.jpg');&lt;br /&gt;s = size(image);&lt;br /&gt;&lt;br /&gt;//scf(0);&lt;br /&gt;//imshow(image, []);&lt;br /&gt;&lt;br /&gt;a = 1;&lt;br /&gt;grayscale = [];&lt;br /&gt;pixels = [];&lt;br /&gt;for i = 0:255&lt;br /&gt;[x, y] = find(round(255*normal(image)) == i);&lt;br /&gt;grayscale(a) = i;&lt;br /&gt;pixels(a) = length(x);&lt;br /&gt;a = a + 1;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;//scf(1);&lt;br /&gt;//plot(grayscale, normal(pixels));&lt;br /&gt;//title('PDF of Image without Noise');&lt;br /&gt;//xlabel('Grayscale Values');&lt;br /&gt;&lt;br /&gt;noise_gauss = grand(s(1), s(2), 'nor', 0.5, 0.075);&lt;br /&gt;noise_ray = matrix(genrayl(0.1, s(1)*s(2)), s(1), s(2));&lt;br /&gt;noise_gamma = grand(s(1), s(2), 'gam', 1, 10);&lt;br /&gt;noise_exp = grand(s(1), s(2), 'exp', 0.1);&lt;br /&gt;noise_uni = grand(s(1), s(2), 'unf', 0, 0.2);&lt;br /&gt;noisy_image_salt = imnoise(image, 'salt &amp;amp; pepper', 0.01);&lt;br /&gt;&lt;br /&gt;//noisy_image = round(255*normal(noisy_image_salt));&lt;br /&gt;noisy_image = round(255*normal(image + noise_gauss));&lt;br /&gt;&lt;br /&gt;//scf(2);&lt;br /&gt;//imshow(noisy_image, []);&lt;br /&gt;//imwrite(normal(noisy_image), 'image gauss noise.bmp');&lt;br /&gt;&lt;br /&gt;a = 1;&lt;br /&gt;grayscale = [];&lt;br /&gt;pixels = [];&lt;br /&gt;for i = 0:255&lt;br /&gt;[x, y] = find(round(255*normal(noisy_image)) == i);&lt;br /&gt;grayscale(a) = i;&lt;br /&gt;pixels(a) = length(x);&lt;br /&gt;a = a + 1;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;//scf(3);&lt;br /&gt;//plot(grayscale, normal(pixels));&lt;br /&gt;//title('PDF of Image with Gaussian Noise');&lt;br /&gt;//xlabel('Grayscale Values');&lt;br /&gt;&lt;br /&gt;// Filtering Noisy Image&lt;br /&gt;&lt;br /&gt;// Arithmetic Mean Filter&lt;br /&gt;&lt;br /&gt;// Size of Rectangle Subimage Window (3 x 3)&lt;br /&gt;m = 3;&lt;br /&gt;n = 3;&lt;br /&gt;&lt;br /&gt;for a = 1:s(1)&lt;br /&gt;for b = 1:s(2)&lt;br /&gt;if a == 1 &amp;amp; b == 1&lt;br /&gt;g1 = [noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered1(a, b) = (1/(2*2))*sum(g1);&lt;br /&gt;elseif a == 1 &amp;amp; b == s(2)&lt;br /&gt;g1 = [noisy_image(a, b - 1) noisy_image(a, b); noisy_image(a + 1, b - 1) noisy_image(a + 1, b)];&lt;br /&gt;filtered1(a, b) = (1/(2*2))*sum(g1);&lt;br /&gt;elseif a == s(1) &amp;amp; b == 1&lt;br /&gt;g1 = [noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b) noisy_image(a, b + 1)];&lt;br /&gt;filtered1(a, b) = (1/(2*2))*sum(g1);&lt;br /&gt;elseif a == s(1) &amp;amp; b == s(2)&lt;br /&gt;g1 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b); noisy_image(a, b - 1) noisy_image(a, b)];&lt;br /&gt;filtered1(a, b) = (1/(2*2))*sum(g1);&lt;br /&gt;elseif a == 1 &amp;amp; b ~= 1 &amp;amp; b ~= s(2)&lt;br /&gt;g1 = [noisy_image(a, b - 1) noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b - 1) noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered1(a, b) = (1/(2*3))*sum(g1);&lt;br /&gt;elseif b == 1 &amp;amp; a ~= 1 &amp;amp; a ~= s(1)&lt;br /&gt;g1 = [noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered1(a, b) = (1/(3*2))*sum(g1);&lt;br /&gt;elseif b == s(2) &amp;amp; a ~= 1 &amp;amp; a ~= s(1)&lt;br /&gt;g1 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b); noisy_image(a, b - 1) noisy_image(a, b); noisy_image(a + 1, b - 1) noisy_image(a + 1, b)];&lt;br /&gt;filtered1(a, b) = (1/(3*2))*sum(g1);&lt;br /&gt;elseif a == s(1) &amp;amp; b ~= 1 &amp;amp; b ~= s(2)&lt;br /&gt;g1 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b - 1) noisy_image(a, b) noisy_image(a, b + 1)];&lt;br /&gt;filtered1(a, b) = (1/(2*3))*sum(g1);&lt;br /&gt;else&lt;br /&gt;g1 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b - 1) noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b - 1) noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered1(a, b) = (1/(m*n))*sum(g1);&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;//scf(4);&lt;br /&gt;//imshow(filtered1, []);&lt;br /&gt;//imwrite(normal(filtered1), 'gauss filtered1.bmp');&lt;br /&gt;&lt;br /&gt;// Geometric Mean Filter&lt;br /&gt;&lt;br /&gt;for a = 1:s(1)&lt;br /&gt;for b = 1:s(2)&lt;br /&gt;if a == 1 &amp;amp; b == 1&lt;br /&gt;g2 = [noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered2(a, b) = prod(g2)^(1/(2*2));&lt;br /&gt;elseif a == 1 &amp;amp; b == s(2)&lt;br /&gt;g2 = [noisy_image(a, b - 1) noisy_image(a, b); noisy_image(a + 1, b - 1) noisy_image(a + 1, b)];&lt;br /&gt;filtered2(a, b) = prod(g2)^(1/(2*2));&lt;br /&gt;elseif a == s(1) &amp;amp; b == 1&lt;br /&gt;g2 = [noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b) noisy_image(a, b + 1)];&lt;br /&gt;filtered2(a, b) = prod(g2)^(1/(2*2));&lt;br /&gt;elseif a == s(1) &amp;amp; b == s(2)&lt;br /&gt;g2 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b); noisy_image(a, b - 1) noisy_image(a, b)];&lt;br /&gt;filtered2(a, b) = prod(g2)^(1/(2*2));&lt;br /&gt;elseif a == 1 &amp;amp; b ~= 1 &amp;amp; b ~= s(2)&lt;br /&gt;g2 = [noisy_image(a, b - 1) noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b - 1) noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered2(a, b) = prod(g2)^(1/(2*3));&lt;br /&gt;elseif b == 1 &amp;amp; a ~= 1 &amp;amp; a ~= s(1)&lt;br /&gt;g2 = [noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered2(a, b) = prod(g2)^(1/(3*2));&lt;br /&gt;elseif b == s(2) &amp;amp; a ~= 1 &amp;amp; a ~= s(1)&lt;br /&gt;g2 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b); noisy_image(a, b - 1) noisy_image(a, b); noisy_image(a + 1, b - 1) noisy_image(a + 1, b)];&lt;br /&gt;filtered2(a, b) = prod(g2)^(1/(3*2));&lt;br /&gt;elseif a == s(1) &amp;amp; b ~= 1 &amp;amp; b ~= s(2)&lt;br /&gt;g2 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b - 1) noisy_image(a, b) noisy_image(a, b + 1)];&lt;br /&gt;filtered2(a, b) = prod(g2)^(1/(2*3));&lt;br /&gt;else&lt;br /&gt;g2 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b - 1) noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b - 1) noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered2(a, b) = prod(g2)^(1/(m*n));&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;//scf(5);&lt;br /&gt;//imshow(filtered2, []);&lt;br /&gt;//imwrite(normal(filtered2), gauss filtered2.bmp');&lt;br /&gt;&lt;br /&gt;// Harmonic Mean Filter&lt;br /&gt;&lt;br /&gt;small_number = 0.000001;&lt;br /&gt;for a = 1:s(1)&lt;br /&gt;for b = 1:s(2)&lt;br /&gt;if a == 1 &amp;amp; b == 1&lt;br /&gt;g3 = [noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered3(a, b) = (2*2)/(sum((1)./(g3 + small_number)));&lt;br /&gt;elseif a == 1 &amp;amp; b == s(2)&lt;br /&gt;g3 = [noisy_image(a, b - 1) noisy_image(a, b); noisy_image(a + 1, b - 1) noisy_image(a + 1, b)];&lt;br /&gt;filtered3(a, b) = (2*2)/(sum((1)./(g3 + small_number)));&lt;br /&gt;elseif a == s(1) &amp;amp; b == 1&lt;br /&gt;g3 = [noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b) noisy_image(a, b + 1)];&lt;br /&gt;filtered3(a, b) = (2*2)/(sum((1)./(g3 + small_number)));&lt;br /&gt;elseif a == s(1) &amp;amp; b == s(2)&lt;br /&gt;g3 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b); noisy_image(a, b - 1) noisy_image(a, b)];&lt;br /&gt;filtered3(a, b) = (2*2)/(sum((1)./(g3 + small_number)));&lt;br /&gt;elseif a == 1 &amp;amp; b ~= 1 &amp;amp; b ~= s(2)&lt;br /&gt;g3 = [noisy_image(a, b - 1) noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b - 1) noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered3(a, b) = (2*3)/(sum((1)./(g3 + small_number)));&lt;br /&gt;elseif b == 1 &amp;amp; a ~= 1 &amp;amp; a ~= s(1)&lt;br /&gt;g3 = [noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered3(a, b) = (3*2)/(sum((1)./(g3 + small_number)));&lt;br /&gt;elseif b == s(2) &amp;amp; a ~= 1 &amp;amp; a ~= s(1)&lt;br /&gt;g3 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b); noisy_image(a, b - 1) noisy_image(a, b); noisy_image(a + 1, b - 1) noisy_image(a + 1, b)];&lt;br /&gt;filtered3(a, b) = (3*2)/(sum((1)./(g3 + small_number)));&lt;br /&gt;elseif a == s(1) &amp;amp; b ~= 1 &amp;amp; b ~= s(2)&lt;br /&gt;g3 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b - 1) noisy_image(a, b) noisy_image(a, b + 1)];&lt;br /&gt;filtered3(a, b) = (2*3)/(sum((1)./(g3 + small_number)));&lt;br /&gt;else&lt;br /&gt;g3 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b - 1) noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b - 1) noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered3(a, b) = (m*n)/(sum((1)./(g3 + small_number)));&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;//scf(6);&lt;br /&gt;//imshow(filtered3, []);&lt;br /&gt;//imwrite(normal(filtered3), 'gauss filtered3.bmp');&lt;br /&gt;&lt;br /&gt;// Contraharmonic Mean Filter&lt;br /&gt;&lt;br /&gt;Q = 0;&lt;br /&gt;for a = 1:s(1)&lt;br /&gt;for b = 1:s(2)&lt;br /&gt;if a == 1 &amp;amp; b == 1&lt;br /&gt;g4 = [noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered4(a, b) = (sum((g4 + small_number).^(Q + 1)))/(sum((g4 + small_number).^Q));&lt;br /&gt;elseif a == 1 &amp;amp; b == s(2)&lt;br /&gt;g4 = [noisy_image(a, b - 1) noisy_image(a, b); noisy_image(a + 1, b - 1) noisy_image(a + 1, b)];&lt;br /&gt;filtered4(a, b) = (sum((g4 + small_number).^(Q + 1)))/(sum((g4 + small_number).^Q));&lt;br /&gt;elseif a == s(1) &amp;amp; b == 1&lt;br /&gt;g4 = [noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b) noisy_image(a, b + 1)];&lt;br /&gt;filtered4(a, b) = (sum((g4 + small_number).^(Q + 1)))/(sum((g4 + small_number).^Q));&lt;br /&gt;elseif a == s(1) &amp;amp; b == s(2)&lt;br /&gt;g4 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b); noisy_image(a, b - 1) noisy_image(a, b)];&lt;br /&gt;filtered4(a, b) = (sum((g4 + small_number).^(Q + 1)))/(sum((g4 + small_number).^Q));&lt;br /&gt;elseif a == 1 &amp;amp; b ~= 1 &amp;amp; b ~= s(2)&lt;br /&gt;g4 = [noisy_image(a, b - 1) noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b - 1) noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered4(a, b) = (sum((g4 + small_number).^(Q + 1)))/(sum((g4 + small_number).^Q));&lt;br /&gt;elseif b == 1 &amp;amp; a ~= 1 &amp;amp; a ~= s(1)&lt;br /&gt;g4 = [noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered4(a, b) = (sum((g4 + small_number).^(Q + 1)))/(sum((g4 + small_number).^Q));&lt;br /&gt;elseif b == s(2) &amp;amp; a ~= 1 &amp;amp; a ~= s(1)&lt;br /&gt;g4 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b); noisy_image(a, b - 1) noisy_image(a, b); noisy_image(a + 1, b - 1) noisy_image(a + 1, b)];&lt;br /&gt;filtered4(a, b) = (sum((g4 + small_number).^(Q + 1)))/(sum((g4 + small_number).^Q));&lt;br /&gt;elseif a == s(1) &amp;amp; b ~= 1 &amp;amp; b ~= s(2)&lt;br /&gt;g4 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b - 1) noisy_image(a, b) noisy_image(a, b + 1)];&lt;br /&gt;filtered4(a, b) = (sum((g4 + small_number).^(Q + 1)))/(sum((g4 + small_number).^Q));&lt;br /&gt;else&lt;br /&gt;g4 = [noisy_image(a - 1, b - 1) noisy_image(a - 1, b) noisy_image(a - 1, b + 1); noisy_image(a, b - 1) noisy_image(a, b) noisy_image(a, b + 1); noisy_image(a + 1, b - 1) noisy_image(a + 1, b) noisy_image(a + 1, b + 1)];&lt;br /&gt;filtered4(a, b) = (sum((g4 + small_number).^(Q + 1)))/(sum((g4 + small_number).^Q));&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;//scf(7);&lt;br /&gt;//imshow(filtered4, []);&lt;br /&gt;//imwrite(normal(filtered4), 'gauss filtered4.bmp');&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1657424262821979330-6190222948883074823?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/6190222948883074823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/09/activity-18-noise-models-and-basic.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/6190222948883074823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/6190222948883074823'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/09/activity-18-noise-models-and-basic.html' title='Activity 18 - Noise Models and Basic Image Restoration'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_kx7Z922tJd0/SrYF6_Fu7lI/AAAAAAAAAzY/wCdtqpccHfo/s72-c/gaussian.bmp' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-7758630626553446095</id><published>2009-09-08T09:03:00.041+08:00</published><updated>2009-09-10T17:24:27.078+08:00</updated><title type='text'>Activity 17 - Photometric Stereo</title><content type='html'>&lt;div style="text-align: justify;"&gt;The shape of a surface is estimated and then plotted 3-dimensionally in this activity using photometric stereo.&lt;br /&gt;&lt;br /&gt;In photometric stereo, the 3-dimensional form of an object can be determined through captured intensity profiles of that object. The intensity profile is varied through different locations of an illuminating source. A point source is considered here. The location of &lt;span style="font-style: italic;"&gt;N&lt;/span&gt; point sources is defined in a matrix as follows.&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/_kx7Z922tJd0/Sqitg2v3iXI/AAAAAAAAAyw/G6Eq5Vokx-M/s1600-h/matrix+V.bmp"&gt;&lt;img style="cursor: pointer; width: 133px; height: 85px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Sqitg2v3iXI/AAAAAAAAAyw/G6Eq5Vokx-M/s320/matrix+V.bmp" alt="" id="BLOGGER_PHOTO_ID_5379740534857763186" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;A row represents a point source and each row corresponds to its &lt;span style="font-style: italic;"&gt;x&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;y&lt;/span&gt;, and &lt;span style="font-style: italic;"&gt;z&lt;/span&gt; component. Now, for &lt;span style="font-style: italic;"&gt;N&lt;/span&gt; number of images of the object, the intensity at &lt;span style="font-style: italic;"&gt;(x, y)&lt;/span&gt; on the surface is given by the following.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqitgEksvtI/AAAAAAAAAyg/HRwgBS4FiRg/s1600-h/I+equations.bmp"&gt;&lt;img style="cursor: pointer; width: 280px; height: 82px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqitgEksvtI/AAAAAAAAAyg/HRwgBS4FiRg/s320/I+equations.bmp" alt="" id="BLOGGER_PHOTO_ID_5379740521389145810" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;This can be written in a matrix operation shown below.&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/_kx7Z922tJd0/SqitgneVFyI/AAAAAAAAAyo/rRLoYQNp11I/s1600-h/I+matrix.bmp"&gt;&lt;img style="cursor: pointer; width: 41px; height: 20px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqitgneVFyI/AAAAAAAAAyo/rRLoYQNp11I/s320/I+matrix.bmp" alt="" id="BLOGGER_PHOTO_ID_5379740530757670690" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Note that &lt;span style="font-style: italic;"&gt;g&lt;/span&gt; is a function of the reflectance of the surface multiplied to the normal vector at &lt;span style="font-style: italic;"&gt;(x, y)&lt;/span&gt; as shown in the following equation.&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/_kx7Z922tJd0/SqitUHOXzII/AAAAAAAAAyI/ewzcA51Cx6c/s1600-h/g+equation.bmp"&gt;&lt;img style="cursor: pointer; width: 126px; height: 21px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqitUHOXzII/AAAAAAAAAyI/ewzcA51Cx6c/s320/g+equation.bmp" alt="" id="BLOGGER_PHOTO_ID_5379740315942374530" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Since &lt;span style="font-style: italic;"&gt;g&lt;/span&gt; is initially unknown, this can be obtained using the matrix equation as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqitUqAmTRI/AAAAAAAAAyQ/2u0JTEr1bio/s1600-h/g+matrix.bmp"&gt;&lt;img style="cursor: pointer; width: 97px; height: 28px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqitUqAmTRI/AAAAAAAAAyQ/2u0JTEr1bio/s320/g+matrix.bmp" alt="" id="BLOGGER_PHOTO_ID_5379740325279845650" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Then, the normal vector of the surface is calculated through the expression below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqithWF39sI/AAAAAAAAAy4/OCZp2sV22o4/s1600-h/n+hat.bmp"&gt;&lt;img style="cursor: pointer; width: 42px; height: 42px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqithWF39sI/AAAAAAAAAy4/OCZp2sV22o4/s320/n+hat.bmp" alt="" id="BLOGGER_PHOTO_ID_5379740543271564994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Note that the denominator from the equation above is the length of g computed employing Pythagorean theorem in 3-dimension. From the normal vector, the shape of the object can be determined in the following definition of its surface elevation at &lt;span style="font-style: italic;"&gt;(x, y)&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SqitmxxvzRI/AAAAAAAAAzI/qZlBUwgDSWc/s1600-h/z.bmp"&gt;&lt;img style="cursor: pointer; width: 64px; height: 21px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SqitmxxvzRI/AAAAAAAAAzI/qZlBUwgDSWc/s320/z.bmp" alt="" id="BLOGGER_PHOTO_ID_5379740636602682642" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The expression above is then rewritten as follows.&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/_kx7Z922tJd0/SqitTOZmG6I/AAAAAAAAAx4/XDR_XJuh9lY/s1600-h/c.bmp"&gt;&lt;img style="cursor: pointer; width: 152px; height: 21px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SqitTOZmG6I/AAAAAAAAAx4/XDR_XJuh9lY/s320/c.bmp" alt="" id="BLOGGER_PHOTO_ID_5379740300688628642" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The gradient of &lt;span style="font-style: italic;"&gt;c(x, y, z)&lt;/span&gt; shown below is next obtained in order to relate the estimated surface normals &lt;span style="font-style: italic;"&gt;n_x&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;n_y&lt;/span&gt;, and &lt;span style="font-style: italic;"&gt;n_z&lt;/span&gt; using photometric stereo and the partial derivative of &lt;span style="font-style: italic;"&gt;f&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SqitVMFDgZI/AAAAAAAAAyY/2xVHfMX5Mbw/s1600-h/gradient+c.bmp"&gt;&lt;img style="cursor: pointer; width: 162px; height: 41px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqitVMFDgZI/AAAAAAAAAyY/2xVHfMX5Mbw/s320/gradient+c.bmp" alt="" id="BLOGGER_PHOTO_ID_5379740334425342354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Meanwhile, the relation between the surface normals and the partial derivative of &lt;span style="font-style: italic;"&gt;f&lt;/span&gt; is the following.&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/_kx7Z922tJd0/SqithhghynI/AAAAAAAAAzA/9TDNez3Sy9E/s1600-h/partial+f+to+x+and+y.bmp"&gt;&lt;img style="cursor: pointer; width: 64px; height: 82px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqithhghynI/AAAAAAAAAzA/9TDNez3Sy9E/s320/partial+f+to+x+and+y.bmp" alt="" id="BLOGGER_PHOTO_ID_5379740546336148082" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Finally, the object's surface elevation at point &lt;span style="font-style: italic;"&gt;(u, v)&lt;/span&gt; is evaluated through the line integral as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SqitTmjntaI/AAAAAAAAAyA/3WRrgSuHyAQ/s1600-h/f+of+u+and+v.bmp"&gt;&lt;img style="cursor: pointer; width: 169px; height: 50px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SqitTmjntaI/AAAAAAAAAyA/3WRrgSuHyAQ/s320/f+of+u+and+v.bmp" alt="" id="BLOGGER_PHOTO_ID_5379740307173127586" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;A Matlab file containing four images of a surface is loaded in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; using the function &lt;span style="font-style: italic;"&gt;loadmatfile&lt;/span&gt;. These images are shown below.&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/_kx7Z922tJd0/SqhkUWiR-6I/AAAAAAAAAxQ/WMjoyOoXBBo/s1600-h/I1.bmp"&gt;&lt;img style="cursor: pointer; width: 89px; height: 88px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SqhkUWiR-6I/AAAAAAAAAxQ/WMjoyOoXBBo/s320/I1.bmp" alt="" id="BLOGGER_PHOTO_ID_5379660055703583650" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqhkUy-V4XI/AAAAAAAAAxY/9TLam3IUnto/s1600-h/I2.bmp"&gt;&lt;img style="cursor: pointer; width: 89px; height: 88px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqhkUy-V4XI/AAAAAAAAAxY/9TLam3IUnto/s320/I2.bmp" alt="" id="BLOGGER_PHOTO_ID_5379660063337472370" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SqhkVJNDaAI/AAAAAAAAAxg/7zJPMwCzwAs/s1600-h/I3.bmp"&gt;&lt;img style="cursor: pointer; width: 89px; height: 88px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqhkVJNDaAI/AAAAAAAAAxg/7zJPMwCzwAs/s320/I3.bmp" alt="" id="BLOGGER_PHOTO_ID_5379660069304756226" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SqhkVpitfsI/AAAAAAAAAxo/PWlLSOyTbCk/s1600-h/I4.bmp"&gt;&lt;img style="cursor: pointer; width: 89px; height: 88px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqhkVpitfsI/AAAAAAAAAxo/PWlLSOyTbCk/s320/I4.bmp" alt="" id="BLOGGER_PHOTO_ID_5379660077985529538" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Each image above is illuminated by a point source located respectively at&lt;br /&gt;&lt;span style="font-style: italic;"&gt;V_1 = [0.085832, 0.17365, 0.98106]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;V_2 = [0.085832, -0.17365, 0.98106]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;V_3 = [0.17365, 0, 0.98481]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;V_4 = [0.16318, -0.34202, 0.92542]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;These four point source locations are then placed in matrix &lt;span style="font-style: italic;"&gt;V&lt;/span&gt; with size 4 x 3 as well as the four intensity profiles in matrix &lt;span style="font-style: italic;"&gt;I&lt;/span&gt; with size 4 x (128*128) or 4 x 16384. Note that each loaded intensity profile has size 128 x 128. The size of matrix &lt;span style="font-style: italic;"&gt;g&lt;/span&gt; and surface normal &lt;span style="font-style: italic;"&gt;n&lt;/span&gt; obtained is thus 3 x 16384. To prevent division by zero, a very small value 0.000001 is added to every element of the length or magnitude of &lt;span style="font-style: italic;"&gt;g&lt;/span&gt; and to all elements of &lt;span style="font-style: italic;"&gt;n_z&lt;/span&gt;. The calculated partial derivatives of &lt;span style="font-style: italic;"&gt;f&lt;/span&gt; with respect to &lt;span style="font-style: italic;"&gt;x&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;y&lt;/span&gt; are recasted into a matrix with size 128 x 128 for evaluation of the surface elevation at &lt;span style="font-style: italic;"&gt;(u, v)&lt;/span&gt;. The line integrals are operated using &lt;span style="font-style: italic;"&gt;cumsum&lt;/span&gt; of &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; where the limit of integration from &lt;span style="font-style: italic;"&gt;0&lt;/span&gt; to &lt;span style="font-style: italic;"&gt;u&lt;/span&gt; means the cumulative summation along the column (from 1st column to 128th column) of the partial derivative of &lt;span style="font-style: italic;"&gt;f&lt;/span&gt; with respect to &lt;span style="font-style: italic;"&gt;x&lt;/span&gt;. Conversely, the limit of integration from &lt;span style="font-style: italic;"&gt;0&lt;/span&gt; to &lt;span style="font-style: italic;"&gt;v&lt;/span&gt; is the cumulative summation along the row (from 1st row to 128th row) of the partial derivative of &lt;span style="font-style: italic;"&gt;f&lt;/span&gt; with respect to &lt;span style="font-style: italic;"&gt;y&lt;/span&gt;.&lt;br /&gt;The following figure is then the plotted surface of the object in 3-dimension.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SqhkcchMgPI/AAAAAAAAAxw/U0Ye7A5OznY/s1600-h/elevated+surface.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SqhkcchMgPI/AAAAAAAAAxw/U0Ye7A5OznY/s320/elevated+surface.bmp" alt="" id="BLOGGER_PHOTO_ID_5379660194748596466" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Apparently, the shape of the surface is successfully reconstructed 3-dimensionally. From the 3-D plot, it is revealed that the object is hemispherical with four divided quadrants as observed from the intensity profiles.&lt;br /&gt;&lt;br /&gt;Since I am able to show the shape of the given surface successfully using photometric stereo, I grade myself 10/10.&lt;br /&gt;&lt;br /&gt;I worked with Gary in completing this activity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;The whole &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code utilized in this activity is as follows.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;loadmatfile('Photos.mat');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(I1, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(I2, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(I3, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(I4, []);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;I1 = matrix(I1, 1, size(I1, 1)*size(I1, 2));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;I2 = matrix(I2, 1, size(I2, 1)*size(I2, 2));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;I3 = matrix(I3, 1, size(I3, 1)*size(I3, 2));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;I4 = matrix(I4, 1, size(I4, 1)*size(I4, 2));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;I = [I1; I2; I3; I4];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;V1 = [0.085832, 0.17365, 0.98106];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;V2 = [0.085832, -0.17365, 0.98106];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;V3 = [0.17365, 0, 0.98481];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;V4 = [0.16318, -0.34202, 0.92542];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;V = [V1; V2; V3; V4];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;small_number = 0.000001;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;g = inv(V'*V)*V'*I;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;magnitude = sqrt((g(1,:).^2) + (g(2,:).^2) + (g(3,:).^2)) + small_number;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 1:3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;n(i,:) = g(i,:)./magnitude;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;n_x = n(1,:);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;n_y = n(2,:);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;n_z = n(3,:) + small_number;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;partial_f_to_x = -n_x./n_z;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;partial_f_to_y = -n_y./n_z;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;partial_f_to_x = matrix(partial_f_to_x, 128, 128);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;partial_f_to_y = matrix(partial_f_to_y, 128, 128);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;z = cumsum(partial_f_to_x, 2) + cumsum(partial_f_to_y, 1);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(4);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//plot3d(1:128, 1:128, z);&lt;/span&gt;&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/1657424262821979330-7758630626553446095?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/7758630626553446095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.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/1657424262821979330/posts/default/7758630626553446095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/7758630626553446095'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/09/activity-17-photometric-stereo.html' title='Activity 17 - Photometric Stereo'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_kx7Z922tJd0/Sqitg2v3iXI/AAAAAAAAAyw/G6Eq5Vokx-M/s72-c/matrix+V.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-9103394173222106904</id><published>2009-09-03T08:51:00.046+08:00</published><updated>2009-09-04T21:04:58.735+08:00</updated><title type='text'>Activity 16 - Neural Networks</title><content type='html'>&lt;div style="text-align: justify;"&gt;For the third time after &lt;span style="font-style: italic;"&gt;Activity 14&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;15&lt;/span&gt;, grouping objects belonging to different classes is done in this acitvity. The artificial neural network (ANN) algorithm is implemented here to classify these sets of objects.&lt;br /&gt;&lt;br /&gt;Again, the features of a sample which are the pixel area, normalized chromaticity values in red, green, and blue obtained from &lt;span style="font-style: italic;"&gt;Activity 14&lt;/span&gt; are used in this activity. This time, 3 classes from &lt;span style="font-style: italic;"&gt;Activity 14 &lt;/span&gt;which are &lt;span style="font-style: italic;"&gt;Snacku&lt;/span&gt; rice crackers, &lt;span style="font-style: italic;"&gt;Superthin&lt;/span&gt; biscuits, and &lt;span style="font-style: italic;"&gt;Nova&lt;/span&gt; multigrain snack with 10 samples each are accounted here unlike from &lt;span style="font-style: italic;"&gt;Activity 15&lt;/span&gt; which considers only 2 classes. These are shown below.&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/_kx7Z922tJd0/SqBDbnyhToI/AAAAAAAAAtY/Lbh2Nd603fo/s1600-h/snacks+cropped.JPG"&gt;&lt;img style="cursor: pointer; width: 318px; height: 320px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqBDbnyhToI/AAAAAAAAAtY/Lbh2Nd603fo/s320/snacks+cropped.JPG" alt="" id="BLOGGER_PHOTO_ID_5377372096896781954" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;ANN recognizes patterns through learning by example. This is similar to how the human brain works in classifying objects. Once it has learned after some training cycles, ANN can quickly and accurately operate pattern processing.&lt;br /&gt;The model of an artificial neuron which is the basic unit of ANN is illustrated as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqBEUNg46OI/AAAAAAAAAtg/h5bfFglwruc/s1600-h/artificial+neuron.bmp"&gt;&lt;img style="cursor: pointer; width: 273px; height: 143px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqBEUNg46OI/AAAAAAAAAtg/h5bfFglwruc/s320/artificial+neuron.bmp" alt="" id="BLOGGER_PHOTO_ID_5377373069096052962" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;From the model above, the weighted inputs &lt;span style="font-style: italic;"&gt;x_1&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;x_2&lt;/span&gt;, ..., &lt;span style="font-style: italic;"&gt;x_i&lt;/span&gt; multiplied to their corresponding synaptic strengths or weights &lt;span style="font-style: italic;"&gt;w_1&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;w_2&lt;/span&gt;, ..., &lt;span style="font-style: italic;"&gt;w_i&lt;/span&gt; of a neuron are summed to produce &lt;span style="font-style: italic;"&gt;a&lt;/span&gt; which then acts to the activation function &lt;span style="font-style: italic;"&gt;g&lt;/span&gt;. Then, the output &lt;span style="font-style: italic;"&gt;z&lt;/span&gt; is transmitted to other neurons as part of the ANN's learning period.&lt;br /&gt;ANN has 3 layers namely the input layer, hidden layer, and the output layer. The input layer consists the features that are then transmitted to every neuron of the hidden layer noting that all neurons of the preceding layer are interconnected to every neurons of the succeeding layer. The results are then passed on to the output layer which determines the class to where the input features belong. The following is an illustration of a simple ANN.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqBEUefbBqI/AAAAAAAAAto/d1WTPWQAOhc/s1600-h/neural+network.bmp"&gt;&lt;img style="cursor: pointer; width: 252px; height: 187px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqBEUefbBqI/AAAAAAAAAto/d1WTPWQAOhc/s320/neural+network.bmp" alt="" id="BLOGGER_PHOTO_ID_5377373073653302946" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Using the &lt;span style="font-style: italic;"&gt;ANN_Toolbox_0.4.2&lt;/span&gt; loaded in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt;, built-in functions &lt;span style="font-style: italic;"&gt;ann_FF_init&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;ann_FF_Std_online&lt;/span&gt;, and &lt;span style="font-style: italic;"&gt;ann_FF_run&lt;/span&gt; are employed to simulate an ANN to classify 15 test samples. The first function &lt;span style="font-style: italic;"&gt;ann_FF_init&lt;/span&gt; initializes the network which has &lt;span style="font-style: italic;"&gt;l&lt;/span&gt; number of neurons in the input layer, &lt;span style="font-style: italic;"&gt;m&lt;/span&gt; number of neurons in the hidden layer, and &lt;span style="font-style: italic;"&gt;n&lt;/span&gt; number of neurons in the output layer. This then becomes the weight of &lt;span style="font-style: italic;"&gt;ann_FF_Std_online&lt;/span&gt; training period. The features of the training set, their corresponding class matrix, the network, its learning rate, and the number of training cycles are other arguments of the second function. The argument learning rate is together with the threshold of the error tolerated by the network which is usually set to 0. The last built-in function &lt;span style="font-style: italic;"&gt;ann_FF_run&lt;/span&gt; with weight as the result of the second function is finally applied to the features of the 15 test samples. This also has the argument of the network same in the first two functions. It returns the classes to where each sample belongs.&lt;br /&gt;Note that the 30 samples are again divided into two where the first serves as the training set with 5 samples in each class for the ANN to learn and the second represents the test set to be classified, again with 5 samples in each class. The samples of the training set have class matrix [0, 0, 0, 0, 0, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 1, 1, 1, 1] because it is observed that the built-in functions in the ANN toolbox of &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; operate only between 0 and 1. However, the output classes are made to return rounded integer values of 0 for &lt;span style="font-style: italic;"&gt;Snacku&lt;/span&gt;, 1 for &lt;span style="font-style: italic;"&gt;Superthin&lt;/span&gt;, and 2 for &lt;span style="font-style: italic;"&gt;Nova&lt;/span&gt;. Furthermore, it is ascertained that these functions cannot recognize features greater than 1. Since the pixel area feature is obviously greater than 1, it is normalized for the training and test samples. Meanwhile, the network used is composed of 4 neurons in the input layers where each neuron represents a feature, 8 neurons in the hidden layer which may be altered to multiples of 4, and 1 neuron in the output layer corresponding to the class assigned to a test sample.&lt;br /&gt;The tables below are the summary of the test samples' classification where the training parameters are varied to observe the ANN's behavior (click the tables for larger view).&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/_kx7Z922tJd0/SqD1483clhI/AAAAAAAAAuI/IK39m9T1ZZQ/s1600-h/results+1.bmp"&gt;&lt;img style="cursor: pointer; width: 400px; height: 206px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqD1483clhI/AAAAAAAAAuI/IK39m9T1ZZQ/s400/results+1.bmp" alt="" id="BLOGGER_PHOTO_ID_5377568313840539154" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqD15FZUAeI/AAAAAAAAAuQ/XeQjiHuDh1o/s1600-h/results+2.bmp"&gt;&lt;img style="cursor: pointer; width: 400px; height: 206px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqD15FZUAeI/AAAAAAAAAuQ/XeQjiHuDh1o/s400/results+2.bmp" alt="" id="BLOGGER_PHOTO_ID_5377568316130066914" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The first table above has 500 training cycles while the table below it has 1000 training cycles. Both are tested with learning rates of 1.0 and 5.0. The 15 test samples are classified correctly for all different training parameters used. Moreover, it can be observed that as the number of training cycles and the learning rate are increased, the outputs approach 0, 0.5 and 1 and thus approach 0 for &lt;span style="font-style: italic;"&gt;Snacku&lt;/span&gt;, 1 for &lt;span style="font-style: italic;"&gt;Superthin&lt;/span&gt;, and 2 for &lt;span style="font-style: italic;"&gt;Nova&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;The order of the test samples are also randomized to see if they are still to be grouped correctly. Here, 1000 training cycles and learning rate of 5.0 are employed. The results are summarized in the table as follows (click the table for larger view).&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SqD15mUjMvI/AAAAAAAAAuY/0h52XzvIyns/s1600-h/results+3.bmp"&gt;&lt;img style="cursor: pointer; width: 381px; height: 307px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SqD15mUjMvI/AAAAAAAAAuY/0h52XzvIyns/s400/results+3.bmp" alt="" id="BLOGGER_PHOTO_ID_5377568324968461042" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Apparently, all test samples are still grouped appropriately to their corresponding classes even these inputs are in different order. Thus, ANN's class recognition does not require inputs in arranged manner.&lt;br /&gt;&lt;br /&gt;I grade myself 10/10 in this activity because I have successfully implemented ANN for class recognition and all test samples are grouped correctly.&lt;br /&gt;&lt;br /&gt;Thanks to Miguel who sent a working version of the ANN toolbox for &lt;span style="font-style: italic;"&gt;Scilab 4.1.2&lt;/span&gt; for the whole class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;The following &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code is utilized in this activity. This is based from the code of Mr. Cole Fabros in his blog (&lt;span style="font-style: italic;"&gt;http://cole-ap186.blogspot.com&lt;/span&gt;) where it is mentioned that the code is originally made  by Mr. Jeric Tugaff (Both are 2008 AP 186 students).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacku_training = fscanfMat('snacku_training.txt');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;superthin_training = fscanfMat('superthin_training.txt');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;nova_training = fscanfMat('nova_training.txt');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacku_test = fscanfMat('snacku_test.txt');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;superthin_test = fscanfMat('superthin_test.txt');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;nova_test = fscanfMat('nova_test.txt');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacks_training = [snacku_training; superthin_training; nova_training];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacks_training(:,1) = snacks_training(:,1)/max(snacks_training(:,1));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacks_training = snacks_training';&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacks_test = [snacku_test; superthin_test; nova_test];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacks_test(:,1) = snacks_test(:,1)/max(snacks_test(:,1));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacks_test = snacks_test';&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rand('seed', 0);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;network = [4, 8, 1];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;groupings = [0 0 0 0 0 0.5 0.5 0.5 0.5 0.5 1 1 1 1 1];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;learning_rate = [5, 0];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;training_cycle = 1000;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;index = [1:15]';&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;random_index = grand(1, 'prm', index);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;random_snacks = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 1:length(index)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;random_snacks(:,i) = snacks_test(:,random_index(i));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;training_weight = ann_FF_init(network);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;weight = ann_FF_Std_online(snacks_training, groupings, network, training_weight, learning_rate, training_cycle);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;class = ann_FF_run(random_snacks, network, weight);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for j = 1:length(index)&lt;br /&gt;if class(j) &lt; 0.2&lt;br /&gt;class(j) = class(j);&lt;br /&gt;elseif 0.4 &lt; class(j) &amp;amp; class(j) &lt; 0.6&lt;br /&gt;class(j) = 0.5 + class(j);&lt;br /&gt;else&lt;br /&gt;class(j) = 1.0 + class(j);&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;rclass = round(class);&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1657424262821979330-9103394173222106904?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/9103394173222106904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.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/1657424262821979330/posts/default/9103394173222106904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/9103394173222106904'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/09/activity-16-neural-networks.html' title='Activity 16 - Neural Networks'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_kx7Z922tJd0/SqBDbnyhToI/AAAAAAAAAtY/Lbh2Nd603fo/s72-c/snacks+cropped.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-3956301557960259045</id><published>2009-08-27T09:16:00.024+08:00</published><updated>2009-09-03T22:15:53.024+08:00</updated><title type='text'>Activity 15 - Probabilistic Classification</title><content type='html'>&lt;div style="text-align: justify;"&gt;This activity is similar to the previous one except that another method is implemented here. Objects are grouped here using probabilistic classification.&lt;br /&gt;&lt;br /&gt;Instead of 3, only 2 classes are considered here which are all from &lt;span style="font-style: italic;"&gt;Activity 14&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;Snacku&lt;/span&gt; rice crackers and &lt;span style="font-style: italic;"&gt;Superthin&lt;/span&gt; biscuits. As assembled previously, 10 samples represent each class. These are shown below.&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/_kx7Z922tJd0/SpcUXmFJnjI/AAAAAAAAArg/QgXlMN-fpDk/s1600-h/snacks.JPG"&gt;&lt;img style="cursor: pointer; width: 320px; height: 208px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SpcUXmFJnjI/AAAAAAAAArg/QgXlMN-fpDk/s320/snacks.JPG" alt="" id="BLOGGER_PHOTO_ID_5374787075881672242" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Also, the 4 features which are the sample's pixel area, normalized chromaticity values in red, green, and blue and their corresponding data from &lt;span style="font-style: italic;"&gt;Activity 14&lt;/span&gt; are used for probabilistic classification. Each class is again divided into a training set and a test set where each set contains 5 samples.&lt;br /&gt;The probabilistic classification is rooted from the algorithm of linear discriminant analysis (LDA). From the following discriminant function, a test object &lt;span style="font-style: italic;"&gt;k&lt;/span&gt; is assigned to class &lt;span style="font-style: italic;"&gt;i&lt;/span&gt; that has maximum &lt;span style="font-style: italic;"&gt;f_i&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Spe3jj1hdJI/AAAAAAAAAsI/4hAFuMfc8NE/s1600-h/f.bmp"&gt;&lt;img style="cursor: pointer; width: 204px; height: 37px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Spe3jj1hdJI/AAAAAAAAAsI/4hAFuMfc8NE/s320/f.bmp" alt="" id="BLOGGER_PHOTO_ID_5374966501833012370" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Note that the transpose matrix operation is represented by &lt;span style="font-style: italic;"&gt;T&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;-1&lt;/span&gt; is the inverse matrix operation. The last term contains the prior probability of class &lt;span style="font-style: italic;"&gt;i&lt;/span&gt; shown below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Spe3k_YaTxI/AAAAAAAAAsg/P0BjE6cNuiw/s1600-h/p.bmp"&gt;&lt;img style="cursor: pointer; width: 49px; height: 38px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Spe3k_YaTxI/AAAAAAAAAsg/P0BjE6cNuiw/s320/p.bmp" alt="" id="BLOGGER_PHOTO_ID_5374966526406971154" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;From the equation above, &lt;span style="font-style: italic;"&gt;n_i&lt;/span&gt; is the number of samples in class &lt;span style="font-style: italic;"&gt;i&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;N&lt;/span&gt; is the total number of samples in the training set. Meanwhile, matrix &lt;span style="font-style: italic;"&gt;C&lt;/span&gt; is called the pooled within class covariance matrix and this obtained from matrix &lt;span style="font-style: italic;"&gt;c&lt;/span&gt; which is called the covariance matrix. These are as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Spe3jxZHFZI/AAAAAAAAAsQ/_EhGIvSBr6U/s1600-h/C.bmp"&gt;&lt;img style="cursor: pointer; width: 136px; height: 48px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Spe3jxZHFZI/AAAAAAAAAsQ/_EhGIvSBr6U/s320/C.bmp" alt="" id="BLOGGER_PHOTO_ID_5374966505471939986" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Spe3kYPk4JI/AAAAAAAAAsY/bRJA5b5hYOw/s1600-h/small+c.bmp"&gt;&lt;img style="cursor: pointer; width: 80px; height: 48px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Spe3kYPk4JI/AAAAAAAAAsY/bRJA5b5hYOw/s320/small+c.bmp" alt="" id="BLOGGER_PHOTO_ID_5374966515900932242" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Note that there are &lt;span style="font-style: italic;"&gt;g&lt;/span&gt; total number of classes. Covariance matrix is determined from the mean corrected data and the features of the training set which are represented by the following expressions from top to bottom respectively.&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/_kx7Z922tJd0/Spe3lLLQkoI/AAAAAAAAAso/Dz4lAz0AYRc/s1600-h/xo1.bmp"&gt;&lt;img style="cursor: pointer; width: 90px; height: 66px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Spe3lLLQkoI/AAAAAAAAAso/Dz4lAz0AYRc/s320/xo1.bmp" alt="" id="BLOGGER_PHOTO_ID_5374966529573032578" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Spe9f8Zu88I/AAAAAAAAAs4/RnauT9hPLc0/s1600-h/xij.bmp"&gt;&lt;img style="cursor: pointer; width: 148px; height: 24px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Spe9f8Zu88I/AAAAAAAAAs4/RnauT9hPLc0/s320/xij.bmp" alt="" id="BLOGGER_PHOTO_ID_5374973036777632706" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The global mean vector &lt;span style="font-style: italic;"&gt;mu&lt;/span&gt; consists the average of each feature &lt;span style="font-style: italic;"&gt;w_i,j,m&lt;/span&gt; coming from all classes of the training set and &lt;span style="font-style: italic;"&gt;M&lt;/span&gt; is the total number of features. Going back to the discriminant function &lt;span style="font-style: italic;"&gt;f_i&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;mu_i&lt;/span&gt; is composed of the mean of each feature just from class &lt;span style="font-style: italic;"&gt;i&lt;/span&gt; in the training set. Thus, using LDA to classify an unknown or test sample, a training set is still required in order to establish the discriminant function which categorize the test sample with the same features possessed by the training set to a class.&lt;br /&gt;&lt;br /&gt;The table below summarizes the data gathered from the training set (click the table for larger view).&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SpeUYqqo5CI/AAAAAAAAAsA/MmpIMsdB1wU/s1600-h/training.bmp"&gt;&lt;img style="cursor: pointer; width: 400px; height: 173px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SpeUYqqo5CI/AAAAAAAAAsA/MmpIMsdB1wU/s400/training.bmp" alt="" id="BLOGGER_PHOTO_ID_5374927831780877346" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Finally, the results of the LDA to the test set are summarized in the following table (click the table for larger view).&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SpeUYEzCK9I/AAAAAAAAAr4/28ajhCPN7P0/s1600-h/test.bmp"&gt;&lt;img style="cursor: pointer; width: 400px; height: 81px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SpeUYEzCK9I/AAAAAAAAAr4/28ajhCPN7P0/s400/test.bmp" alt="" id="BLOGGER_PHOTO_ID_5374927821615541202" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be observed that the values between the two discriminant functions are very small for all samples of the test set compared to the large deviations between the minimum distances acquired in &lt;span style="font-style: italic;"&gt;Activity 14&lt;/span&gt;. The large values of discriminant function are because of the quantified feature pixel area which is relatively greater than the normalized chromaticity values. Nevertheless, all 10 samples of the test set are correctly grouped to their respective classes.&lt;br /&gt;&lt;br /&gt;I grade myself 10/10 in this activity because I have implemented LDA properly and grouped all test samples to their expected classes.&lt;br /&gt;&lt;br /&gt;I have successfully finished the activity individually. However, I have helped my classmates on how to handle this activity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;The whole &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code below is utilized in this activity.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-size:78%;"&gt;snacku_training = fscanfMat('snacku_training.txt');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;superthin_training = fscanfMat('superthin_training.txt');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacku_test = fscanfMat('snacku_test.txt');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;superthin_test = fscanfMat('superthin_test.txt');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;x_training = [snacku_training; superthin_training];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;x_test = [snacku_test; superthin_test];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;myu1 = [mean(snacku_training(:,1)), mean(snacku_training(:,2)), mean(snacku_training(:,3)), mean(snacku_training(:,4))];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;myu2 = [mean(superthin_training(:,1)), mean(superthin_training(:,2)), mean(superthin_training(:,3)), mean(superthin_training(:,4))];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;myu = [mean(x_training(:,1)), mean(x_training(:,2)), mean(x_training(:,3)), mean(x_training(:,4))];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;x01 = [snacku_training(1,:) - myu; snacku_training(2,:) - myu; snacku_training(3,:) - myu; snacku_training(4,:) - myu; snacku_training(5,:) - myu];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;x02 = [superthin_training(1,:) - myu; superthin_training(2,:) - myu; superthin_training(3,:) - myu; superthin_training(4,:) - myu; superthin_training(5,:) - myu];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;n1 = 5;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;n2 = 5;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;c1 = (x01'*x01)/n1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;c2 = (x02'*x02)/n2;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for r = 1:4&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for s = 1:4&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;C(r, s) = (n1/(n1 + n2))*(c1(r, s) + c2(r, s));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;invC = inv(C);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;P1 = n1/(n1 + n2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;P2 = n2/(n1 + n2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;P = [P1; P2];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for k = 1:(n1 + n2)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;f1(k) = myu1*invC*x_test(k,:)' - (1/2)*myu1*invC*myu1' + log(P(1));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;f2(k) = myu2*invC*x_test(k,:)' - (1/2)*myu2*invC*myu2' + log(P(2));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;f = [f1, f2];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//fprintfMat('f_test.txt', f);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;class = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 1:(n1 + n2)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[a, b] = find(f(i,:) == max(f(i,:)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;class = [class; b];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&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/1657424262821979330-3956301557960259045?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/3956301557960259045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/08/activity-15-probabilistic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/3956301557960259045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/3956301557960259045'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/08/activity-15-probabilistic.html' title='Activity 15 - Probabilistic Classification'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_kx7Z922tJd0/SpcUXmFJnjI/AAAAAAAAArg/QgXlMN-fpDk/s72-c/snacks.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-7866677511949145236</id><published>2009-08-25T09:20:00.031+08:00</published><updated>2009-08-29T09:23:59.608+08:00</updated><title type='text'>Activity 14 - Pattern Recognition</title><content type='html'>&lt;div style="text-align: justify;"&gt;The main objective of this activity is to classify various objects with different characteristics through pattern recognition.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;In pattern recognition, the characteristics of an object belonging to a type or class are called features. These are quantified which may be the object's area, color, and many others. Pattern is then a set of features and a class is a set of patterns which share common features. The task is thus finding the features of an unknown object belonging to one of the several classes.&lt;br /&gt;&lt;br /&gt;There are 3 classes assembled in this activity. They are all edible which include &lt;span style="font-style: italic;"&gt;Snacku&lt;/span&gt; rice crackers, &lt;span style="font-style: italic;"&gt;Superthin&lt;/span&gt; biscuits, and &lt;span style="font-style: italic;"&gt;Nova&lt;/span&gt; multigrain snack. Each class is composed of 10 samples. The setup is shown below.&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/_kx7Z922tJd0/SpiDELtqtqI/AAAAAAAAAtA/M-PLKBXcBs8/s1600-h/snacks+cropped.JPG"&gt;&lt;img style="cursor: pointer; width: 318px; height: 320px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SpiDELtqtqI/AAAAAAAAAtA/M-PLKBXcBs8/s320/snacks+cropped.JPG" alt="" id="BLOGGER_PHOTO_ID_5375190263153735330" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The 30 samples are grouped according to their respective classes for simplified image processing. Each class is divided into two, 5 samples serve as the training set and the other 5 correspond to the test set. Features that have been decided to use for pattern recognition are the sample's pixel area, average normalized chromaticity values in red, green, and blue for a total of 4.&lt;br /&gt;The pixel area is attained by binarizing and inverting the cropped image of a class using the most appropriate predetermined threshold value. The funciton &lt;span style="font-style: italic;"&gt;bwlabel&lt;/span&gt; of &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; is then implemented to sum up the white pixels of each cluster equivalent to the pixel area of a sample and this is similar to the algorithm in &lt;span style="font-style: italic;"&gt;Activity 9&lt;/span&gt;.&lt;br /&gt;Meanwhile, parametric segmentation in &lt;span style="font-style: italic;"&gt;Activity 12&lt;/span&gt; is employed to get the normalized chromaticity values in red, green, and blue of each sample. This is operated through cropped individual sample images of each class. Note that the normalized chromaticity values in red, green, and blue are ensured that these just came from the samples (not with the background) by extracting the pixel coordinates of the segmented images.&lt;br /&gt;Next, quantified features are ordered into a matrix called feature vector. Hence, in this case, a sample's feature vector consists 4 elements. Mean feature vectors representing each class are then obtained using the following equation.&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/_kx7Z922tJd0/SpZs6fp3LWI/AAAAAAAAAqA/5xspq8PMdcs/s1600-h/m.bmp"&gt;&lt;img style="cursor: pointer; width: 98px; height: 46px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SpZs6fp3LWI/AAAAAAAAAqA/5xspq8PMdcs/s320/m.bmp" alt="" id="BLOGGER_PHOTO_ID_5374602957498559842" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Here, &lt;span style="font-style: italic;"&gt;N_j&lt;/span&gt; is the total number number of samples in a class &lt;span style="font-style: italic;"&gt;w_j&lt;/span&gt; which is here, equal to 5 while the 1 x 4 matrix &lt;span style="font-style: italic;"&gt;x_j&lt;/span&gt; is composed of all 4 feature vectors acquired from image processing and then this is summed for &lt;span style="font-style: italic;"&gt;N_j&lt;/span&gt; samples. Through minimum distance classification stated by the following expression, the features of each sample in the test set is then compared to the matrix of mean features &lt;span style="font-style: italic;"&gt;m_j&lt;/span&gt; in the training set.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SpZrS4IbWpI/AAAAAAAAApw/OOtq3CVsFsI/s1600-h/D.bmp"&gt;&lt;img style="cursor: pointer; width: 166px; height: 29px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SpZrS4IbWpI/AAAAAAAAApw/OOtq3CVsFsI/s320/D.bmp" alt="" id="BLOGGER_PHOTO_ID_5374601177362815634" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SpZrTbWJYTI/AAAAAAAAAp4/tSV68yqAWFE/s1600-h/y.bmp"&gt;&lt;img style="cursor: pointer; width: 77px; height: 29px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SpZrTbWJYTI/AAAAAAAAAp4/tSV68yqAWFE/s320/y.bmp" alt="" id="BLOGGER_PHOTO_ID_5374601186815598898" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;From the expressions above, &lt;span style="font-style: italic;"&gt;x&lt;/span&gt; is the feature vector of a test sample, &lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;W&lt;/span&gt; is the total number of class and &lt;span style="font-style: italic;"&gt;T&lt;/span&gt; is the transpose matrix operation. The class index &lt;span style="font-style: italic;"&gt;j&lt;/span&gt; of the minimum distance &lt;span style="font-style: italic;"&gt;D_j(x)&lt;/span&gt; is then assigned to the &lt;span style="font-style: italic;"&gt;Nth&lt;/span&gt; sample from the test set of a class.&lt;br /&gt;&lt;br /&gt;The results from the training set are shown in the table below (click the table for larger view).&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/_kx7Z922tJd0/SpaF_zcKdZI/AAAAAAAAArY/vnQXFFbIsvg/s1600-h/training.bmp"&gt;&lt;img style="cursor: pointer; width: 400px; height: 146px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SpaF_zcKdZI/AAAAAAAAArY/vnQXFFbIsvg/s400/training.bmp" alt="" id="BLOGGER_PHOTO_ID_5374630536499852690" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Finally, the resulting classification of the test set is summarized in the following table (click the table for larger view).&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SpaF_q2gAUI/AAAAAAAAArQ/lR7o3sZl-DA/s1600-h/test.bmp"&gt;&lt;img style="cursor: pointer; width: 400px; height: 147px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SpaF_q2gAUI/AAAAAAAAArQ/lR7o3sZl-DA/s400/test.bmp" alt="" id="BLOGGER_PHOTO_ID_5374630534194397506" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;It can be observed that the calculated distance &lt;span style="font-style: italic;"&gt;D_j(x)&lt;/span&gt; is relatively large when a test sample does not match the expected class. Notice that the distances are big numbers because recall that the quantified feature pixel area is relatively larger than the normalized chromaticity values. But most importantly, all 15 samples in the test set are classified correctly.&lt;br /&gt;&lt;br /&gt;Since I have understood the process of pattern recognition using the minimum distance classification and at the same time, successfully classifying all the samples in the test set, I grade myself 10/10 in this activity.&lt;br /&gt;&lt;br /&gt;I have successfully completed this activity through discussions with Gary.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;The whole &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code below is utilized in this activity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;stacksize(4e7);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//snacku = gray_imread('snacku.jpg');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(snacku);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(snacku, 'gray snacku.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snack_A = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for a = 1:3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snack = gray_imread('gray snack'+string(a)+'.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;if a == 1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snack = im2bw(snack, 175/255);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;elseif a == 2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snack = im2bw(snack, 160/255);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snack = im2bw(snack, 155/255);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snack = 1 - snack;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(a);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(snack);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[L, n] = bwlabel(snack);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;A = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 1:n&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;b = (L == i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;A(i) = sum(b);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snack_A(i, a) = A(i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacku_A = snack_A(:,1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;superthin_A = snack_A(:,2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;nova_A = snack_A(:,3);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;training_snack_A = [snacku_A(1:5), superthin_A(1:5), nova_A(1:5)];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;test_snack_A = [snacku_A(6:10), superthin_A(6:10), nova_A(6:10)];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Average Normalized RGB Values&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;mean_snacku_r = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;mean_snacku_g = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;mean_snacku_b = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for j = 1:10&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;image = imread('snacku'+string(j)+'.jpg');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;I = imread('snacku ROI.jpg');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;R = I(:,:,1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;G = I(:,:,2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;B = I(:,:,3);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;RGB = R + G + B;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;r = R./RGB;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;b = B./RGB;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;g = G./RGB;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Ri = image(:,:,1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Gi = image(:,:,2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Bi = image(:,:,3);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;RGBi = Ri + Gi + Bi;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;ri = Ri./RGBi;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;bi = Bi./RGBi;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;gi = Gi./RGBi;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Parametric Segmentation&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rmean = mean(r);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;gmean = mean(g);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rsigma = stdev(r);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;gsigma = stdev(g);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rp = (1/(rsigma*sqrt(2*%pi)))*exp(-((ri - rmean).^2)/(2*rsigma^2));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;gp = (1/(gsigma*sqrt(2*%pi)))*exp(-((gi - gmean).^2)/(2*gsigma^2));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rgp = round(rp.*gp);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(j + 3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(rgp);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[x, y] = find(rgp ~= 0);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacku_r = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacku_g = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacku_b = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for k = 1:length(x)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacku_r = [snacku_r, ri(x(k), y(k))];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacku_g = [snacku_g, gi(x(k), y(k))];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;snacku_b = [snacku_b, bi(x(k), y(k))];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;mean_snacku_r(j,:) = mean(snacku_r);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;mean_snacku_g(j,:) = mean(snacku_g);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;mean_snacku_b(j,:) = mean(snacku_b);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;training_mean_snacku_r = mean_snacku_r(1:5);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;training_mean_snacku_g = mean_snacku_g(1:5);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;training_mean_snacku_b = mean_snacku_b(1:5);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;training_color_snacku = [mean(training_mean_snacku_r), mean(training_mean_snacku_g), mean(training_mean_snacku_b)];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//fprintfMat('training_color_snack1.txt', training_color_snacku);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;test_mean_snacku_r = mean_snacku_r(6:10);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;test_mean_snacku_g = mean_snacku_g(6:10);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;test_mean_snacku_b = mean_snacku_b(6:10);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;test_color_snacku = [test_mean_snacku_r, test_mean_snacku_g, test_mean_snacku_b];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//fprintfMat('test_color_snack1.txt', test_color_snacku);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Test Object Classification&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;D_test_snack = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for l = 1:3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for m = 1:3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;training_color_snack = fscanfMat('training_color_snack'+string(l)+'.txt');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;m_snack = [mean(training_snack_A(:,l)), training_color_snack];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;test_color_snack = fscanfMat('test_color_snack'+string(m)+'.txt');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for n = 1:5&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;x_snack = [test_snack_A(n, m), test_color_snack(n, 1), test_color_snack(n, 2), test_color_snack(n, 3)];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;D_test = [x_snack - m_snack];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;D_test_snack = [D_test_snack; sqrt(D_test*D_test')];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;D_test_snacku = D_test_snack(1:15);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;D_test_superthin = D_test_snack(16:30);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;D_test_nova = D_test_snack(31:45);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;D = [D_test_snacku, D_test_superthin, D_test_nova];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;class = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for o = 1:15&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[a, b] = find(D(o,:) == min(D(o,:)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;class = [class; b];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1657424262821979330-7866677511949145236?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/7866677511949145236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/08/activity-14-pattern-recognition.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/7866677511949145236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/7866677511949145236'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/08/activity-14-pattern-recognition.html' title='Activity 14 - Pattern Recognition'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_kx7Z922tJd0/SpiDELtqtqI/AAAAAAAAAtA/M-PLKBXcBs8/s72-c/snacks+cropped.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-5400075463700430067</id><published>2009-08-18T08:57:00.093+08:00</published><updated>2009-09-10T17:33:25.162+08:00</updated><title type='text'>Activity 13 - Correcting Geometric Distortion</title><content type='html'>&lt;div style="text-align: justify;"&gt;The barrel geometric distortion in an image is removed in this activity based on the image's pixel coordinates and graylevel values.&lt;br /&gt;&lt;br /&gt;The following distorted image of a grid is obtained from the internet.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SpxzrTbgalI/AAAAAAAAAtI/rBi_ulfr8CE/s1600-h/barrel_distortion.jpg"&gt;&lt;img style="cursor: pointer; width: 150px; height: 151px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SpxzrTbgalI/AAAAAAAAAtI/rBi_ulfr8CE/s320/barrel_distortion.jpg" alt="" id="BLOGGER_PHOTO_ID_5376299242960742994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Source: &lt;span style="font-style: italic;"&gt;http://www.jmg-galleries.com/blog/2007/08/01/photo-term-series-post-13-barrel-distortion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The correction starts with the image's pixel coordinates. A subgrid from a distorted image can be thought of transformation of this subgrid from the ideal image through functions in the horizontal and vertical coordinates as shown below.&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/_kx7Z922tJd0/SqL7MpB_Y0I/AAAAAAAAAvI/qzh261okP9I/s1600-h/x+hat.bmp"&gt;&lt;img style="cursor: pointer; width: 60px; height: 21px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqL7MpB_Y0I/AAAAAAAAAvI/qzh261okP9I/s320/x+hat.bmp" alt="" id="BLOGGER_PHOTO_ID_5378137099624997698" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SqL7NBMg3GI/AAAAAAAAAvQ/tM6a12ymRYA/s1600-h/y+hat.bmp"&gt;&lt;img style="cursor: pointer; width: 61px; height: 21px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SqL7NBMg3GI/AAAAAAAAAvQ/tM6a12ymRYA/s320/y+hat.bmp" alt="" id="BLOGGER_PHOTO_ID_5378137106111585378" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The transformation of a vertex from a subgrid is then illustrated as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqJ3E0c32XI/AAAAAAAAAu4/bx63IMNaQCM/s1600-h/pixel+coordinates.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqJ3E0c32XI/AAAAAAAAAu4/bx63IMNaQCM/s320/pixel+coordinates.bmp" alt="" id="BLOGGER_PHOTO_ID_5377991829716719986" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The following transformation functions are thus bilinear if the vertex from the ideal image is mapped simultaneously in both directions.&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/_kx7Z922tJd0/SqL9XJRknaI/AAAAAAAAAvY/4IDKEUy19J4/s1600-h/r.bmp"&gt;&lt;img style="cursor: pointer; width: 185px; height: 21px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SqL9XJRknaI/AAAAAAAAAvY/4IDKEUy19J4/s320/r.bmp" alt="" id="BLOGGER_PHOTO_ID_5378139479102234018" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SqL9XrsPKKI/AAAAAAAAAvg/tUm2P5zWbCw/s1600-h/s.bmp"&gt;&lt;img style="cursor: pointer; width: 186px; height: 21px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqL9XrsPKKI/AAAAAAAAAvg/tUm2P5zWbCw/s320/s.bmp" alt="" id="BLOGGER_PHOTO_ID_5378139488340879522" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Eight equations are enough to determine the unknown eight coefficients &lt;span style="font-style: italic;"&gt;c_1&lt;/span&gt; to &lt;span style="font-style: italic;"&gt;c_8&lt;/span&gt; and these come from the two coordinates of the four vertices of a closed region in the grid both in the distorted and ideal image. Hence, a different set of coefficients is yielded for other closed region.&lt;br /&gt;&lt;br /&gt;Initially from the distorted image obtained from the internet, a vertex from the most undistorted region is located. In this case, it is approximately near the image's center. Then, the length in pixels of the ideal rectangle is measured. The size of the ideal rectangle in the grid is found to be 28 x 28 pixels. Starting from the vertex, the pixel coordinates by counting 28 pixels to its left, right, top and bottom are determined and so the vertex points of the ideal grid are generated which is shown as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqJkP_d3w6I/AAAAAAAAAug/eUFx3_WLdBk/s1600-h/idealgrid.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 151px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqJkP_d3w6I/AAAAAAAAAug/eUFx3_WLdBk/s320/idealgrid.bmp" alt="" id="BLOGGER_PHOTO_ID_5377971130931332002" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Notice that the pixel coordinates at the edges are also obtained in order to cover the whole distorted image in correcting the barrel distortion. Meanwhile, the pixel coordinates of the vertices in the distorted image corresponding to the ideal image are gathered using the function &lt;span style="font-style: italic;"&gt;locate&lt;/span&gt; of &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt;.&lt;br /&gt;The sets of coefficients for each rectangle are then determined from the following equations.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SqMFWBASG8I/AAAAAAAAAvo/aRoCM-LwGOs/s1600-h/x+hat+matrix.bmp"&gt;&lt;img style="cursor: pointer; width: 186px; height: 85px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SqMFWBASG8I/AAAAAAAAAvo/aRoCM-LwGOs/s320/x+hat+matrix.bmp" alt="" id="BLOGGER_PHOTO_ID_5378148255795387330" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqMFWeOQQ4I/AAAAAAAAAvw/OVQ2KEgY3AQ/s1600-h/y+hat+matrix.bmp"&gt;&lt;img style="cursor: pointer; width: 188px; height: 85px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqMFWeOQQ4I/AAAAAAAAAvw/OVQ2KEgY3AQ/s320/y+hat+matrix.bmp" alt="" id="BLOGGER_PHOTO_ID_5378148263638614914" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The matrix expressions can be rewritten as follows.&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/_kx7Z922tJd0/SqMIwD44NyI/AAAAAAAAAv4/yhlGp82neTs/s1600-h/X.bmp"&gt;&lt;img style="cursor: pointer; width: 62px; height: 21px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqMIwD44NyI/AAAAAAAAAv4/yhlGp82neTs/s320/X.bmp" alt="" id="BLOGGER_PHOTO_ID_5378152001781118754" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqMIwXYcyCI/AAAAAAAAAwA/kOpWAjse7-8/s1600-h/Y.bmp"&gt;&lt;img style="cursor: pointer; width: 61px; height: 21px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqMIwXYcyCI/AAAAAAAAAwA/kOpWAjse7-8/s320/Y.bmp" alt="" id="BLOGGER_PHOTO_ID_5378152007013812258" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;So the coefficients are computed as shown below.&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/_kx7Z922tJd0/SqMIw3Rl3fI/AAAAAAAAAwI/n3Ia8DtgzS0/s1600-h/C+1+to+4.bmp"&gt;&lt;img style="cursor: pointer; width: 78px; height: 24px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqMIw3Rl3fI/AAAAAAAAAwI/n3Ia8DtgzS0/s320/C+1+to+4.bmp" alt="" id="BLOGGER_PHOTO_ID_5378152015574982130" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SqMIxcELhBI/AAAAAAAAAwQ/t4LBOQmeaZE/s1600-h/C+5+to+8.bmp"&gt;&lt;img style="cursor: pointer; width: 76px; height: 24px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqMIxcELhBI/AAAAAAAAAwQ/t4LBOQmeaZE/s320/C+5+to+8.bmp" alt="" id="BLOGGER_PHOTO_ID_5378152025450841106" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Now, per pixel inside a rectangle, the coordinates from the distorted image are attained using the corresponding set of coefficients in that rectangle through the following equations.&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/_kx7Z922tJd0/SqMKNfhf4mI/AAAAAAAAAwY/4cacF6hzfCU/s1600-h/x+distorted.bmp"&gt;&lt;img style="cursor: pointer; width: 137px; height: 21px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqMKNfhf4mI/AAAAAAAAAwY/4cacF6hzfCU/s320/x+distorted.bmp" alt="" id="BLOGGER_PHOTO_ID_5378153606927082082" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqMKNzV2PEI/AAAAAAAAAwg/KsEniPvv9hs/s1600-h/y+distorted.bmp"&gt;&lt;img style="cursor: pointer; width: 140px; height: 21px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqMKNzV2PEI/AAAAAAAAAwg/KsEniPvv9hs/s320/y+distorted.bmp" alt="" id="BLOGGER_PHOTO_ID_5378153612246924354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The grayscale values of each pixel are the next to be handled. At first, a matrix of zeros with the same size of the distorted image (150 x 151) is created. Then, interpolated graylevel values of each computed locations in the distorted image are copied to this blank matrix.&lt;br /&gt;Two types of graylevel interpolation are implemented here. The first one is the nearest neighbor interpolation technique where the graylevel value of the nearest integer-valued coordinate is used and this just comes from the rounded pixel coordinates in the distorted image calculated using the eight coefficients.&lt;br /&gt;Bilinear graylevel interpolation is the second technique employed to correct the barrel distortion. Since many of the computed pixel coordinates in the distorted image are not integer-valued, this technique is expected to result to a better corrected image compared to the nearest neighbor graylevel interpolation. Otherwise, the graylevel value at integer-valued locations is automatically copied to the blank matrix. An illustration of bilinear graylevel interpolation is shown below.&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/_kx7Z922tJd0/SqJ3FoaK8DI/AAAAAAAAAvA/355hD6ykCaA/s1600-h/bilinear+interpolation.bmp"&gt;&lt;img style="cursor: pointer; width: 203px; height: 153px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SqJ3FoaK8DI/AAAAAAAAAvA/355hD6ykCaA/s320/bilinear+interpolation.bmp" alt="" id="BLOGGER_PHOTO_ID_5377991843664031794" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The pixel location pointed above is clearly not integer-valued. Through the equation below, the graylevel value is obtained at this location.&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/_kx7Z922tJd0/SqMXaTv3yQI/AAAAAAAAAwo/QeTjxdT9VQQ/s1600-h/v.bmp"&gt;&lt;img style="cursor: pointer; width: 140px; height: 21px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SqMXaTv3yQI/AAAAAAAAAwo/QeTjxdT9VQQ/s320/v.bmp" alt="" id="BLOGGER_PHOTO_ID_5378168120755603714" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Notice that the equation above has form exactly the same in calculating the pixel coordinates in the distorted image. Thus, the same procedure applies in the bilinear graylevel interpolation which is based from the matrix expression shown as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SqM0Z8jP2mI/AAAAAAAAAxI/7N-3j11GOJ4/s1600-h/v+matrix.bmp"&gt;&lt;img style="cursor: pointer; width: 194px; height: 85px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SqM0Z8jP2mI/AAAAAAAAAxI/7N-3j11GOJ4/s320/v+matrix.bmp" alt="" id="BLOGGER_PHOTO_ID_5378200000365845090" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The coefficients &lt;span style="font-style: italic;"&gt;a&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;b&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;c&lt;/span&gt;, and &lt;span style="font-style: italic;"&gt;d&lt;/span&gt; must first be determined using four equations. These are then coming from the four nearest pixels of each computed pixel coordinate in the distorted image. The integer coordinates are assumed to be at the center of each pixel hence the four nearest pixels are located at the rounded values of 0.5 pixel away from calculated pixel location in the distorted image for both directions. The 4 x 4 matrix from the expression above are then assembled for each computed pixel coordinate in the distorted image which contains the location of the four nearest pixels. The following is the simplified version of the matrix expression above.&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/_kx7Z922tJd0/SqMyORcixcI/AAAAAAAAAw4/nO_RHX1dyOk/s1600-h/V+big.bmp"&gt;&lt;img style="cursor: pointer; width: 64px; height: 21px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SqMyORcixcI/AAAAAAAAAw4/nO_RHX1dyOk/s320/V+big.bmp" alt="" id="BLOGGER_PHOTO_ID_5378197600793183682" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Then, the coefficients &lt;span style="font-style: italic;"&gt;a&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;b&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;c&lt;/span&gt;, and &lt;span style="font-style: italic;"&gt;d&lt;/span&gt; for each computed pixel location in the distorted image are acquired as shown below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqMyO2a6E-I/AAAAAAAAAxA/I9TD48VipEA/s1600-h/a+to+d.bmp"&gt;&lt;img style="cursor: pointer; width: 80px; height: 24px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqMyO2a6E-I/AAAAAAAAAxA/I9TD48VipEA/s320/a+to+d.bmp" alt="" id="BLOGGER_PHOTO_ID_5378197610718434274" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The interpolated graylevel value of each calculated pixel location in the distorted image is then transferred to the blank matrix for each pixel inside a rectangle in the ideal grid. The whole algorithm is repeated for the other rectangles in the ideal grid.&lt;br /&gt;Recall that vertices at the perimeter of the ideal grid and distorted image are also considered. Thus to prevent incorrect indexing, the graylevel value is directly copied from the distorted image onto the black matrix at the pixel coordinate inside a rectangle in the ideal grid, if the calculated pixel location is less than 1 or greater than the length of the image which is 150 for the vertical direction and 151 for the horizontal direction.&lt;br /&gt;&lt;br /&gt;The next figure is the result of the nearest neighbor graylevel interpolation technique applied to the barrel distorted grid image.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqJkd5RTxsI/AAAAAAAAAuw/62Uoo0A-fic/s1600-h/newgrid_nearest_neighbor.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 151px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqJkd5RTxsI/AAAAAAAAAuw/62Uoo0A-fic/s320/newgrid_nearest_neighbor.bmp" alt="" id="BLOGGER_PHOTO_ID_5377971369786197698" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be observed that the lines are pixelated and jagged even though the curved grid lines are straightened.&lt;br /&gt;Meanwhile, the figure below is the result of the bilinear graylevel interpolation.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SqJkdf15-vI/AAAAAAAAAuo/elPxJmD_BDk/s1600-h/newgrid_bilinear.bmp"&gt;&lt;img style="cursor: pointer; width: 150px; height: 151px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SqJkdf15-vI/AAAAAAAAAuo/elPxJmD_BDk/s320/newgrid_bilinear.bmp" alt="" id="BLOGGER_PHOTO_ID_5377971362960374514" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Apparently, bilinear graylevel interpolation is better than the nearest neighbor interpolation technique. The barrel distortion is completely eliminated at the same time producing smooth grid lines.&lt;br /&gt;&lt;br /&gt;I say that this activity has the most complicated code so far but since I have successfully corrected the barrel distortion of a grid image and understand how the whole process is implemented, I grade myself 10/10.&lt;br /&gt;&lt;br /&gt;Earl has helped me in this activity and I thank Mandy for explaining how she has implemented the bilinear graylevel interpolation technique.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;The following Scilab code is utilized in this activity.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;stacksize(4e7);&lt;br /&gt;&lt;br /&gt;distort = gray_imread('barrel_distortion.jpg');&lt;br /&gt;&lt;br /&gt;pixelx = 28;&lt;br /&gt;pixely = 28;&lt;br /&gt;tran = 20;&lt;br /&gt;&lt;br /&gt;s = size(distort);&lt;br /&gt;ideal = zeros(s(1), s(2));&lt;br /&gt;&lt;br /&gt;xit = [];&lt;br /&gt;yit = [];&lt;br /&gt;for i = 1:5&lt;br /&gt;for j = 1:5&lt;br /&gt;xit = [xit, tran + pixelx*(j - 1)];&lt;br /&gt;yit = [yit, tran + pixely*(i - 1)];&lt;br /&gt;ideal(tran + pixelx*(i - 1), tran + pixely*(j - 1)) = 1;&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;xit = matrix(xit, 5, 5);&lt;br /&gt;yit = matrix(yit, 5, 5);&lt;br /&gt;&lt;br /&gt;xi = zeros(7, 7);&lt;br /&gt;yi = zeros(7, 7);&lt;br /&gt;xi(2:6, 2:6) = xit;&lt;br /&gt;yi(2:6, 2:6) = yit;&lt;br /&gt;&lt;br /&gt;xi(1,:) = 1;&lt;br /&gt;xi(7,:) = s(1);&lt;br /&gt;yi(:,1) = 1;&lt;br /&gt;yi(:,7) = s(2);&lt;br /&gt;ideal(1, 1) = 1;&lt;br /&gt;ideal(1, s(2)) = 1;&lt;br /&gt;ideal(s(1), 1) = 1;&lt;br /&gt;ideal(s(1), s(2)) = 1;&lt;br /&gt;&lt;br /&gt;for k = 1:5&lt;br /&gt;xi(k + 1, 1) = xi(k + 1, 2);&lt;br /&gt;xi(k + 1, 7) = xi(k + 1, 2);&lt;br /&gt;yi(1, k + 1) = yi(2, k + 1);&lt;br /&gt;yi(7, k + 1) = yi(2, k + 1);&lt;br /&gt;ideal(xi(k + 1, 2), 1) = 1;&lt;br /&gt;ideal(1, yi(2, k + 1)) = 1;&lt;br /&gt;ideal(xi(k + 1, 2), s(2)) = 1;&lt;br /&gt;ideal(s(1), yi(2, k + 1)) = 1;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;//scf(0);&lt;br /&gt;//imshow(ideal);&lt;br /&gt;//imwrite(ideal, 'idealgrid.bmp');&lt;br /&gt;&lt;br /&gt;//scf(1);&lt;br /&gt;//imshow(distort, []);&lt;br /&gt;//xdyd = (locate(49, 1))';&lt;br /&gt;//fprintfMat('xdyd.txt', xdyd);&lt;br /&gt;&lt;br /&gt;xdyd = fscanfMat('xdyd.txt');&lt;br /&gt;&lt;br /&gt;xd = s(1) - xdyd(:,2);&lt;br /&gt;yd = xdyd(:,1);&lt;br /&gt;&lt;br /&gt;xd = (matrix(xd', 7, 7))';&lt;br /&gt;yd = (matrix(yd', 7, 7))';&lt;br /&gt;&lt;br /&gt;newgrid_bilinear = zeros(s(1), s(2));&lt;br /&gt;newgrid_nearest_neighbor = zeros(s(1), s(2));&lt;br /&gt;for a = 1:6&lt;br /&gt;for b = 1:6&lt;br /&gt;&lt;br /&gt;vertex_upperleft = [xd(a, b), yd(a, b)];&lt;br /&gt;vertex_upperright = [xd(a, b + 1), yd(a, b + 1)];&lt;br /&gt;vertex_lowerleft = [xd(a + 1, b), yd(a + 1, b)];&lt;br /&gt;vertex_lowerright = [xd(a + 1, b + 1), yd(a + 1, b + 1)];&lt;br /&gt;&lt;br /&gt;xd4 = [vertex_upperleft(1); vertex_upperright(1); vertex_lowerleft(1); vertex_lowerright(1)];&lt;br /&gt;yd4 = [vertex_upperleft(2); vertex_upperright(2); vertex_lowerleft(2); vertex_lowerright(2)];&lt;br /&gt;&lt;br /&gt;T = [xi(a, b) yi(a, b) xi(a, b)*yi(a, b) 1; xi(a, b + 1) yi(a, b + 1) xi(a, b + 1)*yi(a, b + 1) 1; xi(a + 1, b) yi(a + 1, b) xi(a + 1, b)*yi(a + 1, b) 1; xi(a + 1, b + 1) yi(a + 1, b + 1) xi(a + 1, b + 1)*yi(a + 1, b + 1) 1];&lt;br /&gt;&lt;br /&gt;C1to4 = inv(T)*xd4;&lt;br /&gt;C5to8 = inv(T)*yd4;&lt;br /&gt;&lt;br /&gt;for m = (xi(a, 1)):(xi((a + 1), 1))&lt;br /&gt;for n = (yi(1, b)):(yi(1, (b + 1)))&lt;br /&gt;&lt;br /&gt;points_in_one_box = [m n m*n 1];&lt;br /&gt;&lt;br /&gt;xnew = points_in_one_box*C1to4;&lt;br /&gt;ynew = points_in_one_box*C5to8;&lt;br /&gt;rxnew = round(xnew);&lt;br /&gt;rynew = round(ynew);&lt;br /&gt;&lt;br /&gt;if xnew &lt; 1 | xnew &gt; s(1) | ynew &lt; 1 | ynew &gt; s(2)&lt;br /&gt;newgrid_bilinear(m, n) = distort(m, n);&lt;br /&gt;newgrid_nearest_neighbor(m, n) = distort(m, n);&lt;br /&gt;else&lt;br /&gt;&lt;br /&gt;if xnew - rxnew == 0 &amp;amp; ynew - rynew == 0&lt;br /&gt;newgrid_bilinear(m, n) = distort(xnew, ynew);&lt;br /&gt;else&lt;br /&gt;&lt;br /&gt;nearest_lowerleft = [round(xnew - 0.5), round(ynew - 0.5)];&lt;br /&gt;nearest_upperleft = [round(xnew - 0.5), round(ynew + 0.5)];&lt;br /&gt;nearest_lowerright = [round(xnew + 0.5), round(ynew - 0.5)];&lt;br /&gt;nearest_upperright = [round(xnew + 0.5), round(ynew + 0.5)];&lt;br /&gt;&lt;br /&gt;nearest_pixels = [nearest_lowerleft(1) nearest_lowerleft(2) nearest_lowerleft(1)*nearest_lowerleft(2) 1; nearest_upperleft(1) nearest_upperleft(2) nearest_upperleft(1)*nearest_upperleft(2) 1; nearest_lowerright(1) nearest_lowerright(2) nearest_lowerright(1)*nearest_lowerright(2) 1; nearest_upperright(1) nearest_upperright(2) nearest_upperright(1)*nearest_upperright(2) 1];&lt;br /&gt;distortgray_lowerleft = distort(nearest_lowerleft(1), nearest_lowerleft(2));&lt;br /&gt;distortgray_upperleft = distort(nearest_upperleft(1), nearest_upperleft(2));&lt;br /&gt;distortgray_lowerright = distort(nearest_lowerright(1), nearest_lowerright(2));&lt;br /&gt;distortgray_upperright = distort(nearest_upperright(1), nearest_upperright(2));&lt;br /&gt;distortgray_nearest = [distortgray_lowerleft; distortgray_upperleft; distortgray_lowerright; distortgray_upperright];&lt;br /&gt;&lt;br /&gt;abcd_coefficients = inv(nearest_pixels)*distortgray_nearest;&lt;br /&gt;interpolated_gray = [xnew ynew xnew*ynew 1]*abcd_coefficients;&lt;br /&gt;&lt;br /&gt;newgrid_bilinear(m, n) = interpolated_gray;&lt;br /&gt;newgrid_nearest_neighbor(m, n) = distort(rxnew, rynew);&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;//scf(2);&lt;br /&gt;//imshow(newgrid_bilinear, []);&lt;br /&gt;//imwrite(newgrid_bilinear/max(newgrid_bilinear), 'newgrid_bilinear.bmp');&lt;br /&gt;&lt;br /&gt;//scf(3);&lt;br /&gt;//imshow(newgrid_nearest_neighbor, []);&lt;br /&gt;//imwrite(newgrid_nearest_neighbor/max(newgrid_nearest_neighbor), 'newgrid_nearest_neighbor.bmp');&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1657424262821979330-5400075463700430067?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/5400075463700430067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/08/activity-13-correcting-geometric.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/5400075463700430067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/5400075463700430067'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/08/activity-13-correcting-geometric.html' title='Activity 13 - Correcting Geometric Distortion'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_kx7Z922tJd0/SpxzrTbgalI/AAAAAAAAAtI/rBi_ulfr8CE/s72-c/barrel_distortion.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-482233832786897184</id><published>2009-08-04T09:01:00.028+08:00</published><updated>2009-08-05T17:21:20.612+08:00</updated><title type='text'>Activity 12 - Color Image Segmentation</title><content type='html'>&lt;div style="text-align: justify;"&gt;A region of interest (ROI) from a colored image is segmented in this activity using two types of segmentation - Parametric and Non-parametric.&lt;br /&gt;&lt;br /&gt;The following image is searched from the internet.&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/_kx7Z922tJd0/SnkVxJjRl2I/AAAAAAAAAnI/X0Au1zR8iIo/s1600-h/big_blue_ball.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 362px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SnkVxJjRl2I/AAAAAAAAAnI/X0Au1zR8iIo/s400/big_blue_ball.jpg" alt="" id="BLOGGER_PHOTO_ID_5366344365110302562" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Source: &lt;span style="font-style: italic;"&gt;http://www.justfurfun.org/doghtml/yorikpage.htm&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The blue ball which the dog holds is the ROI used for segmentation. A monochromatic patch is then cropped from the ROI and this is shown below.&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/_kx7Z922tJd0/SnkVxkuE50I/AAAAAAAAAnQ/iO6hyDdQke4/s1600-h/ROI.JPG"&gt;&lt;img style="cursor: pointer; width: 20px; height: 20px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnkVxkuE50I/AAAAAAAAAnQ/iO6hyDdQke4/s400/ROI.JPG" alt="" id="BLOGGER_PHOTO_ID_5366344372403365698" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;This monochromatic patch is the basis of extracting the ROI from the whole image. Its normalized primary color channels red (R), green (G), and blue (B) separately with the whole image's are obtained next. This is done by dividing each color channel element-by-element to the sum of the RGB arrays resulting to the normalized chromaticity coordinates for red (&lt;span style="font-style: italic;"&gt;r&lt;/span&gt;), green (&lt;span style="font-style: italic;"&gt;g&lt;/span&gt;), and blue (&lt;span style="font-style: italic;"&gt;b&lt;/span&gt;). The normalized chromaticity space is as follows.&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/_kx7Z922tJd0/SnkWjKkJZ-I/AAAAAAAAAn4/zxdBOrmOfTo/s1600-h/NCC.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 321px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SnkWjKkJZ-I/AAAAAAAAAn4/zxdBOrmOfTo/s400/NCC.jpg" alt="" id="BLOGGER_PHOTO_ID_5366345224375855074" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Here, the 3 dimensional color space is reduced to only 2 having red as the horizontal axis and green as the vertical axis. Of course, blue has its region in the normalized chromaticity space since the relation between the normalized chromaticity coordinates is &lt;span style="font-style: italic;"&gt;r + g + b = 1&lt;/span&gt;. Normalizing the color channels of the whole image and the patch of the ROI is very important because the shade or brightness of the colors of the whole image and the ROI is separated from their pure colors or chromaticities and so the image is segmented correctly.&lt;br /&gt;&lt;br /&gt;Parametric segmentation is the first type implemented to the image. In this process, the probability of each pixel from the whole image belonging to the chromaticity of the ROI is determined through a Gaussian distribution having the form as shown below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Snk2eK9HukI/AAAAAAAAAoA/8XdZ-c8Qnbc/s1600-h/rgaussian.jpg"&gt;&lt;img style="cursor: pointer; width: 145px; height: 57px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Snk2eK9HukI/AAAAAAAAAoA/8XdZ-c8Qnbc/s400/rgaussian.jpg" alt="" id="BLOGGER_PHOTO_ID_5366380322953345602" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Snk2edWAPDI/AAAAAAAAAoI/evEsyTvP1cs/s1600-h/ggaussian.jpg"&gt;&lt;img style="cursor: pointer; width: 150px; height: 61px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Snk2edWAPDI/AAAAAAAAAoI/evEsyTvP1cs/s400/ggaussian.jpg" alt="" id="BLOGGER_PHOTO_ID_5366380327889550386" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;From the expressions above, &lt;span style="font-style: italic;"&gt;sigma&lt;/span&gt; is the standard deviation of the normalized chromaticities of the patch of the ROI while &lt;span style="font-style: italic;"&gt;mu&lt;/span&gt; is the mean. Then, &lt;span style="font-style: italic;"&gt;r&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;g&lt;/span&gt; come from the normalized chromaticities of each pixel of the whole image. The segmented image is then generated from the multiplied or joint probabilities in the red and blue normalized channels. This is illustrated as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SnkVye7OR3I/AAAAAAAAAno/Rles0zXriVw/s1600-h/parametric+segment.bmp"&gt;&lt;img style="cursor: pointer; width: 400px; height: 362px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SnkVye7OR3I/AAAAAAAAAno/Rles0zXriVw/s400/parametric+segment.bmp" alt="" id="BLOGGER_PHOTO_ID_5366344388027762546" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Apparently, the white region represents the ROI that is the blue ball. Comparing from the original image with the blue ball, the image is well segmented since various shades of the ROI are indeed ignored and thus the whole blue ball is almost separated from the image.&lt;br /&gt;&lt;br /&gt;Non-parametric segmentation operates in the probability distribution of the normalized chromaticity of the ROI alone without depending to a function such as the Gaussian distribution employed in the parametric segmentation. A 2 dimensional histogram is acquired here as shown below which is then verified from the normalized chromaticity space.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SnkVxzPYC8I/AAAAAAAAAnY/Yk4K4Vev_78/s1600-h/2dhistogram+bins+32.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 243px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SnkVxzPYC8I/AAAAAAAAAnY/Yk4K4Vev_78/s400/2dhistogram+bins+32.bmp" alt="" id="BLOGGER_PHOTO_ID_5366344376301128642" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SnkVyGt3OgI/AAAAAAAAAng/sWlgUMGmxUw/s1600-h/2dhistogram+bins+256.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SnkVyGt3OgI/AAAAAAAAAng/sWlgUMGmxUw/s400/2dhistogram+bins+256.bmp" alt="" id="BLOGGER_PHOTO_ID_5366344381529274882" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Both histograms above are comparable to the normalized chromaticity space, their bins are just varied for the sake of visualization (left histogram with 32 bins) and application of the histogram backprojection process (right histogram with 256 bins). The histogram agrees with the normalized chromaticity space since the peaks are located within the blue region knowing that the ROI has chromaticity within this area.&lt;br /&gt;The histogram backprojection is where each pixel in the image is assigned to a value corresponding to the histogram value in the normalized chromaticity space. Hence, it is essential to increase the bins of the histogram to 256 in order to accommodate the 256 rounded integer values in the normalized chromaticity space. Finally, the result of the non-parametric segmentation is the following.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnkV-Xh_qDI/AAAAAAAAAnw/RGgDEwgbfyA/s1600-h/nonparametric+segment.bmp"&gt;&lt;img style="cursor: pointer; width: 400px; height: 362px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnkV-Xh_qDI/AAAAAAAAAnw/RGgDEwgbfyA/s400/nonparametric+segment.bmp" alt="" id="BLOGGER_PHOTO_ID_5366344592201328690" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be observed that the image is not that well segmented compared to the parametric approach since majority of the blue ball particularly at the bottom part where its brightness is minimal is not extracted. The good thing about non-parametric segmentation is that no function is needed, instead, just the histogram of a monochromatic patch from the ROI is required. Therefore, for this case, a Gaussian function works great as basis of probability distribution for image segmentation.&lt;br /&gt;&lt;br /&gt;Since I have successfully done and understand parametric and non-parametric segmentation of a colored image, I give myself 10/10 in this activity.&lt;br /&gt;&lt;br /&gt;Throughout the activity, I have worked independently in its completion. However, I shared useful ideas that have helped my classmates.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;Below is the whole &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code utilized in this Activity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;stacksize(4e7);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;image = imread('big_blue_ball.jpg');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;I = imread('ROI.jpg');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;R = I(:,:,1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;G = I(:,:,2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;B = I(:,:,3);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;RGB = R + G + B;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;r = R./RGB;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;b = B./RGB;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;g = G./RGB;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Ri = image(:,:,1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Gi = image(:,:,2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Bi = image(:,:,3);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;RGBi = Ri + Gi + Bi;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;ri = Ri./RGBi;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;bi = Bi./RGBi;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;gi = Gi./RGBi;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Parametric Segmentation&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rmean = mean(r);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;gmean = mean(g);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rsigma = stdev(r);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;gsigma = stdev(g);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rp = (1/(rsigma*sqrt(2*%pi)))*exp(-((ri - rmean).^2)/(2*rsigma^2));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;gp = (1/(gsigma*sqrt(2*%pi)))*exp(-((gi - gmean).^2)/(2*gsigma^2));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rgp = round(rp.*gp);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(rgp);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(rgp, 'parametric segment.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Non-parametric Segmentation&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// 2D Histogram Plot&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;BINS = 256;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rint = round(r*(BINS - 1) + 1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;gint = round(g*(BINS - 1) + 1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;colors = gint(:) + (rint(:) - 1)*BINS;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;hist = zeros(BINS, BINS);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for row = 1:BINS&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for col = 1:(BINS - row + 1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;hist(row, col) = length(find(colors == (((col + (row - 1)*BINS)))));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;histo = hist/max(hist);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//mesh(histo);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Backprojection&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rib = ri*255;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;gib = gi*255;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[a, b] = size(image);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;segment = zeros(a, b);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 1:a&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for j = 1:b&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;c = round(rib(i, j)) + 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;d = round(gib(i, j)) + 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;segment(i, j) = hist(c, d);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(segment);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(segment, 'nonparametric segment.bmp');&lt;/span&gt;&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/1657424262821979330-482233832786897184?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/482233832786897184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/08/activity-12-color-image-segmentation.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/482233832786897184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/482233832786897184'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/08/activity-12-color-image-segmentation.html' title='Activity 12 - Color Image Segmentation'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_kx7Z922tJd0/SnkVxJjRl2I/AAAAAAAAAnI/X0Au1zR8iIo/s72-c/big_blue_ball.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-5225526411638489868</id><published>2009-07-30T09:33:00.053+08:00</published><updated>2009-08-07T21:38:24.451+08:00</updated><title type='text'>Activity 11 - Color Image Processing</title><content type='html'>&lt;div style="text-align: justify;"&gt;After previous activities of processing grayscale and binary-type images, this time, color images are handled here specifically true color images which are taken by a digital color camera using its various white balancing (WB) settings.&lt;br /&gt;&lt;br /&gt;In a colored digital image, each pixel from it is composed of the three primary spectral colors Red (R), Green (G), and Blue (B) which are overlaid in different proportions. These RGB values are given by the following equations.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SnOZnDpt27I/AAAAAAAAAio/lgqIEe7EDyU/s1600-h/eqR.jpg"&gt;&lt;img style="cursor: pointer; width: 149px; height: 26px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SnOZnDpt27I/AAAAAAAAAio/lgqIEe7EDyU/s400/eqR.jpg" alt="" id="BLOGGER_PHOTO_ID_5364800477402618802" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnOZnbi5UJI/AAAAAAAAAiw/5uxYeuvXAI0/s1600-h/eqG.jpg"&gt;&lt;img style="cursor: pointer; width: 152px; height: 26px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnOZnbi5UJI/AAAAAAAAAiw/5uxYeuvXAI0/s400/eqG.jpg" alt="" id="BLOGGER_PHOTO_ID_5364800483816460434" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SnOZnwg878I/AAAAAAAAAi4/pZTwgL2LZcM/s1600-h/eqB.jpg"&gt;&lt;img style="cursor: pointer; width: 149px; height: 26px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SnOZnwg878I/AAAAAAAAAi4/pZTwgL2LZcM/s400/eqB.jpg" alt="" id="BLOGGER_PHOTO_ID_5364800489445453762" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnOZn22f7BI/AAAAAAAAAjA/Qo-b1cPrW_w/s1600-h/eqK.jpg"&gt;&lt;img style="cursor: pointer; width: 193px; height: 46px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnOZn22f7BI/AAAAAAAAAjA/Qo-b1cPrW_w/s400/eqK.jpg" alt="" id="BLOGGER_PHOTO_ID_5364800491146439698" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;From the expressions above, &lt;span style="font-style: italic;"&gt;rho&lt;/span&gt; corresponds to the spectral reflectance of a surface, &lt;span style="font-style: italic;"&gt;S&lt;/span&gt; is the spectral power distribution (SPD) of a Planckian light source illuminating the surface and &lt;span style="font-style: italic;"&gt;nu&lt;/span&gt; is the spectral sensitivity of a color camera in the RGB channels. Meanwhile, &lt;span style="font-style: italic;"&gt;K&lt;/span&gt; is the normalizing constant or WB constant dependent from the SPD of the light source and spectral sensitivity of the camera, again different in each color channel. The wavelength &lt;span style="font-style: italic;"&gt;lambda&lt;/span&gt; ranges within the visible spectrum usually from 380 nm to 780 nm.&lt;br /&gt;&lt;br /&gt;Initially, an image which includes the three major hues RGB and a known white object is taken by a digital color camera applying its different WB settings. The digital camera used is &lt;span style="font-style: italic;"&gt;Fujifilm Finepix&lt;/span&gt; with maximum image resolution of 6.3 mega pixels while the WB settings include automatic, fine, shade, fluorescent 1, fluorescent 2, fluorescent 3, and incandescent. The exposure value (EV) of the camera is set to -2 ensuring that the RGB values of each pixel do not exceed the maximum pixel value of 1.&lt;br /&gt;The following set of images are the pictures taken under constant fluorescent light source illumination implementing the 7 WB settings in order of automatic, fine, shade, fluorescent 1, fluorescent 2, fluorescent 3, and incandescent from top to bottom and left to right.&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/_kx7Z922tJd0/SnOWdI7YJHI/AAAAAAAAAig/UusHXeMNnWU/s1600-h/imageRGBauto.JPG"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnOWdI7YJHI/AAAAAAAAAig/UusHXeMNnWU/s400/imageRGBauto.JPG" alt="" id="BLOGGER_PHOTO_ID_5364797008485295218" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnOnCqO0gBI/AAAAAAAAAjw/RaILmIuneGc/s1600-h/imageRGBfine.JPG"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnOnCqO0gBI/AAAAAAAAAjw/RaILmIuneGc/s400/imageRGBfine.JPG" alt="" id="BLOGGER_PHOTO_ID_5364815245266419730" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SnOnC8FJ5PI/AAAAAAAAAj4/2IWd6aYcCUw/s1600-h/imageRGBshade.JPG"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnOnC8FJ5PI/AAAAAAAAAj4/2IWd6aYcCUw/s400/imageRGBshade.JPG" alt="" id="BLOGGER_PHOTO_ID_5364815250057716978" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnOnDAwCpAI/AAAAAAAAAkA/p1EoJ2Pj3Gw/s1600-h/imageRGBfluo1.JPG"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnOnDAwCpAI/AAAAAAAAAkA/p1EoJ2Pj3Gw/s400/imageRGBfluo1.JPG" alt="" id="BLOGGER_PHOTO_ID_5364815251311338498" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SnOnDatKRaI/AAAAAAAAAkI/bt85PDTZOlA/s1600-h/imageRGBfluo2.JPG"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SnOnDatKRaI/AAAAAAAAAkI/bt85PDTZOlA/s400/imageRGBfluo2.JPG" alt="" id="BLOGGER_PHOTO_ID_5364815258278577570" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnOnDn3wY8I/AAAAAAAAAkQ/psunkW1679U/s1600-h/imageRGBfluo3.JPG"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnOnDn3wY8I/AAAAAAAAAkQ/psunkW1679U/s400/imageRGBfluo3.JPG" alt="" id="BLOGGER_PHOTO_ID_5364815261812679618" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SnOnoamvNjI/AAAAAAAAAkg/O1b3d3-uwJE/s1600-h/imageRGBincan.JPG"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnOnoamvNjI/AAAAAAAAAkg/O1b3d3-uwJE/s400/imageRGBincan.JPG" alt="" id="BLOGGER_PHOTO_ID_5364815893906798130" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;As expected, each WB setting of the camera results to different color rendering of the picture. Hence, the normalizing constant &lt;span style="font-style: italic;"&gt;K&lt;/span&gt; varies with each WB setting of the camera and thus producing different RGB values in pixels. Of course, the automatic WB setting generates the best rendering of the picture since it automatically selects the most appropriate &lt;span style="font-style: italic;"&gt;K&lt;/span&gt; values which adjust according to the light source illumination. The fine and shade WB settings are considerably good enough for the rendering while the three fluorescent WB settings approach the blue hue as the number increases from 1 to 3.&lt;br /&gt;The last one which uses incandescent WB is observed to be the most obvious incorrectly balanced image. This is then enhanced using two automatic white balancing (AWB) algorithms.&lt;br /&gt;&lt;br /&gt;The first one is the White Patch Algorithm where a patch from a known white object of the unbalanced image is taken and its averaged RGB values are determined. This is why the picture must have a known white object. Then, the RGB color channels of the unbalanced image are divided to the corresponding averaged RGB values of the white patch. The resulting RGB arrays are finally overlaid for the white patch balanced rendering of the wrongly balanced image. Note that the final RGB arrays in saving the rendered image are made sure not to exceed the value of 1 by dividing them to their maximum value even though initially there are no RGB values greater than 1 because of the EV of -2. This is because some RGB values less than 1 are divided to the averaged RGB values from the white patch which are less than them. Therefore, not doing this makes the rendering still incorrectly white balanced.&lt;br /&gt;Shown below is the white patch selected from the picture taken with incandescent WB setting.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SnPGoFjNYZI/AAAAAAAAAlQ/XkR3Ten0iE8/s1600-h/white+patch+RGBincan.JPG"&gt;&lt;img style="cursor: pointer; width: 57px; height: 45px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SnPGoFjNYZI/AAAAAAAAAlQ/XkR3Ten0iE8/s400/white+patch+RGBincan.JPG" alt="" id="BLOGGER_PHOTO_ID_5364849973115314578" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Then the following are the original picture and its rendering using the White Patch Algorithm.&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/_kx7Z922tJd0/SnOnoamvNjI/AAAAAAAAAkg/O1b3d3-uwJE/s1600-h/imageRGBincan.JPG"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnOnoamvNjI/AAAAAAAAAkg/O1b3d3-uwJE/s400/imageRGBincan.JPG" alt="" id="BLOGGER_PHOTO_ID_5364815893906798130" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnO6LPQq-sI/AAAAAAAAAkw/Fuvq8noTbkY/s1600-h/newimageRGBincan.jpg"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnO6LPQq-sI/AAAAAAAAAkw/Fuvq8noTbkY/s400/newimageRGBincan.jpg" alt="" id="BLOGGER_PHOTO_ID_5364836283366177474" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The incorrectly balanced image using the incandescent WB setting is now appropriately white balanced using the White Patch Algorithm. The quality is as good as in using the automatic WB setting of the camera.&lt;br /&gt;&lt;br /&gt;The second AWB algorithm is called the Gray World Algorithm. Here, the average pixel values of each RGB color channel are obtained. The RGB arrays of the unbalanced image are then divided to the corresponding average RGB values. Hence, this algorithm works even the picture does not have a known white object. Again, in saving the rendered image, the values are clipped to 1 like in the White Patch Algorithm.&lt;br /&gt;The original picture taken with incandescent WB setting and its rendering using the Gray World Algorithm are as follows.&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/_kx7Z922tJd0/SnOnoamvNjI/AAAAAAAAAkg/O1b3d3-uwJE/s1600-h/imageRGBincan.JPG"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnOnoamvNjI/AAAAAAAAAkg/O1b3d3-uwJE/s400/imageRGBincan.JPG" alt="" id="BLOGGER_PHOTO_ID_5364815893906798130" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnPBMGWuw7I/AAAAAAAAAk4/54iwOrH7pcg/s1600-h/newimagegrayRGBincan.jpg"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnPBMGWuw7I/AAAAAAAAAk4/54iwOrH7pcg/s400/newimagegrayRGBincan.jpg" alt="" id="BLOGGER_PHOTO_ID_5364843994736935858" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The name of the Gray World Algorithm itself implies the effect when applied to an image. The average values taken from each color channel here represent the RGB values of white however these are already weighted. Hence, when the RGB arrays are divided by these average values, gray which is between white and black becomes the basis of balancing, and thus the image enters the gray world.&lt;br /&gt;&lt;br /&gt;As another illustration of the two AWB algortihms, the picture taken with fluorescent 3 WB setting is rendered using these algorithms. First below is the white patch chosen.&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/_kx7Z922tJd0/SnPJNgGGMcI/AAAAAAAAAlY/1kuD8C4AXjg/s1600-h/white+patch+RGBfluo3.JPG"&gt;&lt;img style="cursor: pointer; width: 42px; height: 32px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnPJNgGGMcI/AAAAAAAAAlY/1kuD8C4AXjg/s400/white+patch+RGBfluo3.JPG" alt="" id="BLOGGER_PHOTO_ID_5364852814919381442" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The next set of images consists the original picture, its rendering using the White Patch Algorithm, and using the Gray World Algorithm.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnOnDn3wY8I/AAAAAAAAAkQ/psunkW1679U/s1600-h/imageRGBfluo3.JPG"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnOnDn3wY8I/AAAAAAAAAkQ/psunkW1679U/s400/imageRGBfluo3.JPG" alt="" id="BLOGGER_PHOTO_ID_5364815261812679618" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnPFeN8iwHI/AAAAAAAAAlA/4VagZi_Niw0/s1600-h/newimageRGBfluo3.jpg"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnPFeN8iwHI/AAAAAAAAAlA/4VagZi_Niw0/s400/newimageRGBfluo3.jpg" alt="" id="BLOGGER_PHOTO_ID_5364848704058736754" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SnPFeS9HfCI/AAAAAAAAAlI/Wc0LRmUKXTI/s1600-h/newimagegrayRGBfluo3.jpg"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnPFeS9HfCI/AAAAAAAAAlI/Wc0LRmUKXTI/s400/newimagegrayRGBfluo3.jpg" alt="" id="BLOGGER_PHOTO_ID_5364848705403321378" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be observed that the rendered picture taken with fluorescent 3 WB setting using the White Patch Algorithm is almost the same as in the rendered picture taken with the incandescent WB setting. However, the rendering using the Gray World Algorithm in this WB setting is better than in the incandescent type.&lt;br /&gt;&lt;br /&gt;For a more conclusive observation, a picture is taken again but this time the objects have colors belonging to a primary hue. Incandescent WB setting is employed here since this is the most inappropriate WB setting for the illumination condition. Some red objects are gathered together and of course a known white object is included in the group.&lt;br /&gt;The white patch selected is shown below.&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/_kx7Z922tJd0/SnPNwe830hI/AAAAAAAAAlg/vVG4fnktEqU/s1600-h/white+patch+Rincan.JPG"&gt;&lt;img style="cursor: pointer; width: 42px; height: 40px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnPNwe830hI/AAAAAAAAAlg/vVG4fnktEqU/s400/white+patch+Rincan.JPG" alt="" id="BLOGGER_PHOTO_ID_5364857813954187794" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The following are the original picture, its rendering using the White Patch Algorithm, and using the Gray World Algorithm.&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/_kx7Z922tJd0/SnPNwoEh0yI/AAAAAAAAAlo/VTcAChVbX6M/s1600-h/imageRincan.JPG"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SnPNwoEh0yI/AAAAAAAAAlo/VTcAChVbX6M/s400/imageRincan.JPG" alt="" id="BLOGGER_PHOTO_ID_5364857816402219810" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SnPNwyYu9gI/AAAAAAAAAlw/KrRAosgzAxs/s1600-h/newimageRincan.jpg"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SnPNwyYu9gI/AAAAAAAAAlw/KrRAosgzAxs/s400/newimageRincan.jpg" alt="" id="BLOGGER_PHOTO_ID_5364857819171321346" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SnPNxKI70EI/AAAAAAAAAl4/ZWT7KsVc7Uc/s1600-h/newimagegrayRincan.jpg"&gt;&lt;img style="cursor: pointer; width: 310px; height: 232px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SnPNxKI70EI/AAAAAAAAAl4/ZWT7KsVc7Uc/s400/newimagegrayRincan.jpg" alt="" id="BLOGGER_PHOTO_ID_5364857825547505730" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Apparently, the White Patch Algortihm is better than the Gray World Algorithm. This is due to the fact that the picture is indeed white balanced since the average RGB values where the RGB color channels are normalized, come from a known white object. While the Gray World Algorithm just uses the average RGB values of each color channel of the unbalanced image in effect just balancing it to gray. However, the Gray World Algorithm generates good rendering if the WB setting used to take the picture blends well with the illumination condition.&lt;br /&gt;&lt;br /&gt;Since I successfully processed some true color images taken with different WB settings of a digital color camera using the two AWB algorithms , I give myself 10/10 in this activity.&lt;br /&gt;&lt;br /&gt;I am able to complete this activity successfully through discussions with Gary and Raffy.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;Below is the Scilab code utilized in this activity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;stacksize(4e7);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;imageRGB = imread('imageRGBincan.jpg');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(imageRGB);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;R = imageRGB(:,:,1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;G = imageRGB(:,:,2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;B = imageRGB(:,:,3);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// White Patch Algorithm&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;white_patch = imread('white patch RGBincan.jpg');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Rw = sum(white_patch(:,:,1))/length(white_patch(:,:,1));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Gw = sum(white_patch(:,:,2))/length(white_patch(:,:,2));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Bw = sum(white_patch(:,:,3))/length(white_patch(:,:,3));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;nR = R/Rw;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;nG = G/Gw;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;nB = B/Bw;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;newimageRGB = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;newimageRGB(:,:,1) = nR;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;newimageRGB(:,:,2) = nG;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;newimageRGB(:,:,3) = nB;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(newimageRGB);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(newimageRGB/max(newimageRGB), 'newimageRGBincan.jpg');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Gray World Algorithm&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Rgray = sum(R)/length(R);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Ggray = sum(G)/length(G);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Bgray = sum(B)/length(B);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;ngrayR = R/Rgray;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;ngrayG = G/Rgray;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;ngrayB = B/Rgray;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;newimagegrayRGB = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;newimagegrayRGB(:,:,1) = ngrayR;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;newimagegrayRGB(:,:,2) = ngrayG;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;newimagegrayRGB(:,:,3) = ngrayB;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(newimagegrayRGB);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(newimagegrayRGB/max(newimagegrayRGB), 'newimagegrayRGBincan.jpg');&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1657424262821979330-5225526411638489868?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/5225526411638489868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-11-color-image-processing.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/5225526411638489868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/5225526411638489868'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-11-color-image-processing.html' title='Activity 11 - Color Image Processing'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_kx7Z922tJd0/SnOZnDpt27I/AAAAAAAAAio/lgqIEe7EDyU/s72-c/eqR.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-6679649480511881942</id><published>2009-07-28T09:46:00.021+08:00</published><updated>2009-07-29T21:52:49.954+08:00</updated><title type='text'>Activity 10 - Preprocessing Text</title><content type='html'>&lt;div style="text-align: justify;"&gt;Another activity applying various image processing techniques is done here. This is divided into two major parts. First, a handwritten text from a scanned image is preprocessed. In the second part, incidences of a typewritten word are found in the same scanned image.&lt;br /&gt;&lt;br /&gt;The image of a scanned demo checklist form is initially downloaded given by the activity. This is shown below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAhdRNgrTI/AAAAAAAAAfo/W92yKl16kZw/s1600-h/Untitled_0001.jpg"&gt;&lt;img style="cursor: pointer; width: 256px; height: 320px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAhdRNgrTI/AAAAAAAAAfo/W92yKl16kZw/s320/Untitled_0001.jpg" alt="" id="BLOGGER_PHOTO_ID_5363823942918253874" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;A portion of handwritten text along the horizontal lines is then cropped from this image. Since the text image is tilted, its Fourier transform (FT) is determined in order to obtain the angle of rotation. Either way, this angle can just be set through trial and error. In this case, the text image is rotated by 1 degree in the clockwise direction using the function &lt;span style="font-style: italic;"&gt;mogrify&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt;. The following are the cropped text image and its rotation in grayscale.&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/_kx7Z922tJd0/SnAhdvFJukI/AAAAAAAAAfw/xKOc1SGRRYo/s1600-h/htext.bmp"&gt;&lt;img style="cursor: pointer; width: 180px; height: 121px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnAhdvFJukI/AAAAAAAAAfw/xKOc1SGRRYo/s320/htext.bmp" alt="" id="BLOGGER_PHOTO_ID_5363823950936259138" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SnAhd0Jj2DI/AAAAAAAAAf4/ZpFEl6_viqc/s1600-h/htextrot.bmp"&gt;&lt;img style="cursor: pointer; width: 180px; height: 120px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SnAhd0Jj2DI/AAAAAAAAAf4/ZpFEl6_viqc/s320/htextrot.bmp" alt="" id="BLOGGER_PHOTO_ID_5363823952296925234" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The text image arranged from top reads: VGA Cable, Power Cord, Remote Control, RCA Cable, USB Cable. The primary reason of rotation is for the ease enhancement of the text image since the horizontal lines must be eliminated and hence a filter that removes this pattern can easily be created. Next, the FT of the rotated text image is attained and this serves as the template for making the filter. Henceforth, frequencies of unwanted pattern can be blocked here. The FT of the rotated text image and the filter created are shown as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAhee-8VaI/AAAAAAAAAgA/9DgLK2uySzQ/s1600-h/Fhtextrot.bmp"&gt;&lt;img style="cursor: pointer; width: 180px; height: 122px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAhee-8VaI/AAAAAAAAAgA/9DgLK2uySzQ/s320/Fhtextrot.bmp" alt="" id="BLOGGER_PHOTO_ID_5363823963795117474" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAhesCjS-I/AAAAAAAAAgI/b1BzxJsNsTY/s1600-h/filterhtextrot.bmp"&gt;&lt;img style="cursor: pointer; width: 180px; height: 122px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAhesCjS-I/AAAAAAAAAgI/b1BzxJsNsTY/s320/filterhtextrot.bmp" alt="" id="BLOGGER_PHOTO_ID_5363823967299914722" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Since the horizontal lines are to be diminished, the central vertical line frequencies must be blocked. However, its center must not be obstructed because it contains the primary information of the rotated text image.&lt;br /&gt;Below is the filtered rotated text image.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAiYi6rntI/AAAAAAAAAgQ/amOsjwLcxSg/s1600-h/filteredhtextrot.bmp"&gt;&lt;img style="cursor: pointer; width: 180px; height: 122px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAiYi6rntI/AAAAAAAAAgQ/amOsjwLcxSg/s320/filteredhtextrot.bmp" alt="" id="BLOGGER_PHOTO_ID_5363824961283399378" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The text can now be extracted from the background after filtering. From the histogram plot of the grayscale values of the filtered rotated text image using &lt;span style="font-style: italic;"&gt;GIMP&lt;/span&gt;, the threshold value for its conversion to binary type is obtained. The following are the binarized filtered rotated text image and its inversion.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SnAiY-L5sbI/AAAAAAAAAgY/rcap2BpBGP0/s1600-h/bintext.bmp"&gt;&lt;img style="cursor: pointer; width: 180px; height: 122px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SnAiY-L5sbI/AAAAAAAAAgY/rcap2BpBGP0/s320/bintext.bmp" alt="" id="BLOGGER_PHOTO_ID_5363824968603382194" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SnAiZWstDjI/AAAAAAAAAgg/4qe09dGoNSI/s1600-h/invbintext.bmp"&gt;&lt;img style="cursor: pointer; width: 180px; height: 122px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SnAiZWstDjI/AAAAAAAAAgg/4qe09dGoNSI/s320/invbintext.bmp" alt="" id="BLOGGER_PHOTO_ID_5363824975183416882" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The threshold value used for binarizing is 0.275. The inversion of the binarized filtered rotated text image is essential since the final step in preprocessing the text is the utilization of image morphological operations. During these operations, the region of interest, which is the text, must be the foreground with pixel value 1 while the background must be 0. Notice that some traces of the horizontal lines reside in the inverted binarized filtered rotated text image. Therefore, a closing operation is needed for these to be removed. Recall that this morphological operation is equivalent to the dilation of the eroded image by a structuring element to that same structuring element. Its implementation to the inverted filtered rotated text image is applied with a 3 x 1 sized matrix of ones as the structuring element. Its effect is shown below.&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/_kx7Z922tJd0/SnAiaLnHQ4I/AAAAAAAAAgo/s9N8cRf-5Ks/s1600-h/morphtext.bmp"&gt;&lt;img style="cursor: pointer; width: 180px; height: 122px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnAiaLnHQ4I/AAAAAAAAAgo/s9N8cRf-5Ks/s320/morphtext.bmp" alt="" id="BLOGGER_PHOTO_ID_5363824989387047810" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The image above is now the preprocessed handwritten text from the scanned image of a demo checklist form. It can be noticed that the remnants of horizontal lines are eliminated through the closing operation. This is because the structuring element is enough to reconnect two clusters along the vertical direction. Hence, increasing the number of rows in the matrix of the structuring element makes the letters that are few pixels adjacent vertically to each other cluster and this is not good for preprocessing the text.&lt;br /&gt;For further analysis of the preprocessed text, the built-in function &lt;span style="font-style: italic;"&gt;bwlabel&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; is again used here for labeling the clusters which are the letters reconstructed. There are 54 clusters detected and originally there are only 46 letters in the text image. This result is fair good enough because in the first place, some handwritten letters in the original text image are not distinctive. Some also coincide with adjacent letters and are not written in the same magnitude.&lt;br /&gt;&lt;br /&gt;The incidences of the word DESCRIPTION from the same scanned image of a demo checklist form are found in the second part of this activity by correlation.&lt;br /&gt;This time the whole image is needed since it is required to locate all incidences of the word from the scanned image. Now, this is rotated so that a sample image of the word can easily be extracted that is to be used in correlation. The original scanned image and its rotation in grayscale are as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAhdRNgrTI/AAAAAAAAAfo/W92yKl16kZw/s1600-h/Untitled_0001.jpg"&gt;&lt;img style="cursor: pointer; width: 256px; height: 320px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAhdRNgrTI/AAAAAAAAAfo/W92yKl16kZw/s320/Untitled_0001.jpg" alt="" id="BLOGGER_PHOTO_ID_5363823942918253874" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAiaZFkMGI/AAAAAAAAAgw/mlqwwd28VAk/s1600-h/checklistrot.bmp"&gt;&lt;img style="cursor: pointer; width: 258px; height: 320px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAiaZFkMGI/AAAAAAAAAgw/mlqwwd28VAk/s320/checklistrot.bmp" alt="" id="BLOGGER_PHOTO_ID_5363824993004433506" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Again, the whole image is rotated by 1 degree in the clockwise direction using the function &lt;span style="font-style: italic;"&gt;mogrify&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; like the text image in the first part. Then, the rotated image is binarized base to the threshold value from the histogram of its grayscale values obtained using &lt;span style="font-style: italic;"&gt;GIMP&lt;/span&gt;. This is illustrated below.&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/_kx7Z922tJd0/SnAjXjgNcsI/AAAAAAAAAg4/3Y4a2hC_pIg/s1600-h/binchecklist.bmp"&gt;&lt;img style="cursor: pointer; width: 258px; height: 320px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnAjXjgNcsI/AAAAAAAAAg4/3Y4a2hC_pIg/s320/binchecklist.bmp" alt="" id="BLOGGER_PHOTO_ID_5363826043772564162" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The threshold value employed in binarizing the rotated image is 0.49.&lt;br /&gt;Due to the fact that it is customary in a binary image where the region of interest must be white value and the background to be black, then the binarized rotated image is inverted. Shown in the following are the inverted binarized rotated image and the sample image of the word DESCRIPTION extracted from it.&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/_kx7Z922tJd0/SnAjYLD3PVI/AAAAAAAAAhA/ubsgoBqPV_I/s1600-h/invbinchecklist.bmp"&gt;&lt;img style="cursor: pointer; width: 258px; height: 320px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnAjYLD3PVI/AAAAAAAAAhA/ubsgoBqPV_I/s320/invbinchecklist.bmp" alt="" id="BLOGGER_PHOTO_ID_5363826054391086418" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAjY5bufYI/AAAAAAAAAhI/3cjM-3Tpxh8/s1600-h/description.bmp"&gt;&lt;img style="cursor: pointer; width: 258px; height: 320px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnAjY5bufYI/AAAAAAAAAhI/3cjM-3Tpxh8/s320/description.bmp" alt="" id="BLOGGER_PHOTO_ID_5363826066839207298" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In getting a sample image of the word DESCRIPTION from the inverted binarized rotated image, it is important that it is placed in an image with black background and this sample image must have the same size as the inverted binarized rotated image because correlation occurs at the frequency domain of their FTs.&lt;br /&gt;Recall that correlation works here when the FT of the sample image is multiplied element-by-element to the conjugate of the FT of the inverted binarized rotated image. Then, the modulus of the shifted inverse FT of their product displays the correlated image. Now, the following is the result of correlation of the sample image of the word DESCRIPTION to the inverted binarized rotated image.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SnAjZUc1LSI/AAAAAAAAAhQ/1Q8Pu-3P6Xg/s1600-h/correlated+text.bmp"&gt;&lt;img style="cursor: pointer; width: 258px; height: 320px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SnAjZUc1LSI/AAAAAAAAAhQ/1Q8Pu-3P6Xg/s320/correlated+text.bmp" alt="" id="BLOGGER_PHOTO_ID_5363826074091597090" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Apparently from the correlated image above, there are three incidences of the word DESCRIPTION in the inverted binarized rotated image which indeed agrees comparing from the scanned image of a demo checklist form. The incidences are marked by the bright spots as observed in the correlated image. One is found at the upper left and two are located below it and are arranged in a same line horizontally.&lt;br /&gt;&lt;br /&gt;Although the preprocessing of a handwritten text in the first part is not perfectly done, I have applied various techniques of image processing successfully in this part also with the correlation of the word DESCRIPTION to the scanned image in the second part, hence I grade myself 10/10 in this activity.&lt;br /&gt;&lt;br /&gt;This activity is successfully completed through my collaboration with Gary and Ed.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;The following is the source code for this activity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;stacksize(4e7);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Preprocessing Handwritten Text&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;text = gray_imread('htext.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(text);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;textrot = mogrify(text, ['-rotate', '1']);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(textrot);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(textrot, 'htextrot.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Ftext = log(abs(fftshift(fft2(textrot))));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(Ftext, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(Ftext/max(Ftext), 'Fhtextrot.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;filter = gray_imread('filterhtextrot.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;filtext = abs(ifft(fftshift(filter).*fft2(textrot)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//invfiltext = max(filtext) - filtext;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(filtext, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(filtext/max(filtext), 'filteredhtextrot.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;bintext = im2bw(filtext, 0.275);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(bintext, 'bintext.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;invbintext = 1 - bintext;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(4);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(invbintext);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(invbintext, 'invbintext.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;SE = ones(3, 1);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;morphtext = dilate(invbintext, SE);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;morphtext = erode(morphtext, SE);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(5);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(morphtext);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(morphtext, 'morphtext.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[L, n] = bwlabel(morphtext);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Typewritten Text Correlation&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;checklist = gray_imread('Untitled_0001.jpg');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;checklistrot = mogrify(checklist, ['-rotate', '1']);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(6);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(checklistrot);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(checklistrot, 'checklistrot.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;binchecklist = im2bw(checklistrot, 0.49);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(7);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(binchecklist);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(binchecklist, 'binchecklist.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;invbinchecklist = 1 - binchecklist;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(8);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(invbinchecklist);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(invbinchecklist, 'invbinchecklist.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;description = imread('description.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;cor = abs(fftshift(fft2(fft2(description).*(conj(fft2(invbinchecklist))))));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(9);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(cor, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(cor/max(cor), 'correlated text.bmp');&lt;/span&gt;&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/1657424262821979330-6679649480511881942?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/6679649480511881942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-10-preprocessing-text.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/6679649480511881942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/6679649480511881942'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-10-preprocessing-text.html' title='Activity 10 - Preprocessing Text'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_kx7Z922tJd0/SnAhdRNgrTI/AAAAAAAAAfo/W92yKl16kZw/s72-c/Untitled_0001.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-6295963054195392094</id><published>2009-07-23T10:00:00.034+08:00</published><updated>2009-08-07T21:34:03.883+08:00</updated><title type='text'>Activity 9 - Binary Operations</title><content type='html'>This activity requires to give the best estimate of the area of a circular punched paper which is called here as cell. Some techniques of image processing that have been worked on in the past activities are employed here in order to calculate the area of this cell.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;First, a scanned image of scattered punched papers is selected from the two images given by the activity. This is shown below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Sm1x4iPCyOI/AAAAAAAAAeY/zL_hJp9cc4E/s1600-h/Circles001.jpg"&gt;&lt;img style="cursor: pointer; width: 320px; height: 264px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Sm1x4iPCyOI/AAAAAAAAAeY/zL_hJp9cc4E/s320/Circles001.jpg" alt="" id="BLOGGER_PHOTO_ID_5363067947344644322" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The image above has size 748 x 618 and it is subdivided into 9 subimages each of which has size 256 x 256 pixels. Thus, some subimages overlap with the other which is better since it results to more area to be calculated and thus the result to be more accurate. &lt;span style="font-style: italic;"&gt;Paint&lt;/span&gt; is used in cropping the scanned image.&lt;br /&gt;A representative subimage that is the parcel labeled &lt;span style="font-style: italic;"&gt;'circles_2'&lt;/span&gt; located at the middle of the one-third topmost part of the whole original image is illustrated as follows.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SnGSHcizujI/AAAAAAAAAiA/e3Q_C3n-wps/s1600-h/circles_2.JPG"&gt;&lt;img style="cursor: pointer; width: 256px; height: 256px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SnGSHcizujI/AAAAAAAAAiA/e3Q_C3n-wps/s400/circles_2.JPG" alt="" id="BLOGGER_PHOTO_ID_5364229287793900082" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The histogram of the grayscale values of each subimage is then analyzed using &lt;span style="font-style: italic;"&gt;GIMP&lt;/span&gt;. This is where the threshold value is determined for the binarizing of the 9 subimages, that is, they only possess two values which are 0 for black corresponding to the background and 1 for white corresponding to the foreground or called the Region of Interest (ROI).&lt;br /&gt;A threshold value of 0.85 is used in making the 9 subimages be of Binary-type. The binarized subimage &lt;span style="font-style: italic;"&gt;'circles_2'&lt;/span&gt; is the following.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SnGSG18UKFI/AAAAAAAAAho/1i2Y_4Rgdx4/s1600-h/binarysubimage2.bmp"&gt;&lt;img style="cursor: pointer; width: 256px; height: 256px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SnGSG18UKFI/AAAAAAAAAho/1i2Y_4Rgdx4/s400/binarysubimage2.bmp" alt="" id="BLOGGER_PHOTO_ID_5364229277431900242" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Notice that binarizing alone is not enough to get the ROI for area calculation. Thus some image morphological operations are utilized in order to remove unnecessary noise and hence to connect overlapping cells which are coined blobs.&lt;br /&gt;Closing and opening operators are then implemented here. The closing operator is defined to be the erosion of the dilated image A by a structuring element (SE) B to that same SE B. Meanwhile, the opening operator is equivalent to the dilation of the eroded image A by a SE B to that same SE B. Therefore, a series of dilation, erosion, erosion, and dilation operation is applied to each subimage for its further enhancement.&lt;br /&gt;The SE used takes the form of a small circle as the matrix below.&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/_kx7Z922tJd0/SnGSHJ8pcWI/AAAAAAAAAh4/kKS-x9NgqMQ/s1600-h/structuring+element.jpg"&gt;&lt;img style="cursor: pointer; width: 61px; height: 64px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SnGSHJ8pcWI/AAAAAAAAAh4/kKS-x9NgqMQ/s400/structuring+element.jpg" alt="" id="BLOGGER_PHOTO_ID_5364229282802004322" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The effect to the representative binarized subimage &lt;span style="font-style: italic;"&gt;'circles_2'&lt;/span&gt; after applying the closing and opening operations is shown as follows.&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/_kx7Z922tJd0/SnGSHCQipEI/AAAAAAAAAhw/czEk-7-IwBc/s1600-h/newbinarysubimage2.bmp"&gt;&lt;img style="cursor: pointer; width: 256px; height: 256px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnGSHCQipEI/AAAAAAAAAhw/czEk-7-IwBc/s400/newbinarysubimage2.bmp" alt="" id="BLOGGER_PHOTO_ID_5364229280737961026" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;It can be observed that noise are eliminated, blobs are created due to the overlapping of some cells and in the same time single-cell units are more defined.&lt;br /&gt;After applying the methods presented above to all the subimages, the blobs and the single-cell units are then isolated and labeled in preparation for area calculation using the built-in function in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; namely &lt;span style="font-style: italic;"&gt;bwlabel&lt;/span&gt;. Thus, the area, which is the total number of white pixels, of blobs and single-cell units to all subimages are independently determined and gathered.&lt;br /&gt;&lt;br /&gt;Now, the histogram of the calculated areas is shown below.&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/_kx7Z922tJd0/SnGSHs0gOAI/AAAAAAAAAiI/QFblB15b4Ro/s1600-h/histogram.bmp"&gt;&lt;img style="cursor: pointer; width: 400px; height: 302px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SnGSHs0gOAI/AAAAAAAAAiI/QFblB15b4Ro/s400/histogram.bmp" alt="" id="BLOGGER_PHOTO_ID_5364229292163086338" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The occurrence of the area of a single-cell unit is found to be between 500 and 550 square pixels. Of course, the blobs and other cells that are not fully reconstructed give very large and very small areas respectively. Hence, these are eliminated in the process of determining the mean area and the standard deviation of the distribution.&lt;br /&gt;&lt;br /&gt;The calculated mean area of the cell is 519.79 square pixels. This is derived from the sum of the elements within the interval of 500 to 550 square pixels divided by the number of elements in this range. Using the built-in function &lt;span style="font-style: italic;"&gt;stdev&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt;, the standard deviation attained is 12.12.&lt;br /&gt;&lt;br /&gt;For validity of the result, the mean area is compared to the area of a single-cell unit which is not overlapping to other cell(s) and this is cropped from a subimage. This is also binarized but the closing and opening operations are not already implemented. The following images represent the basis of comparison to the calculated mean area.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SnGSixSYCFI/AAAAAAAAAiQ/bXj1rDTybmU/s1600-h/gray1circle.bmp"&gt;&lt;img style="cursor: pointer; width: 43px; height: 37px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SnGSixSYCFI/AAAAAAAAAiQ/bXj1rDTybmU/s400/gray1circle.bmp" alt="" id="BLOGGER_PHOTO_ID_5364229757218588754" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SnGSjCZReQI/AAAAAAAAAiY/6v1XvKJUlwk/s1600-h/binary1circle.bmp"&gt;&lt;img style="cursor: pointer; width: 43px; height: 37px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SnGSjCZReQI/AAAAAAAAAiY/6v1XvKJUlwk/s400/binary1circle.bmp" alt="" id="BLOGGER_PHOTO_ID_5364229761810921730" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Pixels of the cell are then summed for its area and the result is 517 square pixels. Finally, its percent difference to the calculated mean area is 0.54 %.&lt;br /&gt;&lt;br /&gt;Since I have applied different image processing techniques for this activity to be successful, and obtained very small or almost insignificant percent difference for the area of a cell, I grade myself 10/10.&lt;br /&gt;&lt;br /&gt;Before starting, Mimie has shared some insights to me on how this activity is handled. However, I have worked independently throughout its completion at the same time sharing my ideas to my classmates after I have finished this.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;The following &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code below is utilized in this activity.&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;circles = [];&lt;br /&gt;binarycircles = [];&lt;br /&gt;N = 9;&lt;br /&gt;for i=1:N&lt;br /&gt;circles1 = gray_imread('circles_'+string(i)+'.jpg');&lt;br /&gt;binarycircles1 = im2bw(circles1, 0.85);&lt;br /&gt;circles = [circles, circles1];&lt;br /&gt;binarycircles = [binarycircles, binarycircles1];&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;M = 2;&lt;br /&gt;graysubimage = circles(:,((M*256) - 255):(M*256));&lt;br /&gt;binarysubimage = binarycircles(:,((M*256) - 255):(M*256));&lt;br /&gt;&lt;br /&gt;//scf(0);&lt;br /&gt;//imshow(graysubimage);&lt;br /&gt;&lt;br /&gt;//scf(1);&lt;br /&gt;//imshow(binarysubimage);&lt;br /&gt;//imwrite(binarysubimage, 'binarysubimage2.bmp');&lt;br /&gt;&lt;br /&gt;SE = [0 1 0; 1 1 1; 0 1 0];&lt;br /&gt;newbinarysubimage = dilate(binarysubimage, SE);&lt;br /&gt;newbinarysubimage = erode(newbinarysubimage, SE);&lt;br /&gt;newbinarysubimage = erode(newbinarysubimage, SE);&lt;br /&gt;newbinarysubimage = dilate(newbinarysubimage, SE);&lt;br /&gt;&lt;br /&gt;//scf(2);&lt;br /&gt;//imshow(newbinarysubimage);&lt;br /&gt;//imwrite(newbinarysubimage, 'newbinarysubimage2.bmp');&lt;br /&gt;&lt;br /&gt;[L, n] = bwlabel(newbinarysubimage);&lt;br /&gt;&lt;br /&gt;A = [];&lt;br /&gt;for j = 1:n&lt;br /&gt;b = (L == j);&lt;br /&gt;A(j) = sum(b);&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;Area = fscanfMat('area data.txt');&lt;br /&gt;&lt;br /&gt;//scf(3);&lt;br /&gt;//histplot(length(Area), Area);&lt;br /&gt;//title('Histogram of Calculated Cell Areas');&lt;br /&gt;//xlabel('Area');&lt;br /&gt;//ylabel('Frequency');&lt;br /&gt;&lt;br /&gt;index_goodArea = find(Area&gt;500 &amp;amp; Area&lt;550);&lt;br /&gt;mean_Area = sum(Area(index_goodArea))/length(index_goodArea);&lt;br /&gt;stddev_Area = stdev(Area(index_goodArea));&lt;br /&gt;gray1circle = gray_imread('1circle.bmp');&lt;br /&gt;&lt;br /&gt;//scf(4);&lt;br /&gt;//imshow(gray1circle);&lt;br /&gt;&lt;br /&gt;binary1circle = im2bw(gray1circle, 0.85);&lt;br /&gt;&lt;br /&gt;//scf(5);&lt;br /&gt;//imshow(binary1circle);&lt;br /&gt;//imwrite(binary1circle, 'binary1circle.bmp');&lt;br /&gt;&lt;br /&gt;theo_Area = sum(binary1circle);&lt;br /&gt;percent_error = abs((theo_Area - mean_Area)/(theo_Area))*100;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1657424262821979330-6295963054195392094?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/6295963054195392094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-9-binary-operations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/6295963054195392094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/6295963054195392094'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-9-binary-operations.html' title='Activity 9 - Binary Operations'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_kx7Z922tJd0/Sm1x4iPCyOI/AAAAAAAAAeY/zL_hJp9cc4E/s72-c/Circles001.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-6085185694585295962</id><published>2009-07-21T09:30:00.058+08:00</published><updated>2009-07-24T06:49:49.320+08:00</updated><title type='text'>Activity 8 - Morphological Operations</title><content type='html'>&lt;div style="text-align: justify;"&gt;We have applied the basic image morphological operations dilation and erosion to some basic shapes in this activity. In &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt;, there are already built-in image morphological functions namely &lt;span style="font-style: italic;"&gt;dilate&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;erode&lt;/span&gt; which are used here. Also, different structural elements are implemented in the dilation and erosion of images.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;Dilation is defined by the expression&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/_kx7Z922tJd0/SmjorscAdDI/AAAAAAAAAeQ/HOlI1nJH3Lw/s1600-h/dilation.jpg"&gt;&lt;img style="cursor: pointer; width: 138px; height: 24px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmjorscAdDI/AAAAAAAAAeQ/HOlI1nJH3Lw/s320/dilation.jpg" alt="" id="BLOGGER_PHOTO_ID_5361791193745224754" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;It states that the intersection of the translation of the reflection of B translated at z for all z's to A is not an empty set. Here, A is the image to be dilated by the structuring element B and z is the coordinate of image A.&lt;br /&gt;Image dilation operates in the following algorithm. A certain location of B, which in this activity is its geometric center, is to be superimposed to every z in A. If at least one element of B coincides with the foreground of A, then the location in A being superimposed by the geometric center of B is to be replaced by one. Thus, if no elements of B coincide with any element in the foreground of A, then it is retained to zero. Recall that the background of A is equal to zero and the object or its foreground under morphological operation is equal to one.&lt;br /&gt;Meanwhile, erosion is defined as the expression below&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/_kx7Z922tJd0/SmhkTrrcc6I/AAAAAAAAAdI/etCp0rdmQ14/s1600-h/erosion.jpg"&gt;&lt;img style="cursor: pointer; width: 121px; height: 21px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmhkTrrcc6I/AAAAAAAAAdI/etCp0rdmQ14/s320/erosion.jpg" alt="" id="BLOGGER_PHOTO_ID_5361645645689811874" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;This means that all elements of B translated at z for all z's are contained in A.&lt;br /&gt;Image erosion then has the following algorithm. The geometric center of B is to be superimposed to all z in A. If all elements of B are contained in A then the location in A being superimposed by the geometric center of B is to be retained to one and otherwise, if at least one element of B coincides with the background of A, it is replaced by zero.&lt;br /&gt;&lt;br /&gt;The shapes that have been created and morphologically operated are a square with size 50 x 50, a right triangle with base 50 pixels long and height 30 pixels long, a circle with 25 pixels radius, a hollow square with size 60 x 60 and its edges are 4 pixels thick, and a plus sign with 50 pixels long for each line having thickness of 8 pixels. They are all made in &lt;span style="font-style: italic;"&gt;Paint&lt;/span&gt;.&lt;br /&gt;Meanwhile, the following structuring elements are used in dilating and eroding the images. A 4 x 4 ones, 2 x 4 ones, 4 x 2 ones, and a cross with 5 pixels long and 1 pixel thick. These are generated in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; as matrices shown below respectively.&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/_kx7Z922tJd0/SmhkT4eQkcI/AAAAAAAAAdQ/hp9iD_zhxlY/s1600-h/4x4.jpg"&gt;&lt;img style="cursor: pointer; width: 77px; height: 82px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SmhkT4eQkcI/AAAAAAAAAdQ/hp9iD_zhxlY/s320/4x4.jpg" alt="" id="BLOGGER_PHOTO_ID_5361645649124168130" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmhkUJvInWI/AAAAAAAAAdY/E4n9-AS_O2g/s1600-h/2x4.jpg"&gt;&lt;img style="cursor: pointer; width: 41px; height: 82px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmhkUJvInWI/AAAAAAAAAdY/E4n9-AS_O2g/s320/2x4.jpg" alt="" id="BLOGGER_PHOTO_ID_5361645653758352738" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SmhkUfFlg8I/AAAAAAAAAdg/16Quik_Tg7w/s1600-h/4x2.jpg"&gt;&lt;img style="cursor: pointer; width: 77px; height: 42px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmhkUfFlg8I/AAAAAAAAAdg/16Quik_Tg7w/s320/4x2.jpg" alt="" id="BLOGGER_PHOTO_ID_5361645659489665986" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmhkYpGqDYI/AAAAAAAAAdo/lEutjJP0vjs/s1600-h/cross.jpg"&gt;&lt;img style="cursor: pointer; width: 98px; height: 90px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmhkYpGqDYI/AAAAAAAAAdo/lEutjJP0vjs/s320/cross.jpg" alt="" id="BLOGGER_PHOTO_ID_5361645730897988994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Before simulating the effects of the morphological operations in the images, we have first predicted the outcome and draw this in yellow paper which is submitted to our professor Dr. Maricor Soriano.&lt;br /&gt;Now, the following sets of figures are the results of the simulated morphological operations in the five images.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Square&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; (Original Image)&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://1.bp.blogspot.com/_kx7Z922tJd0/SmcgJxwQvgI/AAAAAAAAAVg/LjWYZI6fCoE/s1600-h/square.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcgJxwQvgI/AAAAAAAAAVg/LjWYZI6fCoE/s320/square.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289233754537474" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Dilation&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;Structuring Element: 4 x 4, 2 x 4,                       4 x 2,                       cross&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Smcgo8LAiXI/AAAAAAAAAWI/x4Mt1JAj0rQ/s1600-h/dilated_sq4x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Smcgo8LAiXI/AAAAAAAAAWI/x4Mt1JAj0rQ/s320/dilated_sq4x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289769127020914" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SmchI_ohzrI/AAAAAAAAAWw/a-pGzCotsUs/s1600-h/dilated_sq2x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SmchI_ohzrI/AAAAAAAAAWw/a-pGzCotsUs/s320/dilated_sq2x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361290319811956402" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Smchel2RabI/AAAAAAAAAXY/Z5is7uHN9Mo/s1600-h/dilated_sq4x2.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Smchel2RabI/AAAAAAAAAXY/Z5is7uHN9Mo/s320/dilated_sq4x2.bmp" alt="" id="BLOGGER_PHOTO_ID_5361290690847402418" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Smch2SScaQI/AAAAAAAAAYA/e9oC9Fo-WHM/s1600-h/dilated_sqcross.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Smch2SScaQI/AAAAAAAAAYA/e9oC9Fo-WHM/s320/dilated_sqcross.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291097913714946" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Erosion&lt;br /&gt;Structuring Element: 4 x 4, 2 x 4,                       4 x 2,                       cross&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SmciIiJgLUI/AAAAAAAAAYo/9ebp336Ke9U/s1600-h/eroded_sq4x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SmciIiJgLUI/AAAAAAAAAYo/9ebp336Ke9U/s320/eroded_sq4x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291411408825666" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SmciXpICojI/AAAAAAAAAZQ/XmWKEyxu4Dk/s1600-h/eroded_sq2x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SmciXpICojI/AAAAAAAAAZQ/XmWKEyxu4Dk/s320/eroded_sq2x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291670979781170" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Smcim1-XssI/AAAAAAAAAZ4/1zzI4nCS4To/s1600-h/eroded_sq4x2.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Smcim1-XssI/AAAAAAAAAZ4/1zzI4nCS4To/s320/eroded_sq4x2.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291932126917314" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Smci2w3HHII/AAAAAAAAAag/xmrWp2KPEtY/s1600-h/eroded_sqcross.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Smci2w3HHII/AAAAAAAAAag/xmrWp2KPEtY/s320/eroded_sqcross.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292205632199810" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Triangle&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; (Original Image)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcgKBK1W_I/AAAAAAAAAVo/yWHjYZNSamE/s1600-h/triangle.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcgKBK1W_I/AAAAAAAAAVo/yWHjYZNSamE/s320/triangle.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289237892520946" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Dilation&lt;br /&gt;Structuring Element: 4 x 4, 2 x 4,                       4 x 2,                       cross&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SmcgpP0q9cI/AAAAAAAAAWQ/iiTOjGdk-NE/s1600-h/dilated_tr4x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SmcgpP0q9cI/AAAAAAAAAWQ/iiTOjGdk-NE/s320/dilated_tr4x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289774402041282" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SmchJHwWwgI/AAAAAAAAAW4/CEch32RR8bM/s1600-h/dilated_tr2x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SmchJHwWwgI/AAAAAAAAAW4/CEch32RR8bM/s320/dilated_tr2x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361290321992270338" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Smche52E0eI/AAAAAAAAAXg/qxBLUFKxeZI/s1600-h/dilated_tr4x2.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Smche52E0eI/AAAAAAAAAXg/qxBLUFKxeZI/s320/dilated_tr4x2.bmp" alt="" id="BLOGGER_PHOTO_ID_5361290696215286242" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Smch2nz7T2I/AAAAAAAAAYI/IAuSs6E0vkM/s1600-h/dilated_trcross.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Smch2nz7T2I/AAAAAAAAAYI/IAuSs6E0vkM/s320/dilated_trcross.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291103691296610" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Erosion&lt;br /&gt;Structuring Element: 4 x 4, 2 x 4,                       4 x 2,                       cross&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmciIykS5ZI/AAAAAAAAAYw/vpmlIVxcc-E/s1600-h/eroded_tr4x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmciIykS5ZI/AAAAAAAAAYw/vpmlIVxcc-E/s320/eroded_tr4x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291415816168850" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SmciYK7zC6I/AAAAAAAAAZY/qOpxYptBReA/s1600-h/eroded_tr2x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmciYK7zC6I/AAAAAAAAAZY/qOpxYptBReA/s320/eroded_tr2x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291680055233442" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcinAu5d_I/AAAAAAAAAaA/-9s0q_wp1fw/s1600-h/eroded_tr4x2.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcinAu5d_I/AAAAAAAAAaA/-9s0q_wp1fw/s320/eroded_tr4x2.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291935014811634" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Smci3Cw_OHI/AAAAAAAAAao/HcTstrCLvVM/s1600-h/eroded_trcross.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Smci3Cw_OHI/AAAAAAAAAao/HcTstrCLvVM/s320/eroded_trcross.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292210438355058" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Circle&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; (Original Image)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcgKjq_USI/AAAAAAAAAVw/kNpcLd7bnf4/s1600-h/circle.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcgKjq_USI/AAAAAAAAAVw/kNpcLd7bnf4/s320/circle.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289247154196770" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Dilation&lt;br /&gt;Structuring Element: 4 x 4, 2 x 4,                       4 x 2,                       cross&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SmcgpthcCRI/AAAAAAAAAWY/jZVK7E0WyF0/s1600-h/dilated_ci4x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SmcgpthcCRI/AAAAAAAAAWY/jZVK7E0WyF0/s320/dilated_ci4x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289782374435090" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SmchJS-FWmI/AAAAAAAAAXA/jxAcPbFZcww/s1600-h/dilated_ci2x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SmchJS-FWmI/AAAAAAAAAXA/jxAcPbFZcww/s320/dilated_ci2x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361290325002639970" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SmchfOGjO2I/AAAAAAAAAXo/XkCDOLrQ6gs/s1600-h/dilated_ci4x2.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmchfOGjO2I/AAAAAAAAAXo/XkCDOLrQ6gs/s320/dilated_ci4x2.bmp" alt="" id="BLOGGER_PHOTO_ID_5361290701653097314" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Smch28A-G1I/AAAAAAAAAYQ/vPWVLlHN9wo/s1600-h/dilated_cicross.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Smch28A-G1I/AAAAAAAAAYQ/vPWVLlHN9wo/s320/dilated_cicross.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291109114714962" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Erosion&lt;br /&gt;Structuring Element: 4 x 4, 2 x 4,                       4 x 2,                       cross&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SmciJEoU17I/AAAAAAAAAY4/00EVhbekl5E/s1600-h/eroded_ci4x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SmciJEoU17I/AAAAAAAAAY4/00EVhbekl5E/s320/eroded_ci4x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291420664911794" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SmciYQACfDI/AAAAAAAAAZg/aZhl-HGmhc4/s1600-h/eroded_ci2x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmciYQACfDI/AAAAAAAAAZg/aZhl-HGmhc4/s320/eroded_ci2x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291681415199794" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SmcinfclYyI/AAAAAAAAAaI/kMck27jer-o/s1600-h/eroded_ci4x2.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SmcinfclYyI/AAAAAAAAAaI/kMck27jer-o/s320/eroded_ci4x2.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291943259497250" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Smci3YjmwzI/AAAAAAAAAaw/-cCDpM7vBOE/s1600-h/eroded_cicross.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Smci3YjmwzI/AAAAAAAAAaw/-cCDpM7vBOE/s320/eroded_cicross.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292216287806258" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Hollow Square&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; (Original Image)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SmcgK_KRo5I/AAAAAAAAAV4/3WBUZNdw46A/s1600-h/hollow+square.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SmcgK_KRo5I/AAAAAAAAAV4/3WBUZNdw46A/s320/hollow+square.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289254533178258" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Dilation&lt;br /&gt;Structuring Element: 4 x 4, 2 x 4,                       4 x 2,                       cross&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Smcgp7BHgsI/AAAAAAAAAWg/PKP10SJt5go/s1600-h/dilated_hsq4x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Smcgp7BHgsI/AAAAAAAAAWg/PKP10SJt5go/s320/dilated_hsq4x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289785996968642" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/Smhrk3K89GI/AAAAAAAAAdw/0A9QgEwMA6w/s1600-h/dilated_hsq2x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Smhrk3K89GI/AAAAAAAAAdw/0A9QgEwMA6w/s320/dilated_hsq2x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361653637413925986" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SmhrlEwOMHI/AAAAAAAAAd4/mHe5fhNcshU/s1600-h/dilated_hsq4x2.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmhrlEwOMHI/AAAAAAAAAd4/mHe5fhNcshU/s320/dilated_hsq4x2.bmp" alt="" id="BLOGGER_PHOTO_ID_5361653641059905650" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Smch282Tl4I/AAAAAAAAAYY/vCO82G-S8Iw/s1600-h/dilated_hsqcross.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Smch282Tl4I/AAAAAAAAAYY/vCO82G-S8Iw/s320/dilated_hsqcross.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291109338421122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Erosion&lt;br /&gt;Structuring Element: 4 x 4, 2 x 4,                       4 x 2,                       cross&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmciJgoPCuI/AAAAAAAAAZA/PciaPbd3BMg/s1600-h/eroded_hsq4x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmciJgoPCuI/AAAAAAAAAZA/PciaPbd3BMg/s320/eroded_hsq4x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291428180724450" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SmhrlROUXII/AAAAAAAAAeA/vVlRl3ZOvgU/s1600-h/eroded_hsq2x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SmhrlROUXII/AAAAAAAAAeA/vVlRl3ZOvgU/s320/eroded_hsq2x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361653644407364738" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Smhrlr1rCsI/AAAAAAAAAeI/ZKrDpnTQF6k/s1600-h/eroded_hsq4x2.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Smhrlr1rCsI/AAAAAAAAAeI/ZKrDpnTQF6k/s320/eroded_hsq4x2.bmp" alt="" id="BLOGGER_PHOTO_ID_5361653651551750850" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Smci3uaHcMI/AAAAAAAAAa4/BbmW_31dTHY/s1600-h/eroded_hsqcross.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Smci3uaHcMI/AAAAAAAAAa4/BbmW_31dTHY/s320/eroded_hsqcross.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292222153584834" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Plus Sign&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; (Original Image)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcgLEa_yFI/AAAAAAAAAWA/2q9_e48r08E/s1600-h/plus.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcgLEa_yFI/AAAAAAAAAWA/2q9_e48r08E/s320/plus.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289255945488466" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Dilation&lt;br /&gt;Structuring Element: 4 x 4, 2 x 4,                       4 x 2,                       cross&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcgqK57m7I/AAAAAAAAAWo/5CmGc_F8Adg/s1600-h/dilated_pl4x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcgqK57m7I/AAAAAAAAAWo/5CmGc_F8Adg/s320/dilated_pl4x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289790261795762" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SmchJ1npk7I/AAAAAAAAAXQ/DM0WXLuotSw/s1600-h/dilated_pl2x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SmchJ1npk7I/AAAAAAAAAXQ/DM0WXLuotSw/s320/dilated_pl2x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361290334303785906" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmchfZtAsqI/AAAAAAAAAX4/4DsffxlJ1hY/s1600-h/dilated_pl4x2.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmchfZtAsqI/AAAAAAAAAX4/4DsffxlJ1hY/s320/dilated_pl4x2.bmp" alt="" id="BLOGGER_PHOTO_ID_5361290704767201954" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Smch3FYu2OI/AAAAAAAAAYg/R_vcR2-2Asc/s1600-h/dilated_plcross.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Smch3FYu2OI/AAAAAAAAAYg/R_vcR2-2Asc/s320/dilated_plcross.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291111630297314" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Erosion&lt;br /&gt;Structuring Element: 4 x 4, 2 x 4,                       4 x 2,                       cross&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SmciJgRgxNI/AAAAAAAAAZI/wLRrgFlByNE/s1600-h/eroded_pl4x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SmciJgRgxNI/AAAAAAAAAZI/wLRrgFlByNE/s320/eroded_pl4x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291428085417170" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmciY8_avqI/AAAAAAAAAZw/bWh787cs9jQ/s1600-h/eroded_pl2x4.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmciY8_avqI/AAAAAAAAAZw/bWh787cs9jQ/s320/eroded_pl2x4.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291693492190882" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcioJFpPOI/AAAAAAAAAaY/QkVl9vu6lPk/s1600-h/eroded_pl4x2.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcioJFpPOI/AAAAAAAAAaY/QkVl9vu6lPk/s320/eroded_pl4x2.bmp" alt="" id="BLOGGER_PHOTO_ID_5361291954437569762" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Smci4Bu1WrI/AAAAAAAAAbA/klTcwNGpMY4/s1600-h/eroded_plcross.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Smci4Bu1WrI/AAAAAAAAAbA/klTcwNGpMY4/s320/eroded_plcross.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292227340753586" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;My predictions exactly match the simulated results. These are verified by measuring the pixel dimensions of the dilated and eroded images in &lt;span style="font-style: italic;"&gt;Paint&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;We also tried other two image morphological operations in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; namely &lt;span style="font-style: italic;"&gt;thin&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;skel&lt;/span&gt; which mean thinning and skeletonization respectively. The following results are obtained.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Square&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; (Original Image)&lt;/span&gt;, Thinning, Skeletonization&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcgJxwQvgI/AAAAAAAAAVg/LjWYZI6fCoE/s1600-h/square.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcgJxwQvgI/AAAAAAAAAVg/LjWYZI6fCoE/s320/square.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289233754537474" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SmcjI-WZ52I/AAAAAAAAAbI/rP9doMQ1kJE/s1600-h/thinned_sq.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SmcjI-WZ52I/AAAAAAAAAbI/rP9doMQ1kJE/s320/thinned_sq.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292518490761058" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SmcjWhaM0eI/AAAAAAAAAbw/5GaazrOhzaY/s1600-h/skeletonized_sq.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SmcjWhaM0eI/AAAAAAAAAbw/5GaazrOhzaY/s320/skeletonized_sq.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292751240221154" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Triangle&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; (Original Image)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; Thinning, Skeletonization&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcgKBK1W_I/AAAAAAAAAVo/yWHjYZNSamE/s1600-h/triangle.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcgKBK1W_I/AAAAAAAAAVo/yWHjYZNSamE/s320/triangle.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289237892520946" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcjJFSlXZI/AAAAAAAAAbQ/R90sig44vjw/s1600-h/thinned_tr.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcjJFSlXZI/AAAAAAAAAbQ/R90sig44vjw/s320/thinned_tr.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292520353783186" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcjW4vYXAI/AAAAAAAAAb4/a-TE17fd3CY/s1600-h/skeletonized_tr.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcjW4vYXAI/AAAAAAAAAb4/a-TE17fd3CY/s320/skeletonized_tr.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292757503073282" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Circle&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; (Original Image)&lt;/span&gt;, Thinning, Skeletonization&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcgKjq_USI/AAAAAAAAAVw/kNpcLd7bnf4/s1600-h/circle.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcgKjq_USI/AAAAAAAAAVw/kNpcLd7bnf4/s320/circle.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289247154196770" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcjJc6MX4I/AAAAAAAAAbY/OW5O04nhhXQ/s1600-h/thinned_ci.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcjJc6MX4I/AAAAAAAAAbY/OW5O04nhhXQ/s320/thinned_ci.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292526693932930" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcjXJ3xX2I/AAAAAAAAAcA/jEL6r4nqKz8/s1600-h/skeletonized_ci.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcjXJ3xX2I/AAAAAAAAAcA/jEL6r4nqKz8/s320/skeletonized_ci.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292762101669730" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Hollow Square&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; (Original Image)&lt;/span&gt;, Thinning, Skeletonization&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SmcgK_KRo5I/AAAAAAAAAV4/3WBUZNdw46A/s1600-h/hollow+square.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SmcgK_KRo5I/AAAAAAAAAV4/3WBUZNdw46A/s320/hollow+square.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289254533178258" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcjJhVLLaI/AAAAAAAAAbg/RrGZZa6ssEI/s1600-h/thinned_hsq.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcjJhVLLaI/AAAAAAAAAbg/RrGZZa6ssEI/s320/thinned_hsq.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292527880842658" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcjXMO_cJI/AAAAAAAAAcI/6Wx9fl_9ZIw/s1600-h/skeletonized_hsq.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcjXMO_cJI/AAAAAAAAAcI/6Wx9fl_9ZIw/s320/skeletonized_hsq.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292762735931538" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Plus Sign&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; (Original Image)&lt;/span&gt;, Thinning, Skeletonization&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcgLEa_yFI/AAAAAAAAAWA/2q9_e48r08E/s1600-h/plus.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SmcgLEa_yFI/AAAAAAAAAWA/2q9_e48r08E/s320/plus.bmp" alt="" id="BLOGGER_PHOTO_ID_5361289255945488466" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SmcjJ9arEqI/AAAAAAAAAbo/7Nk87vSHMSQ/s1600-h/thinned_pl.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SmcjJ9arEqI/AAAAAAAAAbo/7Nk87vSHMSQ/s320/thinned_pl.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292535420097186" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcjXc7wRNI/AAAAAAAAAcQ/GCGgiANJFBc/s1600-h/skeletonized_pl.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SmcjXc7wRNI/AAAAAAAAAcQ/GCGgiANJFBc/s320/skeletonized_pl.bmp" alt="" id="BLOGGER_PHOTO_ID_5361292767218648274" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be observed that the image morphological operations thinning and skeletonization are quite complicated compared to dilation and erosion. The apparent effects of these are in thinning, the images are left with single pixel lines that do not always follow the contour of the object. Meeanwhile in skeletonization, the images are converted to its skeleton or framework but some areas in the foreground are retained. Due to its unconsistent effects, these two operations are thus sensitive to the image to be morphologically transformed.&lt;br /&gt;&lt;br /&gt;Since I fully understand how the two basic image morphological operations dilation and erosion work, and my predictions match the simulated results then I grade myself 10/10 for this activity.&lt;br /&gt;&lt;br /&gt;I have successfully finished this activity individually but I have shared what I learned with my other classmates.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;The whole &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code below is utilized in this activity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;sq = gray_imread('square.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;tr = gray_imread('triangle.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;ci = gray_imread('circle.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;hsq = gray_imread('hollow square.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;pl = gray_imread('plus.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;A = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;B = [1 1; 1 1; 1 1; 1 1];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;C = [1 1 1 1; 1 1 1 1];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;cross = [0 0 1 0 0; 0 0 1 0 0; 1 1 1 1 1; 0 0 1 0 0; 0 0 1 0 0];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;dilated_sq = dilate(sq, A);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(dilated_sq);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(dilated_sq, 'dilated_sq4x4.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;eroded_sq = erode(sq, A);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(eroded_sq);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(eroded_sq, 'eroded_sq4x4.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;dilated_tr = dilate(tr, A);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(dilated_tr);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(dilated_tr, 'dilated_tr4x4.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;eroded_tr = erode(tr, A);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(eroded_tr);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(eroded_tr, 'eroded_tr4x4.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(4);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;dilated_ci = dilate(ci, A);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(dilated_ci);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(dilated_ci, 'dilated_ci4x4.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(5);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;eroded_ci = erode(ci, A);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(eroded_ci);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(eroded_ci, 'eroded_ci4x4.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(6);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;dilated_hsq = dilate(hsq, A);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(dilated_hsq);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(dilated_hsq, 'dilated_hsq4x4.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(7);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;eroded_hsq = erode(hsq, A);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(eroded_hsq);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(eroded_hsq, 'eroded_hsq4x4.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(8);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;dilated_pl = dilate(pl, A);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(dilated_pl);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(dilated_pl, 'dilated_pl4x4.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(9);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;eroded_pl = erode(pl, A);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(eroded_pl);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(eroded_pl, 'eroded_pl4x4.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(10);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;thinned_sq = thin(sq);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(thinned_sq);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(thinned_sq, 'thinned_sq.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(11);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;skeletonized_sq = skel(sq);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(skeletonized_sq);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(skeletonized_sq, 'skeletonized_sq.bmp');&lt;/span&gt;&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/1657424262821979330-6085185694585295962?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/6085185694585295962/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-8-morphological-operations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/6085185694585295962'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/6085185694585295962'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-8-morphological-operations.html' title='Activity 8 - Morphological Operations'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_kx7Z922tJd0/SmjorscAdDI/AAAAAAAAAeQ/HOlI1nJH3Lw/s72-c/dilation.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-4105560440437789803</id><published>2009-07-14T08:36:00.054+08:00</published><updated>2009-07-27T19:24:13.526+08:00</updated><title type='text'>Activity 7 - Enhancement in the Frequency Domain</title><content type='html'>&lt;div style="text-align: justify;"&gt;This activity is composed of 4 major parts which introduce us to image enhancement in the frequency domain via the Fourier transform.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 7-A - Convolution Theorem&lt;/span&gt;&lt;br /&gt;Different apertures are again created similar to the previous activities for the application of Fourier transform (FT). However this time, the convolution theorem is illustrated through the FT of some images.&lt;br /&gt;Initially, a two-dot single pixel aperture symmetric about the horizontal axis is made in &lt;span style="font-style: italic;"&gt;Paint&lt;/span&gt;. Its FT is shown below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlvmcFx5ihI/AAAAAAAAAQw/wrqZWQKDJH0/s1600-h/2dotpixels.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlvmcFx5ihI/AAAAAAAAAQw/wrqZWQKDJH0/s320/2dotpixels.bmp" alt="" id="BLOGGER_PHOTO_ID_5358129551949531666" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlvmcXzgMHI/AAAAAAAAAQ4/3rimFKZIQDY/s1600-h/F2dots.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlvmcXzgMHI/AAAAAAAAAQ4/3rimFKZIQDY/s320/F2dots.bmp" alt="" id="BLOGGER_PHOTO_ID_5358129556788097138" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be observed that a periodic FT pattern is produced. This is expected since the FT of two dirac deltas along an axis symmetric to the center is a sine function with frequency corresponding to their separation.&lt;br /&gt;&lt;br /&gt;Next, instead of dots, they are replaced with circles with varying radius.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlvmcljzWDI/AAAAAAAAARA/WxDtFCmbkFI/s1600-h/2circles.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlvmcljzWDI/AAAAAAAAARA/WxDtFCmbkFI/s320/2circles.bmp" alt="" id="BLOGGER_PHOTO_ID_5358129560480340018" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/Slvmc_jlQrI/AAAAAAAAARI/g2au1MOmvcc/s1600-h/F2circles.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Slvmc_jlQrI/AAAAAAAAARI/g2au1MOmvcc/s320/F2circles.bmp" alt="" id="BLOGGER_PHOTO_ID_5358129567458738866" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlvmdBBIpfI/AAAAAAAAARQ/VUkCnNBMSJ0/s1600-h/2circleslargerradius.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlvmdBBIpfI/AAAAAAAAARQ/VUkCnNBMSJ0/s320/2circleslargerradius.bmp" alt="" id="BLOGGER_PHOTO_ID_5358129567851128306" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlyH2ot3k0I/AAAAAAAAARY/Y0mUWy35mZ8/s1600-h/F2circleslargerradius.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlyH2ot3k0I/AAAAAAAAARY/Y0mUWy35mZ8/s320/F2circleslargerradius.bmp" alt="" id="BLOGGER_PHOTO_ID_5358307029376537410" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlyH27uBbbI/AAAAAAAAARg/hwifGEwIBy4/s1600-h/2circleslargestradius.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlyH27uBbbI/AAAAAAAAARg/hwifGEwIBy4/s320/2circleslargestradius.bmp" alt="" id="BLOGGER_PHOTO_ID_5358307034477456818" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlyH3JxrksI/AAAAAAAAARo/aAyWEwjzpCc/s1600-h/F2circleslargestradius.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlyH3JxrksI/AAAAAAAAARo/aAyWEwjzpCc/s320/F2circleslargestradius.bmp" alt="" id="BLOGGER_PHOTO_ID_5358307038250898114" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;For the apertures above, the convolution theorem comes in. the FT of a circular aperture which displays airy disks is then convoluted with the FT of dirac deltas which is a sine function similar to the two-dot single pixel aperture. Hence, we see airy disks pattern with vertical alternation of bright and dark stripes. As we increase the radius, airy disks become smaller but the vertical stripes are still discernable.&lt;br /&gt;&lt;br /&gt;After circular apertures, they are substituted with squares. Their widths are also varied.&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/_kx7Z922tJd0/SlyH3XdeGOI/AAAAAAAAARw/nTTKHI4OLyo/s1600-h/2squares.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlyH3XdeGOI/AAAAAAAAARw/nTTKHI4OLyo/s320/2squares.bmp" alt="" id="BLOGGER_PHOTO_ID_5358307041924225250" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlyH3q0J0wI/AAAAAAAAAR4/ZhXCxKOKxfU/s1600-h/F2squares.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlyH3q0J0wI/AAAAAAAAAR4/ZhXCxKOKxfU/s320/F2squares.bmp" alt="" id="BLOGGER_PHOTO_ID_5358307047119639298" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlyIf0eBGsI/AAAAAAAAASA/m3hJcbET7CE/s1600-h/2squareslargerwidth.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlyIf0eBGsI/AAAAAAAAASA/m3hJcbET7CE/s320/2squareslargerwidth.bmp" alt="" id="BLOGGER_PHOTO_ID_5358307736905915074" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlyIgrFwJ3I/AAAAAAAAASI/YZVxM3KaKbY/s1600-h/F2squareslargerwidth.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlyIgrFwJ3I/AAAAAAAAASI/YZVxM3KaKbY/s320/F2squareslargerwidth.bmp" alt="" id="BLOGGER_PHOTO_ID_5358307751568090994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The FT of a single square aperture is a sinc function. This is then convoluted to the FT of the first aperture. Hence, we observe sinc pattern with vertical alternating bright and dark stripes. Like in the circular apertures, the FT image becomes smaller as the width increases.&lt;br /&gt;&lt;br /&gt;Pairs of Gaussian apertures are used next. They are in the form&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SmBaX3n-4aI/AAAAAAAAAVY/6TlZohlwOjw/s1600-h/gaussian.jpg"&gt;&lt;img style="cursor: pointer; width: 164px; height: 44px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SmBaX3n-4aI/AAAAAAAAAVY/6TlZohlwOjw/s320/gaussian.jpg" alt="" id="BLOGGER_PHOTO_ID_5359382922686030242" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;where &lt;span style="font-style: italic;"&gt;sigma&lt;/span&gt; is the variance and &lt;span style="font-style: italic;"&gt;mu&lt;/span&gt; is the location of its maximum. Variance is changed for different Gaussian aperture sizes.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlyIgl4q_2I/AAAAAAAAASQ/V3qMqcQPyEk/s1600-h/gaussianm0.5s0.05.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlyIgl4q_2I/AAAAAAAAASQ/V3qMqcQPyEk/s320/gaussianm0.5s0.05.bmp" alt="" id="BLOGGER_PHOTO_ID_5358307750171049826" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlyIzE7GZRI/AAAAAAAAASo/s_9-oRhI5uQ/s1600-h/Fgaussianm0.5s0.05.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlyIzE7GZRI/AAAAAAAAASo/s_9-oRhI5uQ/s320/Fgaussianm0.5s0.05.bmp" alt="" id="BLOGGER_PHOTO_ID_5358308067740378386" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlyIgyoJk6I/AAAAAAAAASY/hL2fLfZmHeA/s1600-h/gaussianm0.5s0.2.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlyIgyoJk6I/AAAAAAAAASY/hL2fLfZmHeA/s320/gaussianm0.5s0.2.bmp" alt="" id="BLOGGER_PHOTO_ID_5358307753591411618" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlyIzK7DWuI/AAAAAAAAASw/qmjQWswuRXs/s1600-h/Fgaussianm0.5s0.2.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlyIzK7DWuI/AAAAAAAAASw/qmjQWswuRXs/s320/Fgaussianm0.5s0.2.bmp" alt="" id="BLOGGER_PHOTO_ID_5358308069350791906" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlyIhDnNbLI/AAAAAAAAASg/e0xLsPVPABQ/s1600-h/gaussianm0.5s0.5.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlyIhDnNbLI/AAAAAAAAASg/e0xLsPVPABQ/s320/gaussianm0.5s0.5.bmp" alt="" id="BLOGGER_PHOTO_ID_5358307758150872242" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlyIzThjD6I/AAAAAAAAAS4/itSH2z__-mI/s1600-h/Fgaussianm0.5s0.5.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlyIzThjD6I/AAAAAAAAAS4/itSH2z__-mI/s320/Fgaussianm0.5s0.5.bmp" alt="" id="BLOGGER_PHOTO_ID_5358308071659736994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be observed that as the variance of the Gaussian aperture is increased, the FT image which is a single Gaussian function centrally located gets smaller.&lt;br /&gt;&lt;br /&gt;A Gaussian aperture is inverted as depicted as follows having the brighest to be the darkest and vice-versa.&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/_kx7Z922tJd0/SlyJViowdPI/AAAAAAAAATA/wquPQwhISdo/s1600-h/gaussianinv.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlyJViowdPI/AAAAAAAAATA/wquPQwhISdo/s320/gaussianinv.bmp" alt="" id="BLOGGER_PHOTO_ID_5358308659832059122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Then, its FT is acquired without getting the modulus or absolute values. The real and imaginary part is comparable to the non-inverted Gaussian aperture such that they cancel out when multiplied. This inversion property in the Fourier or frequency space is exploited for the next sections of this activity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 7-B - Fingerprints: Ridge Enhancement&lt;/span&gt;&lt;br /&gt;An image of a fingerprint is downloaded from the internet for this part of the activity. Then, this image is enhanced particularly emphasizing its ridges at the same time removing its blotches. The process is done in the frequency domain through designing a filter that can enhance the image. In a more detalied steps, the image is read in grayscale-type then its FT is then multiplied element-by-element to the shifted filter through &lt;span style="font-style: italic;"&gt;fftshift&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt;. Note that we are enhancing the image in the frequency domain that is, the filter created is already in this domain, thus it is no longer required to shift the image. Finally, the inverse FT is applied to the product and this corresponds to the enhanced fingerprint image.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Sl56m0KMjZI/AAAAAAAAAUI/hiVNH669CTo/s1600-h/fingerprint.jpg"&gt;&lt;img style="cursor: pointer; width: 300px; height: 300px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Sl56m0KMjZI/AAAAAAAAAUI/hiVNH669CTo/s320/fingerprint.jpg" alt="" id="BLOGGER_PHOTO_ID_5358855413872496018" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SmBEk8hy7OI/AAAAAAAAAVQ/KW7_3YGFPvM/s1600-h/Ffingerprint.bmp"&gt;&lt;img style="cursor: pointer; width: 300px; height: 300px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SmBEk8hy7OI/AAAAAAAAAVQ/KW7_3YGFPvM/s320/Ffingerprint.bmp" alt="" id="BLOGGER_PHOTO_ID_5359358958084746466" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SmBCVhCBGHI/AAAAAAAAAVA/KQrjlg0Bmjs/s1600-h/betterfingerprint.bmp"&gt;&lt;img style="cursor: pointer; width: 300px; height: 300px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SmBCVhCBGHI/AAAAAAAAAVA/KQrjlg0Bmjs/s320/betterfingerprint.bmp" alt="" id="BLOGGER_PHOTO_ID_5359356493982406770" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SmBC0iLlB4I/AAAAAAAAAVI/yv7CRFVgAW0/s1600-h/filterfingerprint.bmp"&gt;&lt;img style="cursor: pointer; width: 300px; height: 300px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SmBC0iLlB4I/AAAAAAAAAVI/yv7CRFVgAW0/s320/filterfingerprint.bmp" alt="" id="BLOGGER_PHOTO_ID_5359357026866890626" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Source: &lt;span style="font-style: italic;"&gt;http://www.cs.tau.ac.il/~turkel/images.html&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The upperleft image is the original fingerprint image downloaded from the website as written above. The next one is the FT image of the original image from which the filter below is based. It can be observed from the FT that there are regions where the intensity is higher than the others. These correspond to the frequency of the ridges thus they are made white in the filter for emphasis. Higher order frequencies which are attributed to blotches and other noise in the image are then blackened in the filter. As the enhanced fingerprint image shown above, the ridges are emphasized at the same time, although not totally removed, the blotches are very much diminished.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 7-C - Lunar Landing Scanned Pictures: Line Removal&lt;/span&gt;&lt;br /&gt;The third part of the activity has also the same procedure as the second, except that here, unnecessary patterns from the image are removed. From a scanned picture of lunar landing as the activity suggested to improve, there are vertical lines that are to be removed. Again, the filter used is based from the FT of the original image. The set of images below summarizes the results.&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/_kx7Z922tJd0/SlyKEjwl-EI/AAAAAAAAATI/FC50UYtzpLY/s1600-h/hi_res_vertical_lg.gif"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlyKEjwl-EI/AAAAAAAAATI/FC50UYtzpLY/s320/hi_res_vertical_lg.gif" alt="" id="BLOGGER_PHOTO_ID_5358309467587213378" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlyKFIYiigI/AAAAAAAAATQ/6TJjpvwlFcM/s1600-h/Fmoon.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlyKFIYiigI/AAAAAAAAATQ/6TJjpvwlFcM/s320/Fmoon.bmp" alt="" id="BLOGGER_PHOTO_ID_5358309477418437122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/Sl1vqfXUCdI/AAAAAAAAAUA/leDGgfIgmbA/s1600-h/bettermoon.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/Sl1vqfXUCdI/AAAAAAAAAUA/leDGgfIgmbA/s320/bettermoon.bmp" alt="" id="BLOGGER_PHOTO_ID_5358561907405228498" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Sl1vqPZfP7I/AAAAAAAAAT4/_6J9-roj224/s1600-h/filtermoon.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Sl1vqPZfP7I/AAAAAAAAAT4/_6J9-roj224/s320/filtermoon.bmp" alt="" id="BLOGGER_PHOTO_ID_5358561903119384498" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;A horizontal line is drawn as the filter leaving the center in white. This is because the lowest orders of frequencies which correspond to the primary image information are found here. Recall from the first part that the Gaussian aperture is inverted such that the real and imaginary parts of its FT can cancel out the FT of the non-inverted aperture. So, in this case, since horizontal aperture has FT of vertical patterns, the filter is designed as illustrated above. Hence, the resulting enhanced lunar landing picture no longer contains the vertical lines and its primary image information still remain.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 7-D - Canvas Weave Modeling and Removal&lt;/span&gt;&lt;br /&gt;The last part is similar to the previous section except that a different pattern from the image must be eliminated. An oil painting from the Vargas Museum collection is to be enhanced by removing the canvas weave pattern on it. The following images are the results.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Sl6AKCiH7zI/AAAAAAAAAUQ/sYLn_l4Ve_E/s1600-h/canvasweave.JPG"&gt;&lt;img style="cursor: pointer; width: 320px; height: 230px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Sl6AKCiH7zI/AAAAAAAAAUQ/sYLn_l4Ve_E/s320/canvasweave.JPG" alt="" id="BLOGGER_PHOTO_ID_5358861516584513330" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/Sl6Rk6WXIRI/AAAAAAAAAUo/iIsvljfMpfs/s1600-h/Fcanvas.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 230px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/Sl6Rk6WXIRI/AAAAAAAAAUo/iIsvljfMpfs/s320/Fcanvas.bmp" alt="" id="BLOGGER_PHOTO_ID_5358880669941834002" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/Sl6RAAhxE8I/AAAAAAAAAUY/vqqdXmRQsew/s1600-h/bettercanvas.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 230px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Sl6RAAhxE8I/AAAAAAAAAUY/vqqdXmRQsew/s320/bettercanvas.bmp" alt="" id="BLOGGER_PHOTO_ID_5358880035945124802" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/Sl6RaLpJGjI/AAAAAAAAAUg/gwFP8AFyYcA/s1600-h/filtercanvas.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 230px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Sl6RaLpJGjI/AAAAAAAAAUg/gwFP8AFyYcA/s320/filtercanvas.bmp" alt="" id="BLOGGER_PHOTO_ID_5358880485605448242" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The FT of the grayscaled original image shows distinctive bright spots which correspond to the canvas weave pattern. Thus, they are blocked in the filter used for enhancement. Consequently, there are no longer weave pattern seen in the resulting oil painting image. However, the brushstrokes in the painting are not enhanced since they depend on the weave pattern.&lt;br /&gt;In modeling a canvas weave pattern, the filter is inverted and modified to single-pixel bright spots. Its FT is then obtained. These are shown below.&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/_kx7Z922tJd0/Sl6ZSukPRnI/AAAAAAAAAUw/-NZ93glFT-g/s1600-h/filtercanvas2.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 230px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/Sl6ZSukPRnI/AAAAAAAAAUw/-NZ93glFT-g/s320/filtercanvas2.bmp" alt="" id="BLOGGER_PHOTO_ID_5358889153634190962" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/Sl6ZTahG9CI/AAAAAAAAAU4/29s8V5cPhNA/s1600-h/Ffiltercanvasinv.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 230px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/Sl6ZTahG9CI/AAAAAAAAAU4/29s8V5cPhNA/s320/Ffiltercanvasinv.bmp" alt="" id="BLOGGER_PHOTO_ID_5358889165432222754" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Ideally, the canvas weave pattern is generated through the superimposition of sinusoidal waves in both horizontal and vertical propagation having different frequencies. Thus, the filter is simplified as composed of only single-pixel bright spots which are equivalent to dirac deltas, recalling that the FT of a pair of dirac deltas is a sine function.&lt;br /&gt;&lt;br /&gt;So far, this is the longest activity I've successfully completed, but since I have accomplished all the requirements of each section and gained better understanding about image enhancement in the frequency domain, I grade myself 10/10.&lt;br /&gt;&lt;br /&gt;Throughout the activity, I have collaborated with Gary and Raffy who have brought useful insights during our discussions.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;The whole &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code used in this activity is as follows.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;stacksize(4e7);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;I2dots = gray_imread('2dotpixels.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(abs(fftshift(fft2(I2dots))), []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(abs(fftshift(fft2(I2dots)))/max(abs(fftshift(fft2(I2dots)))), 'F2dots.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//I2circles = gray_imread('2circleslargestradius.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(abs(fftshift(fft2(I2circles))), []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(abs(fftshift(fft2(I2circles)))/max(abs(fftshift(fft2(I2circles)))), 'F2circleslargestradius.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;I2squares = gray_imread('2squareslargerwidth.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;2squares = abs(fftshift(fft2(I2squares)));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(abs(fftshift(fft2(I2squares))), []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(abs(fftshift(fft2(I2squares)))/max(abs(fftshift(fft2(I2squares)))), 'F2squareslargerwidth.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a = 100;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;b = 100;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;m = 0.5;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;s = 0.2;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;x = linspace(-1, 1, a);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;y = linspace(-1, 1, b);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[X, Y] = meshgrid(x, y);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;g = exp(-((X + m).*(X + m))/s^2).*exp(-(Y.*Y)/s^2) + exp(-((X - m).*(X - m))/s^2).*exp(-(Y.*Y)/s^2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(g, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(g/max(g), 'gaussianm0.5s0.2.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Igaussian = gray_imread('gaussianm0.5s0.2.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Fgaussian = abs(fftshift(fft2(Igaussian)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Fgaussian2 = fftshift(fft2(Igaussian));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;realFg = real(Fgaussian2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;imFg = imag(Fgaussian2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(4);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(Fgaussian, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//mesh(Fgaussian);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(Fgaussian/max(Fgaussian), 'Fgaussianm0.5s0.05.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;ginv = max(g) - g;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(5);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(ginv, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(ginv/max(ginv), 'gaussianinv.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Iginv = gray_imread('gaussianinv.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Fginv = fftshift(fft2(Iginv));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;realFginv = real(Fginv);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;imFginv = imag(Fginv);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;moon = gray_imread('hi_res_vertical_lg.gif');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Fmoon = log(abs(fftshift(fft2(moon))));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(6);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(Fmoon, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(Fmoon/max(Fmoon), 'Fmoon.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;filtermoon = gray_imread('filtermoon.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;bettermoon = abs((ifft(fftshift(filtermoon).*fft2(moon))));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(7);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(bettermoon, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(bettermoon/max(bettermoon), 'bettermoon.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;fingerprint = gray_imread('fingerprint.jpg');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Ffingerprint = log(abs(fftshift(fft2(fingerprint))));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(8);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(Ffingerprint, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(Ffingerprint/max(Ffingerprint), 'Ffingerprint.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;filterfingerprint = gray_imread('filterfingerprint.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;betterfingerprint = abs((ifft(fftshift(filterfingerprint).*fft2(fingerprint))));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(9);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(betterfingerprint, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(betterfingerprint/max(betterfingerprint), 'betterfingerprint.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;canvas = gray_imread('canvasweave.jpg');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Fcanvas = log(abs(fftshift(fft2(canvas))));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(10);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(Fcanvas, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(Fcanvas/max(Fcanvas), 'Fcanvas.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;filtercanvas = gray_imread('filtercanvas.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;bettercanvas = abs((ifft(fftshift(filtercanvas).*fft2(canvas))));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(11);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(bettercanvas, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(bettercanvas/max(bettercanvas), 'bettercanvas.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;filtercanvasinv = gray_imread('filtercanvasinv.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Ffiltercanvasinv = abs(fftshift(fft2(filtercanvasinv)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(12);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(Ffiltercanvasinv, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(Ffiltercanvasinv/max(Ffiltercanvasinv), 'Ffiltercanvasinv.bmp');&lt;/span&gt;&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/1657424262821979330-4105560440437789803?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/4105560440437789803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-7-enhancement-in-frequency.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/4105560440437789803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/4105560440437789803'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-7-enhancement-in-frequency.html' title='Activity 7 - Enhancement in the Frequency Domain'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_kx7Z922tJd0/SlvmcFx5ihI/AAAAAAAAAQw/wrqZWQKDJH0/s72-c/2dotpixels.bmp' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-8139782485294997790</id><published>2009-07-09T08:39:00.040+08:00</published><updated>2009-08-28T20:18:26.433+08:00</updated><title type='text'>Activity 6 - Properties of the 2D Fourier Transform</title><content type='html'>After familiarizing ourselves in the Fourier transform (FT) model of image formation from the previous activity, this time, we have investigated the properties of the 2D Fourier transform. This is divided into 2 major parts.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; 6-A &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;- F&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;a&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;miliarization with Fourier Transform of Different 2D Patterns&lt;/span&gt;&lt;br /&gt;This first part is similar to Activity 5-A where the Fourier transform of some 2D patterns are obtained using &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt;. Physically, these represent the diffraction patterns in such apertures. In this case, other 2D patterns are used which are created in &lt;span style="font-style: italic;"&gt;Paint&lt;/span&gt;. Recall that the output image displayed is the absolute or modulus fftshifted FT of the aperture.&lt;br /&gt;&lt;br /&gt;The first one is a square aperture. Its FT is also shown as follows.&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/_kx7Z922tJd0/SlV3QUYYHWI/AAAAAAAAALw/FLLfPDTfS2g/s1600-h/square.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV3QUYYHWI/AAAAAAAAALw/FLLfPDTfS2g/s320/square.bmp" alt="" id="BLOGGER_PHOTO_ID_5356318454059638114" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV3QwKCY_I/AAAAAAAAAL4/oe0A5Jwk9KY/s1600-h/Fsquare.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV3QwKCY_I/AAAAAAAAAL4/oe0A5Jwk9KY/s320/Fsquare.bmp" alt="" id="BLOGGER_PHOTO_ID_5356318461515686898" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be observed that the FT image of a square aperture is similar to the FT image of the circular aperture in Activity 5-A. But instead of airy disks, the FT image above has bright central square maximum and decreasing intensity maxima at its edges.&lt;br /&gt;&lt;br /&gt;A circular annular or "doughnut"aperture is shown below with its FT image.&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/_kx7Z922tJd0/SlV3RItKAzI/AAAAAAAAAMA/BlJtjaS3jrk/s1600-h/annulus.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV3RItKAzI/AAAAAAAAAMA/BlJtjaS3jrk/s320/annulus.bmp" alt="" id="BLOGGER_PHOTO_ID_5356318468105438002" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV3RQFmhQI/AAAAAAAAAMI/ZJVyzQky7ME/s1600-h/Fannulus.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV3RQFmhQI/AAAAAAAAAMI/ZJVyzQky7ME/s320/Fannulus.bmp" alt="" id="BLOGGER_PHOTO_ID_5356318470087017730" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The FT image above is comparable to the airy disks of a circular aperture except that some orders are missing. This is due to the central circular obstacle of the annulus which removes these orders.&lt;br /&gt;&lt;br /&gt;The FT image of a square annular aperture is also examined.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlV3RTHvAqI/AAAAAAAAAMQ/Lv7AmwQ60Hw/s1600-h/square_annulus.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlV3RTHvAqI/AAAAAAAAAMQ/Lv7AmwQ60Hw/s320/square_annulus.bmp" alt="" id="BLOGGER_PHOTO_ID_5356318470901269154" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV3hvun9pI/AAAAAAAAAMY/L9bwrlrcYIw/s1600-h/Fsquare_annulus.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV3hvun9pI/AAAAAAAAAMY/L9bwrlrcYIw/s320/Fsquare_annulus.bmp" alt="" id="BLOGGER_PHOTO_ID_5356318753458484882" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;As expected, the FT image of this aperture type resembles a regular square aperture except that there are also some missing orders like in the circular annular aperture.&lt;br /&gt;&lt;br /&gt;Two horizontal slits which are symmetric with the central horizontal axis are made as the next aperture as follows.&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/_kx7Z922tJd0/SlV3hoVQuRI/AAAAAAAAAMg/Av35fOSUNKU/s1600-h/2slitshor.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV3hoVQuRI/AAAAAAAAAMg/Av35fOSUNKU/s320/2slitshor.bmp" alt="" id="BLOGGER_PHOTO_ID_5356318751473056018" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlV3hwyNZdI/AAAAAAAAAMo/nlVxXPGV1A8/s1600-h/F2slitshor.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlV3hwyNZdI/AAAAAAAAAMo/nlVxXPGV1A8/s320/F2slitshor.bmp" alt="" id="BLOGGER_PHOTO_ID_5356318753741956562" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be seen that the FT image above is vertical with alternating bright and dark fringes. This is due to the cancellation of FT from the left side and right side of the horizontal slits which in turn retains the central maxima in the center. The alternating fringes are effects of destructive interference coming from the 2 horizontal slits.&lt;br /&gt;&lt;br /&gt;The last test aperture created contain 2-small dots symmetric and centered along the horizontal axis.&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/_kx7Z922tJd0/SlV3iGoZuWI/AAAAAAAAAMw/Zx-dobRY774/s1600-h/2dots.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV3iGoZuWI/AAAAAAAAAMw/Zx-dobRY774/s320/2dots.bmp" alt="" id="BLOGGER_PHOTO_ID_5356318759606401378" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV3idlo2QI/AAAAAAAAAM4/IWO4vQtpCCI/s1600-h/F2dots.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV3idlo2QI/AAAAAAAAAM4/IWO4vQtpCCI/s320/F2dots.bmp" alt="" id="BLOGGER_PHOTO_ID_5356318765768825090" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Its FT image is similar to airy disks but vertical alternating bright and dark fringes are observed. This is a consquence of destructive interference from the 2 spots and since they are arranged horizontally, vertical fringes are then produced.&lt;br /&gt;&lt;br /&gt;The following &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code is utilized in this part.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// DFT Apertures 6-A&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Isquare = gray_imread('square.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Fsquare = abs(fftshift(fft2(Isquare)));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(Fsquare, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(Fsquare/max(Fsquare), 'Fsquare.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Iannulus = gray_imread('annulus.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Fannulus = abs(fftshift(fft2(Iannulus)));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(Fannulus, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(Fannulus/max(Fannulus), 'Fannulus.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Isquare_annulus = gray_imread('square_annulus.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Fsquare_annulus = abs(fftshift(fft2(Isquare_annulus)));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(2)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(Fsquare_annulus, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(Fsquare_annulus/max(Fsquare_annulus), 'Fsquare_annulus.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;I2slitshor = gray_imread('2slitshor.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;F2slitshor = abs(fftshift(fft2(I2slitshor)));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(3)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(F2slitshor, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(F2slitshor/max(F2slitshor), 'F2slitshor.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;I2dots = gray_imread('2dots.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;F2dots = abs(fftshift(fft2(I2dots)));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(4)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(F2dots, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(F2dots/max(F2dots), 'F2dots.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Ac&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;t&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;ivi&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;ty&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; 6&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;-B - Anamorphic Pr&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;operty of the Fourier Transform&lt;/span&gt;&lt;br /&gt;This second part tackles the anamorphic properties of the FT for sinusoidal signals which include the ability to distribute the spatial frequency of the input signal, rotation effects, combined effects via multiplication of signals and its linearity.&lt;br /&gt;&lt;br /&gt;A simple sinusoidal signal is initially generated. This is in the form&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/_kx7Z922tJd0/SlXkp57Tt-I/AAAAAAAAAQY/bxrwg4m_5Zc/s1600-h/eq1.bmp"&gt;&lt;img style="cursor: pointer; width: 53px; height: 21px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlXkp57Tt-I/AAAAAAAAAQY/bxrwg4m_5Zc/s320/eq1.bmp" alt="" id="BLOGGER_PHOTO_ID_5356438740402419682" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Different frequencies are tested for further examination. The leftmost image of the sinusoidal signal shown below has f = 2.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV5CLEKaRI/AAAAAAAAANA/4fs2PX2ex8U/s1600-h/sinef2.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV5CLEKaRI/AAAAAAAAANA/4fs2PX2ex8U/s320/sinef2.bmp" alt="" id="BLOGGER_PHOTO_ID_5356320410064021778" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV5CsnE41I/AAAAAAAAANI/ISQRIAaAqhU/s1600-h/Fsinef2.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV5CsnE41I/AAAAAAAAANI/ISQRIAaAqhU/s320/Fsinef2.bmp" alt="" id="BLOGGER_PHOTO_ID_5356320419068830546" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV5C73Yk5I/AAAAAAAAANQ/5a5TORcLCzA/s1600-h/Msinef2.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 158px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV5C73Yk5I/AAAAAAAAANQ/5a5TORcLCzA/s320/Msinef2.bmp" alt="" id="BLOGGER_PHOTO_ID_5356320423163761554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Recall that the FT of a sinusoidal wave signal following the equation above is composed of two dirac deltas which are located at the positive and negative frequency space of the transform. For this case, its frequency is 2 thus the dirac deltas are expected to be located at +2 and -2. The second image above illustrates the 2D FT image of the signal. However, it can be observed that the 3D plot using &lt;span style="font-style: italic;"&gt;mesh&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt;, they are to be found somewhere else. This is because its x and y axes do not contain negative values.&lt;br /&gt;&lt;br /&gt;Next sinusoidal signal has f = 4.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV5DGXvlVI/AAAAAAAAANY/LdXGO6zLQIY/s1600-h/sinef4.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV5DGXvlVI/AAAAAAAAANY/LdXGO6zLQIY/s320/sinef4.bmp" alt="" id="BLOGGER_PHOTO_ID_5356320425983841618" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV5DOEzdpI/AAAAAAAAANg/NwwIUJPh15s/s1600-h/Fsinef4.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV5DOEzdpI/AAAAAAAAANg/NwwIUJPh15s/s320/Fsinef4.bmp" alt="" id="BLOGGER_PHOTO_ID_5356320428051887762" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlV6wxhhCxI/AAAAAAAAANo/-uIUbKFroaE/s1600-h/Msinef4.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 158px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlV6wxhhCxI/AAAAAAAAANo/-uIUbKFroaE/s320/Msinef4.bmp" alt="" id="BLOGGER_PHOTO_ID_5356322310173297426" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Its dirac deltas are then to be found at +4 and -4. Hence, their spacing between each other increases.&lt;br /&gt;&lt;br /&gt;And the following set of images has sinusoidal signal with f = 8.&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/_kx7Z922tJd0/SlV6xBRty2I/AAAAAAAAANw/J9irIuGDjsk/s1600-h/sinef8.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV6xBRty2I/AAAAAAAAANw/J9irIuGDjsk/s320/sinef8.bmp" alt="" id="BLOGGER_PHOTO_ID_5356322314401991522" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV6xoYbdrI/AAAAAAAAAN4/_3dfXNvZGMw/s1600-h/Fsinef8.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV6xoYbdrI/AAAAAAAAAN4/_3dfXNvZGMw/s320/Fsinef8.bmp" alt="" id="BLOGGER_PHOTO_ID_5356322324899133106" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV6x_0M-EI/AAAAAAAAAOA/1N6eL3nYDZw/s1600-h/Msinef8.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 158px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV6x_0M-EI/AAAAAAAAAOA/1N6eL3nYDZw/s320/Msinef8.bmp" alt="" id="BLOGGER_PHOTO_ID_5356322331189639234" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Expectedly, the dirac deltas are farther from each other since they have frequency of 8.&lt;br /&gt;&lt;br /&gt;The next thing done is adding a positive constant bias to the sinusoidal signal. For this case 2 is added and the 2D image of the input signal is shown as follows. Note that from here, the following signals have frequency equal to 8.&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/_kx7Z922tJd0/SlV6xzXmfLI/AAAAAAAAAOI/MRy6SG5otCg/s1600-h/zbias.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV6xzXmfLI/AAAAAAAAAOI/MRy6SG5otCg/s320/zbias.bmp" alt="" id="BLOGGER_PHOTO_ID_5356322327848451250" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV8Np9F1lI/AAAAAAAAAOQ/7LeW9R0OvwE/s1600-h/sinebias.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV8Np9F1lI/AAAAAAAAAOQ/7LeW9R0OvwE/s320/sinebias.bmp" alt="" id="BLOGGER_PHOTO_ID_5356323905869305426" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV8NxajySI/AAAAAAAAAOY/4TNdggQbGzU/s1600-h/Msinebias.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 158px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV8NxajySI/AAAAAAAAAOY/4TNdggQbGzU/s320/Msinebias.bmp" alt="" id="BLOGGER_PHOTO_ID_5356323907871951138" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The 2D FT image can be observed having a central bright spot and two fainter ones symmetric to the center. The added positive constant bias is the cause of the additional central bright spot. This is because the FT of a constant is a dirac delta centered at the origin. Also, since the amplitude of the sinusoid is 1 which is less than the positive constant bias 2, then the intensities coming from the sinusoid are less than the intensity of the central spot. The 3D plot further illustrates the effect of the positive constant bias.&lt;br /&gt;In real applications, like in getting interferogram which has sinusoidal signal, its actual frequencies can easily be extracted from applying FT to it. If the signal contains non-constant bias example having very low frequency sinusoid, the frequencies of the interferogram can be acquired by subtracting this non-constant bias from the signal before applying FT or based from the FT, the dirac deltas that are close to each other correspond to the non-constant bias since this has very low frequency and what remain are the frequency contents of the interferogram.&lt;br /&gt;&lt;br /&gt;The sinusoidal signal is then made to have phase angles theta in the x and y coordinates. This is in the form&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/_kx7Z922tJd0/SlXkp9byryI/AAAAAAAAAQg/vkLqUrY1Wic/s1600-h/eq2.bmp"&gt;&lt;img style="cursor: pointer; width: 142px; height: 21px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlXkp9byryI/AAAAAAAAAQg/vkLqUrY1Wic/s320/eq2.bmp" alt="" id="BLOGGER_PHOTO_ID_5356438741343973154" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;First, a 30-degree angle is used.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV8ONt76mI/AAAAAAAAAOg/IGB6K5h1s9k/s1600-h/zrot30.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlV8ONt76mI/AAAAAAAAAOg/IGB6K5h1s9k/s320/zrot30.bmp" alt="" id="BLOGGER_PHOTO_ID_5356323915469417058" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlV8OSF7JqI/AAAAAAAAAOo/jZy_3X8Mcx8/s1600-h/sinerot30.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlV8OSF7JqI/AAAAAAAAAOo/jZy_3X8Mcx8/s320/sinerot30.bmp" alt="" id="BLOGGER_PHOTO_ID_5356323916643772066" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV8Oq9wMEI/AAAAAAAAAOw/wudSPa4wXQU/s1600-h/Msinerot30.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 158px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV8Oq9wMEI/AAAAAAAAAOw/wudSPa4wXQU/s320/Msinerot30.bmp" alt="" id="BLOGGER_PHOTO_ID_5356323923320385602" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The leftmost image above is the 2D image of the rotated sinusoidal signal. The next two are  the 2D and 3D FT images respectively. The dirac deltas are rotated by 60 degrees or 90-30 degrees clockwise with respect to the central vertical axis. This is because our reference axis is the central vertical one.&lt;br /&gt;&lt;br /&gt;I tested for the angle of 60 degrees.&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/_kx7Z922tJd0/SlWM7Gsx2pI/AAAAAAAAAQA/8WaGwgYf4fU/s1600-h/zrot60.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlWM7Gsx2pI/AAAAAAAAAQA/8WaGwgYf4fU/s320/zrot60.bmp" alt="" id="BLOGGER_PHOTO_ID_5356342278865672850" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlWM7aGtzuI/AAAAAAAAAQI/Ou6__xGzZ_4/s1600-h/sinerot60.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlWM7aGtzuI/AAAAAAAAAQI/Ou6__xGzZ_4/s320/sinerot60.bmp" alt="" id="BLOGGER_PHOTO_ID_5356342284074733282" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlWM7hQO-SI/AAAAAAAAAQQ/LbGhaxW3pV4/s1600-h/Msinerot60.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 158px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlWM7hQO-SI/AAAAAAAAAQQ/LbGhaxW3pV4/s320/Msinerot60.bmp" alt="" id="BLOGGER_PHOTO_ID_5356342285993703714" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Indeed, the dirac deltas rotated by 30 degrees or 90-30 degrees with respect to the central vertical axis but now in the counterclockwise direction.&lt;br /&gt;&lt;br /&gt;Another type of sinusoidal signal investigated is a combination of two sinusoids multiplied to each other. One is running along the x direction while the other in y. This is in the form&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/_kx7Z922tJd0/SlXkqOjqJJI/AAAAAAAAAQo/rt1J4ia9GSw/s1600-h/eq3.bmp"&gt;&lt;img style="cursor: pointer; width: 142px; height: 21px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlXkqOjqJJI/AAAAAAAAAQo/rt1J4ia9GSw/s320/eq3.bmp" alt="" id="BLOGGER_PHOTO_ID_5356438745940370578" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Based from the equation above, the sinusoids have frequencies equal to 4. The result is illustrated by the images as follows.&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/_kx7Z922tJd0/SlV-B9EKQ1I/AAAAAAAAAO4/lm0a__Mxp0I/s1600-h/ztimes.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV-B9EKQ1I/AAAAAAAAAO4/lm0a__Mxp0I/s320/ztimes.bmp" alt="" id="BLOGGER_PHOTO_ID_5356325903864054610" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV-CAr1GlI/AAAAAAAAAPA/Uv0OQatpI6Y/s1600-h/sinetimes.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV-CAr1GlI/AAAAAAAAAPA/Uv0OQatpI6Y/s320/sinetimes.bmp" alt="" id="BLOGGER_PHOTO_ID_5356325904835746386" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV-CtjA8zI/AAAAAAAAAPI/h8JlkRtlRPU/s1600-h/Msinetimes.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 158px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV-CtjA8zI/AAAAAAAAAPI/h8JlkRtlRPU/s320/Msinetimes.bmp" alt="" id="BLOGGER_PHOTO_ID_5356325916878369586" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be observed that 4 dirac deltas are produced which are symmetric about the center. 2 dirac deltas come from the sinusoid running in the x direction and the other two from the sinusoid running in y.&lt;br /&gt;&lt;br /&gt;Lastly, the combined sinusoids are added with rotated sinusoidal signal. I have added the rotated sinusoid with 30 degrees and the images below are obtained.&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/_kx7Z922tJd0/SlV-C85mwZI/AAAAAAAAAPQ/7PW4bNcS0Mw/s1600-h/ztimesplusrot.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlV-C85mwZI/AAAAAAAAAPQ/7PW4bNcS0Mw/s320/ztimesplusrot.bmp" alt="" id="BLOGGER_PHOTO_ID_5356325920999653778" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV-Dd4FmRI/AAAAAAAAAPY/Z8OCP7fUDyk/s1600-h/sinetimesplusrot.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlV-Dd4FmRI/AAAAAAAAAPY/Z8OCP7fUDyk/s320/sinetimesplusrot.bmp" alt="" id="BLOGGER_PHOTO_ID_5356325929851656466" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlWL18TblPI/AAAAAAAAAPg/6guqlyfHYTg/s1600-h/Msinetimesplusrot.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 158px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlWL18TblPI/AAAAAAAAAPg/6guqlyfHYTg/s320/Msinetimesplusrot.bmp" alt="" id="BLOGGER_PHOTO_ID_5356341090664027378" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Before plotting the FT image, I have anticipated that the dirac deltas coming from the rotated sinusoid will just add to the 4 dirac deltas from the combined sinusoids. Based from the 2D and 3D images, my prediction is indeed correct.&lt;br /&gt;&lt;br /&gt;I have added another rotated sinusoid with an angle of 60 degrees which results to the following images.&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/_kx7Z922tJd0/SlWL2dCJhrI/AAAAAAAAAPo/MGOwiTSXZfE/s1600-h/ztimesplusrot2.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlWL2dCJhrI/AAAAAAAAAPo/MGOwiTSXZfE/s320/ztimesplusrot2.bmp" alt="" id="BLOGGER_PHOTO_ID_5356341099449910962" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlWL2l6YJAI/AAAAAAAAAPw/nbKA2Z764UE/s1600-h/sinetimesplusrot2.bmp"&gt;&lt;img style="cursor: pointer; width: 100px; height: 100px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlWL2l6YJAI/AAAAAAAAAPw/nbKA2Z764UE/s320/sinetimesplusrot2.bmp" alt="" id="BLOGGER_PHOTO_ID_5356341101833233410" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlWL2y2SpbI/AAAAAAAAAP4/7yFnTcfeQRo/s1600-h/Msinetimesplusrot2.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 158px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlWL2y2SpbI/AAAAAAAAAP4/7yFnTcfeQRo/s320/Msinetimesplusrot2.bmp" alt="" id="BLOGGER_PHOTO_ID_5356341105305757106" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Based from the images above, it can be concluded that FT has the property of linearity, that is the superposition of signals correspond to the superposition of their transforms.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code below is utilized in the second part.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// DFT Anamorphic F 6-B&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;nx = 100; ny = 100;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;x = linspace(-1,1,nx);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;y = linspace(-1,1,ny);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[X,Y] = ndgrid(x,y);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;f = 8&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;z = sin(2*%pi*f*X);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(z, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(z/max(z), 'sinef8.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;sine = abs(fftshift(fft2(z)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(sine, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//mesh(sine);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(sine/max(sine), 'Fsinef2.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//Constant Bias&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;c = 2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;zbias = c + sin(2*%pi*f*X);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(zbias, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(zbias/max(zbias), 'zbias.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;sinebias = abs(fftshift(fft2(zbias)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(3)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(sinebias, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(sinebias/max(sinebias), 'sinebias.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//mesh(sinebias);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Rotated Sinusoidal Signal&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;theta = 30;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;zrot = sin(2*%pi*f*(Y*sin(theta) + X*cos(theta)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(4);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(zrot, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(zrot/max(zrot), 'zrot30.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;sinerot = abs(fftshift(fft2(zrot)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(5);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(sinerot, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//mesh(sinerot);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(sinerot/max(sinerot), 'sinerot30.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Multiplied Sinusoidal Signals&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;ztimes = sin(2*%pi*4*X).*sin(2*%pi*4*Y);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(6);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(ztimes, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(ztimes/max(ztimes), 'ztimes.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;sinetimes = abs(fftshift(fft2(ztimes)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(7);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(sinetimes, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//mesh(sinetimes);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(sinetimes/max(sinetimes), 'sinetimes.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Multiplied Sinusoidal Signals Plus Rotated Sinusoidal Signal(s)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;theta2 = 60;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;ztimesplusrot = sin(2*%pi*4*X).*sin(2*%pi*4*Y) + sin(2*%pi*f*(Y*sin(theta) + X*cos(theta))) + sin(2*%pi*f*(Y*sin(theta2) + X*cos(theta2)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(8);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(ztimesplusrot, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(ztimesplusrot/max(ztimesplusrot), 'ztimesplusrot.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;sinetimesplusrot = abs(fftshift(fft2(ztimesplusrot)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(9);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(sinetimesplusrot, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//mesh(sinetimesplusrot);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(sinetimesplusrot/max(sinetimesplusrot), 'sinetimesplusrot.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I give myself a grade of 10/10 since I have successfully accomplished all instructions of this activity and I have gained better understanding of the properties of the 2D Fourier transform.&lt;br /&gt;&lt;br /&gt;Thanks to &lt;span style="font-style: italic;"&gt;mesh&lt;/span&gt;, a special 3D plotting function in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; which is introduced to me by Raffy, makes better illustration of Fourier transforms of different sinusoidal signals. This activity is also made successful with collaborating with Gary.&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/1657424262821979330-8139782485294997790?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/8139782485294997790/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-6-properties-of-2d-fourier.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/8139782485294997790'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/8139782485294997790'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-6-properties-of-2d-fourier.html' title='Activity 6 - Properties of the 2D Fourier Transform'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_kx7Z922tJd0/SlV3QUYYHWI/AAAAAAAAALw/FLLfPDTfS2g/s72-c/square.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-7948972952150959579</id><published>2009-07-07T09:03:00.040+08:00</published><updated>2009-07-09T17:21:43.548+08:00</updated><title type='text'>Activity 5 - Fourier Transform Model of Image Formation</title><content type='html'>This activity is composed of four major parts to which we are introduced to the fourier transform image model of image formation.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 5-&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;A - F&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;a&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;m&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;iliarization with Discrete FFT&lt;/span&gt;&lt;br /&gt;Using the 2-dimensional discrete fast fourier transform (FFT) function of &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; which is &lt;span style="font-style: italic;"&gt;fft2&lt;/span&gt;, we are familiarized with what it does when applied to images.&lt;br /&gt;The first set of pictures shown below illustrates the result of discrete FFT in an image. Initially, a 128x128 image of a white circle which is leftmost picture with black background is made in &lt;span style="font-style: italic;"&gt;Paint&lt;/span&gt;. The image is then read and converted to grayscale-type where &lt;span style="font-style: italic;"&gt;fft2&lt;/span&gt; is applied. The effect of &lt;span style="font-style: italic;"&gt;fft2&lt;/span&gt; to the circle is represented by the second image. The third one shows the result when the function &lt;span style="font-style: italic;"&gt;fftshift&lt;/span&gt; is used on the second image. The rightmost image illustrates the inverse FFT of the FFT of the first image equivalently applying &lt;span style="font-style: italic;"&gt;fft2&lt;/span&gt; twice.&lt;br /&gt;It is important that the FFT images are applied by the &lt;span style="font-style: italic;"&gt;abs&lt;/span&gt; function which computes the modulus of complex numbers that &lt;span style="font-style: italic;"&gt;fft2&lt;/span&gt; returns and so it will give intensity values.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlNdS5geCBI/AAAAAAAAAJA/7iGvFSFd_N8/s1600-h/circle_paint.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlNdS5geCBI/AAAAAAAAAJA/7iGvFSFd_N8/s320/circle_paint.bmp" alt="" id="BLOGGER_PHOTO_ID_5355726961129687058" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlNc6A1sNMI/AAAAAAAAAIo/Bb_gRCcmyt4/s1600-h/circlefft.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlNc6A1sNMI/AAAAAAAAAIo/Bb_gRCcmyt4/s320/circlefft.bmp" alt="" id="BLOGGER_PHOTO_ID_5355726533601014978" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNdCwqb-sI/AAAAAAAAAIw/DZw9K3jHbBQ/s1600-h/circlefftshift.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNdCwqb-sI/AAAAAAAAAIw/DZw9K3jHbBQ/s320/circlefftshift.bmp" alt="" id="BLOGGER_PHOTO_ID_5355726683877669570" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlNdKQbH8OI/AAAAAAAAAI4/Xi-hy3l9P-k/s1600-h/circleifft.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlNdKQbH8OI/AAAAAAAAAI4/Xi-hy3l9P-k/s320/circleifft.bmp" alt="" id="BLOGGER_PHOTO_ID_5355726812662460642" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The second picture is the effect of the first application of &lt;span style="font-style: italic;"&gt;fft2&lt;/span&gt; since the white circle is divided into four being distributed on the four quadrant corners. The third one represents an image of airy disks which is the consequence of &lt;span style="font-style: italic;"&gt;fftshift&lt;/span&gt;. This produces the diffraction pattern of a circular aperture where Fourier Transform is involved. The pattern is more apparent because I have made a small circle. Finally, when &lt;span style="font-style: italic;"&gt;fft2&lt;/span&gt; is used twice on the first image, it comes back to its original form knowing actually it is already inverted but of course is not obvious here since the object is a circle.&lt;br /&gt;&lt;br /&gt;For other illustrations of the functions &lt;span style="font-style: italic;"&gt;fft2&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;fftshift&lt;/span&gt; and the inverse FFT on an image, a white letter A is created with black background again in &lt;span style="font-style: italic;"&gt;Paint&lt;/span&gt;. The following images summarize the result.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNdjrs4F7I/AAAAAAAAAJI/hcj_NTfOSeE/s1600-h/Ainv.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNdjrs4F7I/AAAAAAAAAJI/hcj_NTfOSeE/s320/Ainv.bmp" alt="" id="BLOGGER_PHOTO_ID_5355727249481406386" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNdrUMRMOI/AAAAAAAAAJQ/cl7v5zjua_Q/s1600-h/Afft.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNdrUMRMOI/AAAAAAAAAJQ/cl7v5zjua_Q/s320/Afft.bmp" alt="" id="BLOGGER_PHOTO_ID_5355727380609577186" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlNdvgYH_TI/AAAAAAAAAJY/HPuVV27O9oI/s1600-h/Afftshift.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlNdvgYH_TI/AAAAAAAAAJY/HPuVV27O9oI/s320/Afftshift.bmp" alt="" id="BLOGGER_PHOTO_ID_5355727452600007986" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNd0KgSDOI/AAAAAAAAAJg/7ol5dYpESKo/s1600-h/Aifft.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNd0KgSDOI/AAAAAAAAAJg/7ol5dYpESKo/s320/Aifft.bmp" alt="" id="BLOGGER_PHOTO_ID_5355727532627987682" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The first one is the original created image. The second is the first &lt;span style="font-style: italic;"&gt;fft2&lt;/span&gt; aplication. Next is the &lt;span style="font-style: italic;"&gt;fftshift&lt;/span&gt;ed image of the second and the last one illustrates the inverse FFT which indeed inverts the original image.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code below is utilized for Activity 5-A.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// DFFT Circle, 5&lt;/span&gt;&lt;span style="font-size:78%;"&gt;-A&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;I = imread('circle_paint.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Igray = im2gray(I);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;FIgray = fft2(Igray);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;circlefft = abs(&lt;/span&gt;&lt;span style="font-size:78%;"&gt;FIgray);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(circlefft, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(circlefft/max(cir&lt;/span&gt;&lt;span style="font-size:78%;"&gt;clefft), 'circlefft.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;circlefftshift = fftshift(abs(FIgray));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(circlefftshift, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(&lt;/span&gt;&lt;span style="font-size:78%;"&gt;circ&lt;/span&gt;&lt;span style="font-size:78%;"&gt;lefftshift/max(circlefftshift), 'circlefftshift.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;circleifft = abs(fft&lt;/span&gt;&lt;span style="font-size:78%;"&gt;2(fft2(Igray)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(circleifft, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(circleifft/max(circleifft), 'circleifft.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// DFFT Letter A, 5-A&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a = imread('A.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Agray = im2gray(a);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;A = 1 - Agray;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(A, 'Ainv.bmp')&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;FAgray = fft&lt;/span&gt;&lt;span style="font-size:78%;"&gt;2(A);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Afft = abs(FAgray);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(Afft, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(Afft/max(Afft), 'Afft.bmp'&lt;/span&gt;&lt;span style="font-size:78%;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(4);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Afftshift = fftshift&lt;/span&gt;&lt;span style="font-size:78%;"&gt;(abs(FAgray));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(Afftshift, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(Afftshift/max(Afftshift), 'Afftshift.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(5);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Aifft = abs(fft2(fft2(A)));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(Aifft, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite&lt;/span&gt;&lt;span style="font-size:78%;"&gt;(Aifft/max(Aifft), 'Aifft.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 5-B - Simulation of an Imaging Device&lt;/span&gt;&lt;br /&gt;This next part involves convolution which can simulate an imaging device. Here, a circular aperture is used. VIP with large Arial font is created in &lt;span style="font-style: italic;"&gt;Paint&lt;/span&gt;. The rightmost image below illustrates the consequence of convolution on the circular aperture and VIP.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNear5sWmI/AAAAAAAAAJo/l0DxF_5Po0g/s1600-h/circle_paint.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNear5sWmI/AAAAAAAAAJo/l0DxF_5Po0g/s320/circle_paint.bmp" alt="" id="BLOGGER_PHOTO_ID_5355728194427968098" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlNelw5hZKI/AAAAAAAAAJw/slWxhUiMiYI/s1600-h/vipgrayinv.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlNelw5hZKI/AAAAAAAAAJw/slWxhUiMiYI/s320/vipgrayinv.bmp" alt="" id="BLOGGER_PHOTO_ID_5355728384747988130" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlNevi5jBOI/AAAAAAAAAJ4/8k3aPk8QZMg/s1600-h/Aconv.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlNevi5jBOI/AAAAAAAAAJ4/8k3aPk8QZMg/s320/Aconv.bmp" alt="" id="BLOGGER_PHOTO_ID_5355728552788690146" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be observed above that the convolved image is inverted and not clear. The inversion of VIP is due to the application of inverse FFT to the convolution. The aperture is small hence the object is not well-reconstructed.&lt;br /&gt;&lt;br /&gt;Now, let's see the effect of a larger radius circular aperture.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlNfI8SahHI/AAAAAAAAAKA/ysZOq7wxE3Y/s1600-h/circlebig.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlNfI8SahHI/AAAAAAAAAKA/ysZOq7wxE3Y/s320/circlebig.bmp" alt="" id="BLOGGER_PHOTO_ID_5355728989100606578" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlNfylKXuhI/AAAAAAAAAKY/u5vRIbD2K-0/s1600-h/vipgrayinv.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlNfylKXuhI/AAAAAAAAAKY/u5vRIbD2K-0/s320/vipgrayinv.bmp" alt="" id="BLOGGER_PHOTO_ID_5355729704447359506" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlNfSqnJCbI/AAAAAAAAAKQ/hXOkpYJUg_s/s1600-h/Aconvbig.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlNfSqnJCbI/AAAAAAAAAKQ/hXOkpYJUg_s/s320/Aconvbig.bmp" alt="" id="BLOGGER_PHOTO_ID_5355729156154395058" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Obviously, VIP is still inverted but it is now clearer than the previous aperture. However, the intensity is not the same as the original VIP which proves that the reconstruction in imaging systems is not perfect.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code below is utilized in this part.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Convolution 5-B&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;vip = imread('vip.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;c = imread('circle_paint.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;cgray = im2gray(c);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;vipgray = i&lt;/span&gt;&lt;span style="font-size:78%;"&gt;m2gray(vip);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Fr = fftshift(&lt;/span&gt;&lt;span style="font-size:78%;"&gt;cgray);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Fvip = fft2(1 - vipgray);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(1 - vipgray, 'vipgrayinv.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;FRA = Fr.*(Fvip);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;IRA = fft2(FRA); //&lt;/span&gt;&lt;span style="font-size:78%;"&gt;inverse FFT&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;FImage = abs(IRA);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(7);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(FImage, []);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(FImage/max(FImage), 'Aconv.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 5-C - Templa&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;te Matching using Correlation&lt;/span&gt;&lt;br /&gt;The third part matches a particular letter in a sentence using correlation. The image of a sentence at the leftmost side shown below is created in &lt;span style="font-style: italic;"&gt;Paint&lt;/span&gt;. This has an Arial font and written in capital letters. Next, an image for letter A which is the second image below is made considering that it is also capitalized and has the same font type and size as used in the sentence. Correlation works when the Fourier transform of the letter A image is multiplied element-by-element to the conjugate of the Fourier transform of the text image. Then, the inverse FFT is applied.&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/_kx7Z922tJd0/SlNgH7NEYyI/AAAAAAAAAKw/sHAvNfSprBA/s1600-h/raingrayinv.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlNgH7NEYyI/AAAAAAAAAKw/sHAvNfSprBA/s320/raingrayinv.bmp" alt="" id="BLOGGER_PHOTO_ID_5355730071141507874" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNgAazBF1I/AAAAAAAAAKo/p-l5mHbfuQk/s1600-h/a_raingray.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNgAazBF1I/AAAAAAAAAKo/p-l5mHbfuQk/s320/a_raingray.bmp" alt="" id="BLOGGER_PHOTO_ID_5355729942183221074" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlNgNzoNF6I/AAAAAAAAAK4/YG6gNnLM-eo/s1600-h/correlate.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlNgNzoNF6I/AAAAAAAAAK4/YG6gNnLM-eo/s320/correlate.bmp" alt="" id="BLOGGER_PHOTO_ID_5355730172187056034" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The third image illustrates the correlated image of the text. It can be observed that the letter A's of the text have bright spots which indicate the letter A is indeed matched with the text using correlation. The similarity of the font type and size of letter A is very important for better correlation so that the Fourier transform of A best matches the incidence of this same transform from the text.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code below is utilized in Activity 5-C.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Correlation 5-C&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rain = imread('rain.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a_rain = imread('a_rain.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;raingray = im2gray(rain);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a_raingray = im2gray(a_rain);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rainf = fft2(1 - raingray);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(1 - raingray, 'raingrayinv.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a_rainf = fft2(1 - a_raingray);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(1 - a_raingray, 'a_raingray.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;correlate = abs(fftshift(fft2(a_rainf.*(conj(rainf)))));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//scf(8);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(correlate, [&lt;/span&gt;&lt;span style="font-size:78%;"&gt;]);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(correlate/max(correlate), 'correlate.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 5-&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;D - E&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;dge De&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;tection using the Convolution Integral&lt;/span&gt;&lt;br /&gt;The last part has the same algorithm as in the previous part but this time a special function in Scilab which is &lt;span style="font-style: italic;"&gt;imcorrcoef&lt;/span&gt; is used and edges are matched here with a given pattern. Again, the image of VIP is used for edge detection. Different edge patterns which are 3x3 matrix are created for matching with VIP. It is important the sum of the matrix elements is equal to zero. The activity suggested the edge patterns to be used involve horizontal, vertical and spot edge pattern. These are shown as follows which are arranged respectively.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlPnYT9wnfI/AAAAAAAAALY/9LrISmBTlwk/s1600-h/horizontal+edge.bmp"&gt;&lt;img style="cursor: pointer; width: 88px; height: 64px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlPnYT9wnfI/AAAAAAAAALY/9LrISmBTlwk/s320/horizontal+edge.bmp" alt="" id="BLOGGER_PHOTO_ID_5355878786735840754" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlPncmJwqzI/AAAAAAAAALg/cw-2ZC2QcAs/s1600-h/vertical+edge.bmp"&gt;&lt;img style="cursor: pointer; width: 80px; height: 64px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlPncmJwqzI/AAAAAAAAALg/cw-2ZC2QcAs/s320/vertical+edge.bmp" alt="" id="BLOGGER_PHOTO_ID_5355878860337490738" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlPnfzhYcUI/AAAAAAAAALo/ZrV_frEhREY/s1600-h/spot+edge.bmp"&gt;&lt;img style="cursor: pointer; width: 88px; height: 64px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlPnfzhYcUI/AAAAAAAAALo/ZrV_frEhREY/s320/spot+edge.bmp" alt="" id="BLOGGER_PHOTO_ID_5355878915465834818" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The set of images below illustrates the result of edge detection.&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/_kx7Z922tJd0/SlNfOLrcKuI/AAAAAAAAAKI/cak8w9i7ufU/s1600-h/vipgrayinv.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlNfOLrcKuI/AAAAAAAAAKI/cak8w9i7ufU/s320/vipgrayinv.bmp" alt="" id="BLOGGER_PHOTO_ID_5355729079131450082" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlNg9dDKa_I/AAAAAAAAALA/AtlowDTSL34/s1600-h/vip_edge1.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlNg9dDKa_I/AAAAAAAAALA/AtlowDTSL34/s320/vip_edge1.bmp" alt="" id="BLOGGER_PHOTO_ID_5355730990759832562" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNhB8Iv0yI/AAAAAAAAALI/k7PI4fQ6RJ0/s1600-h/vip_edge2.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlNhB8Iv0yI/AAAAAAAAALI/k7PI4fQ6RJ0/s320/vip_edge2.bmp" alt="" id="BLOGGER_PHOTO_ID_5355731067824231202" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SlNhGcDqrxI/AAAAAAAAALQ/J4wV7W9Fb2c/s1600-h/vip_edge3.bmp"&gt;&lt;img style="cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlNhGcDqrxI/AAAAAAAAALQ/J4wV7W9Fb2c/s320/vip_edge3.bmp" alt="" id="BLOGGER_PHOTO_ID_5355731145112334098" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The first image is the original VIP. Next is the result of a horizontal edge pattern which makes the vertical edges to disappear and generates horizontal bright stripes. The third is based from a vertical edge pattern apparently producing vertical stripes and removing horizontal edges. The last image uses a spot edge pattern where no edges are erased instead they are brightly highlighted.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code below is utilized in this last part.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Edge Detection 5-D&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;pattern1 = [-1 -1 -1; 2 2 2; -1 -1 -1];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;pattern2 = [-1 2 -1; -1 2 -1; -1 2 -1];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;pattern3 = [-1 -1 -1; -1 8 -1; -1 -1 -1];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;vip_edge = imcorrcoef(1 - vipgray, pattern3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imshow(vip_edge/max(vip_edge));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(vip_edge/max(vip_edge), 'vip_edge3.bmp');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Because I have successfully fulfilled all the objectives and procedures to each part of this activity, I grade myself 10/10.&lt;br /&gt;&lt;br /&gt;This activity is completed through collaborating with Gary and Raffy.&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/1657424262821979330-7948972952150959579?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/7948972952150959579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.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/1657424262821979330/posts/default/7948972952150959579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/7948972952150959579'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/07/activity-5-fourier-transform-model-of.html' title='Activity 5 - Fourier Transform Model of Image Formation'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_kx7Z922tJd0/SlNdS5geCBI/AAAAAAAAAJA/7iGvFSFd_N8/s72-c/circle_paint.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-7878338915059998963</id><published>2009-06-30T10:34:00.048+08:00</published><updated>2009-10-08T16:49:37.293+08:00</updated><title type='text'>Activity 4 - Enhancement by Histogram Manipulation</title><content type='html'>&lt;div style="text-align: justify;"&gt;The program &lt;span style="font-style: italic;"&gt;Adobe Photos&lt;/span&gt;&lt;span style="font-style: italic;"&gt;hop&lt;/span&gt; is very well-known for easy handling of various images like adjusting the contrast, adding special effects, among many more. In this activity, we are rather to enhance an image through manipulating the histogram of the image's grayscale values using &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;The first step of course is to find an image which has poor contrast. I have found this image from the web as shown below.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlBpAthR7cI/AAAAAAAAAGg/s239gvqIcsQ/s1600-h/poor_contrast.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 153px; height: 256px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlBpAthR7cI/AAAAAAAAAGg/s239gvqIcsQ/s320/poor_contrast.jpg" alt="" id="BLOGGER_PHOTO_ID_5354895417883618754" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Source: &lt;span style="font-style: italic;"&gt;http://www.american-indian-artwork.com/photograph-restoration-tutorial.htm&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The image to be enhanced is strictly a grayscale type which possesses 0 to 255 grayscale values. The graylevel probability distribution function (PDF) of this image is what we manipulated using two main methods: first is through the backprojection using its original cumulative probability function (CDF) and the other is through backprojection via a desired CDF.&lt;br /&gt;&lt;br /&gt;The PDF of my image under enhancement is illustrated below. The CDF is then acquired through the cumulative sum of the PDF. The PDF and CDF of the original image are shown as follows.&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/_kx7Z922tJd0/SlB8Gb-NNaI/AAAAAAAAAGw/yuOHXqa0B0U/s1600-h/PDF+orig.jpg"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlB8Gb-NNaI/AAAAAAAAAGw/yuOHXqa0B0U/s320/PDF+orig.jpg" alt="" id="BLOGGER_PHOTO_ID_5354916406973248930" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlB8MlxydBI/AAAAAAAAAG4/3od9g6gd3iQ/s1600-h/CDF+orig.jpg"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlB8MlxydBI/AAAAAAAAAG4/3od9g6gd3iQ/s320/CDF+orig.jpg" alt="" id="BLOGGER_PHOTO_ID_5354916512684733458" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Based from its histogram, the image really has a poor contarst because the grayscale values are concentrated in the region near 0 or pure black.&lt;br /&gt;&lt;br /&gt;In the backprojection of the grayscale values through the original CDF of the image, each pixel value is corresponded to its y-value in the original CDF and replaced by it. The effect of this first method is illustrated below.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlB7N9TZDHI/AAAAAAAAAGo/oWfjX0wKvWI/s1600-h/good_contrast_linear.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 153px; height: 256px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlB7N9TZDHI/AAAAAAAAAGo/oWfjX0wKvWI/s320/good_contrast_linear.jpg" alt="" id="BLOGGER_PHOTO_ID_5354915436667931762" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The image is excellently enhanced in this method because it results to a more recognizable image where details are not sacrificed.&lt;br /&gt;&lt;br /&gt;Then the PDF and CDF of this enhanced image are the following.&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/_kx7Z922tJd0/SlB9Xja0XyI/AAAAAAAAAHA/Ovq_6IyrvnI/s1600-h/PDF+linear.jpg"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlB9Xja0XyI/AAAAAAAAAHA/Ovq_6IyrvnI/s320/PDF+linear.jpg" alt="" id="BLOGGER_PHOTO_ID_5354917800541708066" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlB9bqeyGXI/AAAAAAAAAHI/krKDEpPruz0/s1600-h/CDF+linear.jpg"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlB9bqeyGXI/AAAAAAAAAHI/krKDEpPruz0/s320/CDF+linear.jpg" alt="" id="BLOGGER_PHOTO_ID_5354917871156861298" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It can be observed from the enhanced CDF that it follows a staright line (y = x) thus distributing the pixel values from 0 to 255 linearly in the same form of the original CDF.&lt;br /&gt;&lt;br /&gt;The second method which is the backprojection using a desired CDF is done initially by finding the original CDF value from the pixel grayscale. Then, this is traced in the value of the desired CDF. Finally, this pixel value is replaced by the pixel value at the desired CDF having the same CDF value. The same algorithm is applied to all the pixel values of the original CDF.&lt;br /&gt;&lt;br /&gt;For a simple case, I used a parabolic function y = x^2 as a desired CDF. The effect of this CDF to the original image is shown below.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlB-D-KhtdI/AAAAAAAAAHQ/evFycMvUQTs/s1600-h/good_parabola.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 153px; height: 256px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlB-D-KhtdI/AAAAAAAAAHQ/evFycMvUQTs/s320/good_parabola.jpg" alt="" id="BLOGGER_PHOTO_ID_5354918563635377618" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;It can be observed that the contrast enhancement thorugh a parabolic CDF is somehow not applicable for this image since it is too bright.&lt;br /&gt;&lt;br /&gt;The following are the PDF and CDF of this enhanced image via a parabolic CDF.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlB_VAKgLEI/AAAAAAAAAHY/N6cLhoD4zJw/s1600-h/PDF+parabola.jpg"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlB_VAKgLEI/AAAAAAAAAHY/N6cLhoD4zJw/s320/PDF+parabola.jpg" alt="" id="BLOGGER_PHOTO_ID_5354919955741551682" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlB_bYF2cBI/AAAAAAAAAHg/lcHyH2gvqlw/s1600-h/CDF+parabola.jpg"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlB_bYF2cBI/AAAAAAAAAHg/lcHyH2gvqlw/s320/CDF+parabola.jpg" alt="" id="BLOGGER_PHOTO_ID_5354920065243705362" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The PDF is similar to the first method except that in this parabolic CDF, the histogram is not well spreaded over the grayscale values. Apparently, the CDF follows the contour of a parabola which in turn make the image highly contrasted compared to the first method.&lt;br /&gt;&lt;br /&gt;I have also tried when a placed a linear function (y = x). I anticipate that this will result to the first method. And I am correct. The first algorithm is exactly doing the second method but with a linear CDF.&lt;br /&gt;&lt;br /&gt;Finally, using the same second method, I replaced the parabolic function into a nonlinear CDF which mimicks a nonlinear response like the human eye. Here, I have chosen a logarithmic one which is y = log(x).&lt;br /&gt;&lt;br /&gt;The effect is as follows.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlCBXsYNIYI/AAAAAAAAAHo/OE-0_RiFmA8/s1600-h/good_nonlinear_log.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 153px; height: 256px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlCBXsYNIYI/AAAAAAAAAHo/OE-0_RiFmA8/s320/good_nonlinear_log.jpg" alt="" id="BLOGGER_PHOTO_ID_5354922200993177986" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Some details of the image are lost in this kind of contrast enhacement which implies that the nonlinear CDF is not applicable for my image.&lt;br /&gt;&lt;br /&gt;Meanwhile, its PDF and CDF are illustrated below.&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/_kx7Z922tJd0/SlCCGYcZoiI/AAAAAAAAAHw/fY4nw_NQ3xQ/s1600-h/PDF+nonlinear+log.jpg"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SlCCGYcZoiI/AAAAAAAAAHw/fY4nw_NQ3xQ/s320/PDF+nonlinear+log.jpg" alt="" id="BLOGGER_PHOTO_ID_5354923003095917090" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlCCKYAkD1I/AAAAAAAAAH4/3Y0LgGz_1uc/s1600-h/CDF+nonlinear+log.jpg"&gt;&lt;img style="cursor: pointer; width: 320px; height: 242px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlCCKYAkD1I/AAAAAAAAAH4/3Y0LgGz_1uc/s320/CDF+nonlinear+log.jpg" alt="" id="BLOGGER_PHOTO_ID_5354923071698636626" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The PDF for this nonlinear logarithmic CDF is not well-distributed. Due to this nonlinearity, the spacings along the grayscale values are not uniform and the probability values are not high. Like the parabolic CDF, the CDF of the enhanced image follows the graph of the desired CDF which is a logarithmic function here, and this makes the quality of the image not that good.&lt;br /&gt;&lt;br /&gt;In summary, here are the original image and its enhanced images using the two methods (the second is composed of two kinds of functions).&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlCEyJe9WQI/AAAAAAAAAIA/VCX0C0XsDHw/s1600-h/poor_contrast.jpg"&gt;&lt;img style="cursor: pointer; width: 153px; height: 256px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlCEyJe9WQI/AAAAAAAAAIA/VCX0C0XsDHw/s320/poor_contrast.jpg" alt="" id="BLOGGER_PHOTO_ID_5354925954017614082" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SlCE22YNweI/AAAAAAAAAII/WAeoexZSXQM/s1600-h/good_contrast_linear.jpg"&gt;&lt;img style="cursor: pointer; width: 153px; height: 256px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SlCE22YNweI/AAAAAAAAAII/WAeoexZSXQM/s320/good_contrast_linear.jpg" alt="" id="BLOGGER_PHOTO_ID_5354926034788401634" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SlCE6qGVeqI/AAAAAAAAAIQ/PGSbOi7FPhI/s1600-h/good_parabola.jpg"&gt;&lt;img style="cursor: pointer; width: 153px; height: 256px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SlCE6qGVeqI/AAAAAAAAAIQ/PGSbOi7FPhI/s320/good_parabola.jpg" alt="" id="BLOGGER_PHOTO_ID_5354926100211661474" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SlCE9ic_cNI/AAAAAAAAAIY/BbfGdsNza9s/s1600-h/good_nonlinear_log.jpg"&gt;&lt;img style="cursor: pointer; width: 153px; height: 256px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SlCE9ic_cNI/AAAAAAAAAIY/BbfGdsNza9s/s320/good_nonlinear_log.jpg" alt="" id="BLOGGER_PHOTO_ID_5354926149698810066" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The first one is the original image, the second is the enhanced image from its original CDF (linear backprojection), the third is used with a parabolic CDF, and finally with a logarithmic CDF. I can conclude that the first method or implementing a linear CDF is the best process for the contrast enhancement of my image.&lt;br /&gt;&lt;br /&gt;I grade myself 10/10 in this activity since I am able to enhance a grayscale image through the manipulation of its PDF using two main procedures successfully.&lt;br /&gt;&lt;br /&gt;The following are my collaborators in this activity: Gary, Ed, Raffy, Neil, and Earl.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;The whole code in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; utilized in this activity is as follows.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;poor = imread('poor_contrast.jpg'); // For histogram (PDF) of the original image&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;imfinfo('poor_contrast.jpg');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a_poor = 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;grayscale_poor = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;pixels_poor = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 0:255&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[x_poor, y_poor] = find(poor == i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;grayscale_poor(a_poor) = i;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;pixels_poor(a_poor) = length(x_poor);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a_poor = a_poor + 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;scf(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;imshow(poor/max(poor));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;scf(1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;subplot(211)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;plot(grayscale_poor, pixels_poor/max(pixels_poor));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;title('PDF of Original Image');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;xlabel('Grayscale Values');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;cdf_0_poor = cumsum(pixels_poor); // For CDF of the original image&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;cdf_poor = cdf_0_poor/max(cdf_0_poor);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;subplot(212)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;plot(grayscale_poor, cdf_poor)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;title('CDF of Original Image');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;xlabel('Grayscale Values');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;good1= []; // For backprojection of the image through the original CDF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 1:size(poor,1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for j = 1:size(poor,2)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;good1(i,j) = cdf_poor(poor(i,j));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;scf(2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;imshow(good1);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(good1, 'good_contrast_linear.jpg');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;good1 = round(good1*255); // For histogram (PDF) of the enhanced image through the original CDF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a_good1 = 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;grayscale_good1 = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;pixels_good1 = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 0:255&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[x_good1, y_good1] = find(good1 == i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;grayscale_good1(a_good1) = i;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;pixels_good1(a_good1) = length(x_good1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a_good1 = a_good1 + 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;scf(3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;subplot(211);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;plot(grayscale_good1, pixels_good1/max(pixels_good1));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;title('PDF of Enhanced Image via Linear Function');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;xlabel('Grayscale Values');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;cdf_0_good1 = cumsum(pixels_good1); // For CDF of the enhanced image through the original CDF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;cdf_good1 = cdf_0_good1/max(cdf_0_good1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;subplot(212);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;plot(grayscale_good1, cdf_good1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;title('CDF of Enhanced Image via Linear Function');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;xlabel('Grayscale Values');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Image enhancement through a desired CDF&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;z = [0:255]; // CDF definition&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;parabola = z^2;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;parabola = parabola/max(parabola);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;good2 = []; // For backprojection through a desired CDF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 1:size(poor, 1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for j = 1:size(poor, 2)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;dummy = abs(cdf_poor(poor(i, j)) - parabola);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;dummy = find(dummy == min(dummy));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;good2(i,j) = dummy;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;good2 = good2/max(good2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;scf(4);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;imshow(good2);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(good2, 'good_parabola.jpg');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;good2 = round(good2*255); // For histogram (PDF) of the enhanced image through a desired CDF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a_good2 = 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;grayscale_good2 = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;pixels_good2 = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 0:255&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[x_good2, y_good2] = find(good2 == i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;grayscale_good2(a_good2) = i;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;pixels_good2(a_good2) = length(x_good2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a_good2 = a_good2 + 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;scf(5);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;subplot(211);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;plot(grayscale_good2, pixels_good2/max(pixels_good2));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;title('PDF of Enhanced Image via Parabolic Function');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;xlabel('Grayscale Values');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;cdf_0_good2 = cumsum(pixels_good2); // For CDF of the enhanced image through a desired CDF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;cdf_good2 = cdf_0_good2/max(cdf_0_good2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;subplot(212);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;plot(grayscale_good2, cdf_good2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;title('CDF of Enhanced Image via Parabolic Function');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;xlabel('Grayscale Values');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;// Enhancement through a nonlinear function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;v = [0:255]; // Nonlinear CDF definition&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;non = log(v + 1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;non = non/max(non);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;good3 = []; // For backprojection of the image through a nonlinear CDF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 1:size(poor, 1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for j = 1:size(poor, 2)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;dummy = abs(cdf_poor(poor(i, j)) - non);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;dummy = find(dummy == min(dummy));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;good3(i,j) = dummy;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;good3 = good3/max(good3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;scf(6);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;imshow(good3);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;//imwrite(good3, 'good_nonlinear_log.jpg');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;good3 = round(good3*255); // For histogram (PDF) of the enhanced image through a nonlinear CDF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a_good3 = 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;grayscale_good3 = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;pixels_good3 = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 0:255&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[x_good3, y_good3] = find(good3 == i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;grayscale_good3(a_good3) = i;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;pixels_good3(a_good3) = length(x_good3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;a_good3 = a_good3 + 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;scf(7);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;subplot(211);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;plot(grayscale_good3, pixels_good3/max(pixels_good3));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;title('PDF of Enhanced Image via Nonlinear Function');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;xlabel('Grayscale Values');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;cdf_0_good3 = cumsum(pixels_good3); // For CDF of the image through a nonlinear CDF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;cdf_good3 = cdf_0_good3/max(cdf_0_good3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;subplot(212);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;plot(grayscale_good3, cdf_good3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;title('CDF of Enhanced Image via Nonlinear Function');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;xlabel('Grayscale Values');&lt;/span&gt;&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/1657424262821979330-7878338915059998963?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/7878338915059998963/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/06/activity-4-enhancement-by-histogram.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/7878338915059998963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/7878338915059998963'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/06/activity-4-enhancement-by-histogram.html' title='Activity 4 - Enhancement by Histogram Manipulation'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_kx7Z922tJd0/SlBpAthR7cI/AAAAAAAAAGg/s239gvqIcsQ/s72-c/poor_contrast.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-4286475028798562811</id><published>2009-06-25T10:52:00.002+08:00</published><updated>2009-08-01T14:43:05.785+08:00</updated><title type='text'>Activity 2 - Area Estimation for Images with Defined Edges</title><content type='html'>&lt;div style="text-align: justify;"&gt;In this activity, we are asked to obtain the area of some basic geometric shapes through the Green's theorem then this will be compared with its known analytic area.&lt;br /&gt;&lt;br /&gt;Note that the first part of Activity 3 was done prior to this activity because the &lt;span style="font-style: italic;"&gt;SIP Toolbox&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;ImageMagick&lt;/span&gt; needed for &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; to handle images were not yet installed in our computer.&lt;br /&gt;&lt;br /&gt;Green's theorem can compute the area of a closed contour through the relation of its double integral to the line integral of the closed curve. After manipulation of the Green's theorem, the resulting discrete or summation form for calculating the area of a closed contour is as follows.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SkSk7kI1HZI/AAAAAAAAAFg/RHmvhn1MPJ4/s1600-h/greens_equation.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 148px; height: 48px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SkSk7kI1HZI/AAAAAAAAAFg/RHmvhn1MPJ4/s400/greens_equation.jpg" alt="" id="BLOGGER_PHOTO_ID_5351583600442940818" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Here, x and y are the pixel locations and N_b is the number of pixels along the contour.&lt;br /&gt;&lt;br /&gt;All my geometric shapes under area estimation are created in &lt;span style="font-style: italic;"&gt;Microsoft Paint&lt;/span&gt;. They are all 256 x 256 pixels in dimension and are saved as 24-bit Bitmap image. Then, using the programming software &lt;span style="font-style: italic;"&gt;Scilab 4.1.2.&lt;/span&gt; with &lt;span style="font-style: italic;"&gt;ImageMagick&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;SIP Toolbox&lt;/span&gt; installed, I managed to implement Green's method in area calculation.&lt;br /&gt;&lt;br /&gt;It is important that the shapes created are white in color and black as their background since the &lt;span style="font-style: italic;"&gt;follow&lt;/span&gt; command in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; gets the pixel locations along the border of the white before the transition to the black background. Incidentally, the default save format in &lt;span style="font-style: italic;"&gt;Paint&lt;/span&gt; does not require to be converted into Binary-type because it already consists of only ones (white) and zeroes (black) when imported to &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; using the command &lt;span style="font-style: italic;"&gt;imread&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;The first geometric shape is a rectangle.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SkLuVp47TwI/AAAAAAAAAFA/6L0CJT7uZ50/s1600-h/rectangle.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 200px; height: 200px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SkLuVp47TwI/AAAAAAAAAFA/6L0CJT7uZ50/s200/rectangle.bmp" alt="" id="BLOGGER_PHOTO_ID_5351101363058855682" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Calculated Area using Green's Theorem = 13926.5 square pixels&lt;br /&gt;Theoretical Area = 14016 square pixels&lt;br /&gt;Percent Error = 0.64 %&lt;br /&gt;&lt;br /&gt;The theoretical area is simply obtained by the formula A = lw (l = length, w = width) through subtracting the maximum pixel location in x to its minimum and multiplying it to the difference of extrema in y from the followed contour of the rectangle.&lt;br /&gt;&lt;br /&gt;Next one is a right triangle.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SkLuatcl5pI/AAAAAAAAAFI/R5r-adIBt4E/s1600-h/triangle.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 200px; height: 200px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SkLuatcl5pI/AAAAAAAAAFI/R5r-adIBt4E/s200/triangle.bmp" alt="" id="BLOGGER_PHOTO_ID_5351101449913099922" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Calculated Area using Green's Theorem = 6791.5 square pixels&lt;br /&gt;Theoretical Area = 6960 square pixels&lt;br /&gt;Percent Error = 2.42 %&lt;br /&gt;&lt;br /&gt;The theoretical area is from A = (1/2)bh (b = base, h = height), where this is similar to the rectangle except for dividing it to 2. Of course, base and height are also from the differences of extrema in x and y of the followed contour of the triangle.&lt;br /&gt;&lt;br /&gt;Finally, a circle is created for area calculation using Green's theorem.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SkLugHcRoZI/AAAAAAAAAFQ/PWO7CedETZo/s1600-h/circle.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 200px; height: 200px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SkLugHcRoZI/AAAAAAAAAFQ/PWO7CedETZo/s200/circle.bmp" alt="" id="BLOGGER_PHOTO_ID_5351101542790439314" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Calculated Area using Green's Theorem = 16643.5 square pixels&lt;br /&gt;Theoretical Area = 16741.547 square pixels&lt;br /&gt;Percent Error = 0.59 %&lt;br /&gt;&lt;br /&gt;From the theoretical equation A = pi*r^2 (pi = 3.14..., r = radius), the radius is determined from half of the difference of extrema in either x or y from the followed contour of the circle.&lt;br /&gt;&lt;br /&gt;Since the shapes generated have pixelated edges, then errors cannot be prevented in area calculation using Green's theorem especially if they are diminutive which possess not-well-defined perimeter. However, I can say that the method is very reliable due to incredibly small percent errors I acquired hence I grade myself 10/10 for this activity.&lt;br /&gt;&lt;br /&gt;I would like to thank Gary and Ed in helping me for loading the &lt;span style="font-style: italic;"&gt;SIP Toolbox&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; of my desktop in our computer room. Raffy guided me for the correct syntax since I am not yet familiar with the &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; environment.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code below is used in this activity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;rectangle = imread('rectangle.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;triangle = imread('triangle.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;circle = imread('circle.bmp');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[x_rectangle, y_rectangle] = follow(rectangle);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[x_triangle, y_triangle] = follow(triangle);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;[x_circle, y_circle] = follow(circle);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;n = length(x_rectangle);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;o = length(x_triangle);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;p = length(x_circle);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;A_rectangle = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;A_triangle = [];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;A_circle = [];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for i = 1:n-1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;  A_rectangle(i) = x_rectangle(i)*y_rectangle(i+1) - y_rectangle(i)*x_rectangle(i+1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for j = 1:o-1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;  A_triangle(j) = x_triangle(j)*y_triangle(j+1) - y_triangle(j)*x_triangle(j+1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;for k = 1:p-1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;  A_circle(k) = x_circle(k)*y_circle(k+1) - y_circle(k)*x_circle(k+1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Theo_rectangle = (max(x_rectangle)-min(x_rectangle))*(max(y_rectangle)-min(y_rectangle))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Theo_triangle = (1/2)*(max(x_triangle)-min(x_triangle))*(max(y_triangle)-min(y_triangle))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Theo_circle = %pi*((max(x_circle)-min(x_circle))/2)^2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Area_rectangle = sum(A_rectangle)/2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Area_triangle = sum(A_triangle)/2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;Area_circle = sum(A_circle)/2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;percent_error_rectangle = abs(((Theo_rectangle - Area_rectangle)/Theo_rectangle))*100&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;percent_error_triangle = abs(((Theo_triangle - Area_triangle)/Theo_triangle))*100&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;percent_error_circle = abs(((Theo_circle - Area_circle)/Theo_circle))*100&lt;/span&gt;&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/1657424262821979330-4286475028798562811?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/4286475028798562811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/06/activity-2-area-estimation-for-images.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/4286475028798562811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/4286475028798562811'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/06/activity-2-area-estimation-for-images.html' title='Activity 2 - Area Estimation for Images with Defined Edges'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_kx7Z922tJd0/SkSk7kI1HZI/AAAAAAAAAFg/RHmvhn1MPJ4/s72-c/greens_equation.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-6710201039801856673</id><published>2009-06-23T10:11:00.005+08:00</published><updated>2009-08-01T14:37:25.337+08:00</updated><title type='text'>Activity 3 - Image Types and Basic Image Enhancement</title><content type='html'>&lt;div style="text-align: justify;"&gt;This activity has 2 major parts. First, different image types which are Binary, Grayscale, Truecolor, and Indexed image were collected. Their respective properties including the pixel dimensions, resolution, image type, file size file type were also determined. The second part involves the conversion of scanned image to grayscale for histogram and threshold determination. Then, the area of the region of interest (ROI) of the Binary-converted image from being a Grayscale type is calculated using Green's theorem which is similar to the method utilized in Activity 2.&lt;br /&gt;&lt;br /&gt;Note that the second part was only started after the &lt;span style="font-style: italic;"&gt;SIP Toolbox&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;ImageMagick&lt;/span&gt; which are needed for &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; to handle images, were installed thus the first part was finished before Activity 2 was completed.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Using the internet, I searched some images then I was able to determine their image type and other image properties using the software &lt;span style="font-style: italic;"&gt;GIMP&lt;/span&gt;&lt;span style="font-style: italic;"&gt; 2.6.6&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1. Binary Image&lt;/span&gt;&lt;br /&gt;The first image is somehow resembling an optical illusion. It is only composed of 2 colors by mere observation.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SkDy8lyHPuI/AAAAAAAAAEI/ULl4NUqTmhM/s1600-h/white_on_black.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 200px; height: 196px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SkDy8lyHPuI/AAAAAAAAAEI/ULl4NUqTmhM/s200/white_on_black.gif" alt="" id="BLOGGER_PHOTO_ID_5350543480064524002" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Width =  405 pixels&lt;br /&gt;Height = 397 pixels&lt;br /&gt;Horizontal Resolution = 72 dpi (dots per inch) or ppi (points per inch)&lt;br /&gt;Vertical Resolution = 72 dpi&lt;br /&gt;Color Space = Indexed (2 Colors)&lt;br /&gt;File Size = 4.3 kb&lt;br /&gt;File Type = GIF Image&lt;br /&gt;Source: &lt;span style="font-style: italic;"&gt;http://acjournal.org/holdings/vol5/iss1/articles/radwan.htm&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Notice that the color space from the properties of the image above is indexed, but it only comprises 2 colors which represent pure black and white, thus it is a Binary image indeed.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. Grayscale Image&lt;/span&gt;&lt;br /&gt;I found a grayscale image of the lake at the summit of Mt. Pinatubo which is shown as follows.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SkA-2D2qZ8I/AAAAAAAAADA/aMAwlYmmMZw/s1600-h/Mount+Pinatubo+Grayscale.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 217px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SkA-2D2qZ8I/AAAAAAAAADA/aMAwlYmmMZw/s320/Mount+Pinatubo+Grayscale.jpg" alt="" id="BLOGGER_PHOTO_ID_5350345455784585154" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Width =  640 pixels&lt;br /&gt;Height =  433 pixels&lt;br /&gt;Horizontal Resolution = 72 dpi&lt;br /&gt;Vertical Resolution = 72 dpi&lt;br /&gt;Color Space = Grayscale&lt;br /&gt;File Size = 48.8 kb&lt;br /&gt;File Type = JPEG Image&lt;br /&gt;Source: &lt;span style="font-style: italic;"&gt;http://www.volcano.si.edu/world/volcano.cfm?vnum=0703-083&amp;amp;volpage=var&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Obviously, the image above is a grayscale one because it contains the different shades between black and white.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;3. Truecolor Image&lt;/span&gt;&lt;br /&gt;The next image is a panoramic view of Taal Volcano as seen from Tagaytay Ridge.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SkDzYYSn7YI/AAAAAAAAAEg/BTfMW1w5Q7w/s1600-h/Taal+Volcano+Colored.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 216px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SkDzYYSn7YI/AAAAAAAAAEg/BTfMW1w5Q7w/s320/Taal+Volcano+Colored.jpg" alt="" id="BLOGGER_PHOTO_ID_5350543957479124354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Width =  500 pixels&lt;br /&gt;Height =  338 pixels&lt;br /&gt;Horizontal Resolution = 96 dpi&lt;br /&gt;Vertical Resolution = 96 dpi&lt;br /&gt;Color Space = RGB Color&lt;br /&gt;File Size = 105.9 kb&lt;br /&gt;File Type = JPEG Image&lt;br /&gt;Source: &lt;span style="font-style: italic;"&gt;http://www.flickr.com/search/?q=taal+volcano&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Since the image of Taal Volcano above has color space of Red-Green-Blue (RGB), then it is a Truecolor image.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;4. Indexed Image&lt;/span&gt;&lt;br /&gt;The following image illustrates the location of major volcanoes in the Philippines. This is apparently an Indexed image because there is less color information compared to a Truecolor image.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SkDzM0x5dgI/AAAAAAAAAEY/U2hpl3nzo5A/s1600-h/MajorVolcanoesOfThePhilippines-USGS.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 150px; height: 320px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SkDzM0x5dgI/AAAAAAAAAEY/U2hpl3nzo5A/s320/MajorVolcanoesOfThePhilippines-USGS.gif" alt="" id="BLOGGER_PHOTO_ID_5350543758968059394" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Width =  351 pixels&lt;br /&gt;Height =  752 pixels&lt;br /&gt;Horizontal Resolution = 96 dpi&lt;br /&gt;Vertical Resolution = 96 dpi&lt;br /&gt;Color Space = Indexed (51 Colors)&lt;br /&gt;File Size = 23.8 kb&lt;br /&gt;File Type = GIF Image&lt;br /&gt;Source: &lt;span style="font-style: italic;"&gt;http://www.absoluteastronomy.com/topics/Pacific_Ring_of_Fire&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;From the image property color space, the image above is an Indexed image type which has 51 representative colors independent from each other.&lt;br /&gt;&lt;br /&gt;For the second part of this activity, I scanned an old 2-peso coin for its area calculation. The scanned image is shown below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SkW_dpTbsFI/AAAAAAAAAFw/R7zbyd-tnbs/s1600-h/coin.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 183px; height: 200px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SkW_dpTbsFI/AAAAAAAAAFw/R7zbyd-tnbs/s200/coin.jpg" alt="" id="BLOGGER_PHOTO_ID_5351894248224174162" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Using the command &lt;span style="font-style: italic;"&gt;im2gray&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt;, I was able to convert the scanned image to a Grayscale-type one. Then &lt;span style="font-style: italic;"&gt;im2bw&lt;/span&gt; made it into a Binary image type. Finally, I used &lt;span style="font-style: italic;"&gt;Microsoft Paint&lt;/span&gt; to make the text and image of Andres Bonifacio to black and invert them to white and the white background to black. The 3 images in order of Grayscale, Binary, and inverted Binary are displayed below.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SkXFB_eh9wI/AAAAAAAAAGY/uN5PPdPpXGA/s1600-h/coin_gray.jpg"&gt;&lt;img style="cursor: pointer; width: 183px; height: 200px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SkXFB_eh9wI/AAAAAAAAAGY/uN5PPdPpXGA/s200/coin_gray.jpg" alt="" id="BLOGGER_PHOTO_ID_5351900370209732354" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SkXE9ZC5UkI/AAAAAAAAAGQ/WZxTHJrTIZ8/s1600-h/coin_bw.jpg"&gt;&lt;img style="cursor: pointer; width: 183px; height: 200px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SkXE9ZC5UkI/AAAAAAAAAGQ/WZxTHJrTIZ8/s200/coin_bw.jpg" alt="" id="BLOGGER_PHOTO_ID_5351900291173798466" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SkXE3g-qoGI/AAAAAAAAAGI/dbB5P2G452c/s1600-h/coin_bw_inv.jpg"&gt;&lt;img style="cursor: pointer; width: 183px; height: 200px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SkXE3g-qoGI/AAAAAAAAAGI/dbB5P2G452c/s200/coin_bw_inv.jpg" alt="" id="BLOGGER_PHOTO_ID_5351900190224326754" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;The Grayscale image has the following properties.&lt;br /&gt;&lt;br /&gt;Width = 476 pixels&lt;br /&gt;Height = 520 pixels&lt;br /&gt;Horizontal Resolution = 72 dpi&lt;br /&gt;Vertical Resolution = 72 dpi&lt;br /&gt;Color Space = Grayscale&lt;br /&gt;File Size = 12.6 kb&lt;br /&gt;File Type = JPEG Image&lt;br /&gt;&lt;br /&gt;The histogram plot of the Grayscale image is as follows.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SkXD37FJCXI/AAAAAAAAAGA/MDmwnWO0MGM/s1600-h/histogram.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 302px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SkXD37FJCXI/AAAAAAAAAGA/MDmwnWO0MGM/s400/histogram.jpg" alt="" id="BLOGGER_PHOTO_ID_5351899097719179634" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;From the histogram plot above, the horizontal axis is the Grayscale values from 0 to 255 and the vertical axis is the number of pixels. The Grayscale range between 100 and 150 represents the ROI and the spike between 200 and 250 represents the background. I can infer from the histogram plot that the ROI is well separated from the background. A threshold of 0.7 for converting the Grayscale image to Binary is best suited based from this plot.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;Finally, the following data for area calculation of the 2-peso coin are obtained.&lt;br /&gt;&lt;br /&gt;Calculated Area using Green's Theorem = 46300 square pixels&lt;br /&gt;Theoretical Area = 46005 square pixels&lt;br /&gt;Percent Error = 0.64 %&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Since the object under area calculation is no longer a basic geometric shape, hence the best way to get its theoretical area is simply summing all the elements of the imported Binary image which only consists of zeroes and ones. But due to the fact that the followed contour is not included to the Green's calculation of area (the followed contour is the white perimeter before the transition to the black background), then it is subtracted to the summation of ones for more accurate theoretical area.&lt;br /&gt;&lt;br /&gt;I grade myself 10/10 here because first, I was able to complete all types of image asked in this activity and identify their properties, and second, because of the very small deviation of the calculated area of the 2-peso coin using Green's theorem from the theoretical value I got.&lt;br /&gt;&lt;br /&gt;This activity is done successfully through the help of Gary and Ed in search of different image types and Raffy for the proper syntax in &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Appendix&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;The following &lt;span style="font-style: italic;"&gt;Scilab&lt;/span&gt; code is implemented in converting the scanned image to Grayscale and Binary, acquiring the histogram plot of the Grayscale image, and calculating the theoretical and Green's area of the 2-peso coin.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;coin = imread('coin.jpg'); // For Image Conversion&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;coin_gray = im2gray(coin);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;imwrite(coin_gray, 'coin_gray.jpg');&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;coin_bw = im2bw(coin_gray, 0.7);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;imwrite(coin_bw, 'coin_bw_inv.jpg');&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;imfinfo('coin_gray.jpg');&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;gray = imread('coin_gray.jpg'); // For Histogram&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;a = 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;grayscale = [];&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;pixels = [];&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;for j = 0:255&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;[x_gray, y_gray] = find(gray == j);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;grayscale(a) = j;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;pixels(a) = length(x_gray);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;a = a + 1;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;plot(grayscale, pixels);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;coin_pic = imread('coin_bw_inv.jpg'); // For Area Calculation&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;coin = im2bw(coin_pic, 0.5);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;[x_coin, y_coin] = follow(coin);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;n = length(x_coin);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;A_coin = [];&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;for i = 1:n-1&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;A_coin(i) = x_coin(i)*y_coin(i+1) - y_coin(i)*x_coin(i+1);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;Theo_coin = sum(coin) - length(x_coin)&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;Area_coin = sum(A_coin)/2&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;percent_error_coin = abs(((Theo_coin - Area_coin)/Theo_coin))*100&lt;/span&gt;&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/1657424262821979330-6710201039801856673?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/6710201039801856673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.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/1657424262821979330/posts/default/6710201039801856673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/6710201039801856673'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/06/activity-3-image-types-and-basic-image.html' title='Activity 3 - Image Types and Basic Image Enhancement'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_kx7Z922tJd0/SkDy8lyHPuI/AAAAAAAAAEI/ULl4NUqTmhM/s72-c/white_on_black.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1657424262821979330.post-8952209834742236265</id><published>2009-06-18T10:46:00.000+08:00</published><updated>2009-06-19T22:09:45.265+08:00</updated><title type='text'>Activity 1 - Digital Scanning</title><content type='html'>Our very first activity is all about reconstructing a hand-drawn graph from an old journal found in the College of Science (CS) library through digital scanning. Ratio and proportion is implemented for the reconstruction where the number of pixels for the scanned image is converted to the physical value of the plot.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;Initially for the first day of classes (June 16, 2009 - Tuesday), all of us went to the CS library where . Here, I found a hand-drawn graph from a 1953 Botany journal which is about analysis of plant environment. Below is shown the scanned image.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_kx7Z922tJd0/SjrV7IOoITI/AAAAAAAAAAk/ygm4YZB-6lg/s1600-h/Activity+1+Image.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 498px; height: 353px;" src="http://1.bp.blogspot.com/_kx7Z922tJd0/SjrV7IOoITI/AAAAAAAAAAk/ygm4YZB-6lg/s400/Activity+1+Image.jpg" alt="" id="BLOGGER_PHOTO_ID_5348822719253717298" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;On our second meeting (June 18, 2009 - Thursday), we started the reconstruction of the hand-drawn plot. Using the software &lt;span style="font-style: italic;"&gt;Nero PhotoSnap Viewer Essentials&lt;/span&gt;, I cropped my image leaving only the graph so that the pixel locations will coincide directly with the reconstruction's physical values. I also adjusted the angle of its orientation so that error in reconstruction will be minimized. The following image is the cropped image of the graph.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_kx7Z922tJd0/SjrXj9gQu0I/AAAAAAAAAA0/3w4dJoaKd78/s1600-h/Cropped.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 279px;" src="http://4.bp.blogspot.com/_kx7Z922tJd0/SjrXj9gQu0I/AAAAAAAAAA0/3w4dJoaKd78/s400/Cropped.jpg" alt="" id="BLOGGER_PHOTO_ID_5348824520261155650" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I opened the cropped image using the software &lt;span style="font-style: italic;"&gt;Microsoft Paint&lt;/span&gt; where I located the pixel locations (both X and Y) of my selected data along the plot, which appear at the lower right corner of its working window when the mouse pointer is directed to them. Then, I noted these pixel locations together with determining conversion factors which will turn pixel locations into the physical values of the plot. Since the pixel location of the origin in &lt;span style="font-style: italic;"&gt;Paint&lt;/span&gt; is at the upper leftmost part, I subtracted the Y pixel location from the total vertical pixels of my cropped image.&lt;br /&gt;&lt;br /&gt;In equations:&lt;br /&gt;Light Intensity = X*(1000/318)&lt;br /&gt;Count per Limit Time = Y prime*(200/219)   ; where Y prime = 769 - Y&lt;br /&gt;&lt;br /&gt;Thus, for the horizontal axis, there is 1000 units of Light Intensity in 318 pixels while there is 200 units of Count per Limit Time in 219 pixels for the vertical axis.&lt;br /&gt;&lt;br /&gt;Next, using the software &lt;span style="font-style: italic;"&gt;OpenOffice.org Calc&lt;/span&gt;, I tabulated my 14 data points and their corresponding physical values.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_kx7Z922tJd0/SjrU5Pe-suI/AAAAAAAAAAU/OKEXykAMCPE/s1600-h/Table.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 202px;" src="http://3.bp.blogspot.com/_kx7Z922tJd0/SjrU5Pe-suI/AAAAAAAAAAU/OKEXykAMCPE/s400/Table.jpg" alt="" id="BLOGGER_PHOTO_ID_5348821587329987298" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Finally, I have reconstructed the hand-drawn graph by plotting the physical values in the same program. Below is shown my reconstructed graph which has background of the cropped image.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_kx7Z922tJd0/SjrW7GEx7ZI/AAAAAAAAAAs/7uWRBFXcAgU/s1600-h/Superimposed.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 431px; height: 247px;" src="http://2.bp.blogspot.com/_kx7Z922tJd0/SjrW7GEx7ZI/AAAAAAAAAAs/7uWRBFXcAgU/s400/Superimposed.jpg" alt="" id="BLOGGER_PHOTO_ID_5348823818187173266" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Notice that there is quite some vertical displacement at high Light Intensity values and this is because the hand-drawn graph is not equally scaled especially in the Y direction.  Meaning, there are significant differences in pixels between two ticks of Count per Limit Time. As an illustration, there are 219 pixels between 0 and 200 units of Count per Limit Time which served as my conversion factor for all data points in Y, but there are only 207 pixels between the ticks of 200 and 400 units of Count per Limit Time in the hand-drawn graph. However, since I fully understood and enjoyed the whole process of this activity plus my reconstruction of the hand-drawn graph is successful, I confidently grade myself 10/10.&lt;br /&gt;&lt;br /&gt;This activity is completed with the help of Dr. Gay Jane Perez for scanning our images. In addition, Raffy, Ed, and Gary guided me with the techniques in plotting, scaling, and making an external image as background of a plot in &lt;span style="font-style: italic;"&gt;OpenOffice.org Calc&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&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/1657424262821979330-8952209834742236265?l=gilbert-ap186.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gilbert-ap186.blogspot.com/feeds/8952209834742236265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/06/activity-1-digital-scanning.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/8952209834742236265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1657424262821979330/posts/default/8952209834742236265'/><link rel='alternate' type='text/html' href='http://gilbert-ap186.blogspot.com/2009/06/activity-1-digital-scanning.html' title='Activity 1 - Digital Scanning'/><author><name>Gilbert</name><uri>http://www.blogger.com/profile/07946571517892849179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://1.bp.blogspot.com/_kx7Z922tJd0/TRa380kJVFI/AAAAAAAABFI/598EpBbF4aw/S220/SVI%2BHalloween%2BCropped.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_kx7Z922tJd0/SjrV7IOoITI/AAAAAAAAAAk/ygm4YZB-6lg/s72-c/Activity+1+Image.jpg' height='72' width='72'/><thr:total>1</thr:total></entry></feed>
