<?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-273950707063911697</id><updated>2011-11-28T09:30:08.439+08:00</updated><category term='paint'/><category term='excel'/><category term='proportion.'/><category term='ratio'/><category term='digital scanning'/><category term='dengue'/><category term='mosquitoes'/><category term='fight dengue'/><title type='text'>Pixel of Knowledge</title><subtitle type='html'>..on pics, physics, and more!</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>23</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-8230256589451847853</id><published>2010-10-07T17:53:00.000+08:00</published><updated>2010-10-07T17:53:34.340+08:00</updated><title type='text'>finally found the meaning of ‘I Like it on the Floor,  I like it on my desk..I like it anywhere’ Facebook updates</title><content type='html'>Ok. I'll just go direct to the point. Read this article &lt;a href="http://thenewsoftoday.com/about-the-i-like-it-on-the-floor-i-like-it-anywhere-facebook-status-updates/3239/"&gt;http://thenewsoftoday.com/about-the-i-like-it-on-the-floor-i-like-it-anywhere-facebook-status-updates/3239/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;October is Breast cancer month and women posting these updates want to show their support. That's it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-8230256589451847853?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/8230256589451847853/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2010/10/finally-found-meaning-of-i-like-it-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/8230256589451847853'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/8230256589451847853'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2010/10/finally-found-meaning-of-i-like-it-on.html' title='finally found the meaning of ‘I Like it on the Floor,  I like it on my desk..I like it anywhere’ Facebook updates'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-6655332672875186807</id><published>2010-10-07T17:41:00.000+08:00</published><updated>2010-10-07T17:41:52.842+08:00</updated><title type='text'>lessons from drinking sessions part 2..</title><content type='html'>Second round of drinking session, this time with my good friend wert, we talked to our friends dad and he shared with us several key points. Below are the things that I remember :).&lt;br /&gt;&lt;br /&gt;Key thing that I remember is &lt;b&gt;"never be complacent, strive for greatness and avoid the trap of mediocrity&lt;/b&gt;". &lt;br /&gt;Other things he also mentioned are the following:&lt;br /&gt;&lt;br /&gt;1. too much analysis leads to paralysis - deal with problems, don't think and analyze too much.&lt;br /&gt;2. marijuana is good. smells good - hehe.. :)&lt;br /&gt;3. be frank, use your position, directly say what you want.&lt;br /&gt;4. experience life, everything is a dose of experience.&lt;br /&gt;5. make mistakes while young...&lt;br /&gt;6. when talking to a crowd, start from where you came from - your foundation and branch your ideas from it. In this way, you are confident that you know what you're talking.&lt;br /&gt;&lt;br /&gt;7. In correspondence to number 6, you must establish a solid foundation. whatever that maybe..&lt;br /&gt;8.&lt;br /&gt;&lt;br /&gt;..there are still couple of things. I just don't remember, :) hehe&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-6655332672875186807?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/6655332672875186807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2010/10/lessons-from-drinking-sessions-part-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/6655332672875186807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/6655332672875186807'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2010/10/lessons-from-drinking-sessions-part-2.html' title='lessons from drinking sessions part 2..'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-6381915417749747437</id><published>2010-10-03T23:31:00.002+08:00</published><updated>2010-10-03T23:33:51.870+08:00</updated><title type='text'>lessons from drinking sessions..part 1.</title><content type='html'>Nakausap ko si Fidel Rillo habang ako ay nakipag-inuman sa bahay ng aming kaibigan (tawagin natin Mambo) bilang despidida nya papuntang Germany. Nais kong ibahagi ang mga bagay na napagusapan namin.&lt;br /&gt;&lt;br /&gt;Tinanong ako ng "What is God?"&lt;br /&gt;&lt;ol&gt;&lt;ul&gt;&lt;li&gt;napakahirap na tanong, isang tanong na kahit alam mong iba ang nagtanong sayo ay isa iyong tanong sa sarili mo. Bilang hindi ko alam kung ano ang tamang sagot, sinagot ko na lang ay..uhh, hindi ko pa pinagiisipan yan. hehe&lt;/li&gt;&lt;li&gt;Isang sagot ang binigay sa akin ng tatay ng aking kaibigan. "it is the search for truth"&lt;/li&gt;&lt;li&gt;Ako ay isang estudyante ng agham, at kung gagamitan mo ng rason, mahirap mapatunayan kung ano ang tamang sagot. "its the search for truth" -- sa gantong paraan, maaring pagdugtungin ang dalawang bagay na tila magkasalungat.&lt;/li&gt;&lt;li&gt;It is the search for truth..science and God...&lt;/li&gt;&lt;/ul&gt;&lt;/ol&gt;&amp;nbsp;isa itong palaisipan sa akin, isang bagay na dapat kong sagutin...&lt;br /&gt;&lt;br /&gt;abangan ang iba pang mga lessons from drinking sessions :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-6381915417749747437?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/6381915417749747437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2010/10/lessons-from-drinking-sessionspart-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/6381915417749747437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/6381915417749747437'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2010/10/lessons-from-drinking-sessionspart-1.html' title='lessons from drinking sessions..part 1.'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-9189356708122494581</id><published>2010-10-03T22:49:00.002+08:00</published><updated>2010-10-03T22:53:08.610+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='fight dengue'/><category scheme='http://www.blogger.com/atom/ns#' term='dengue'/><category scheme='http://www.blogger.com/atom/ns#' term='mosquitoes'/><title type='text'>Simple way to fight Dengue</title><content type='html'>I got this email from my colleague and it is worth trying. I recommend doing this at home and provide feedback if it will work.&lt;br /&gt;&lt;br /&gt;I don't know where this came from but below is an exact copy of the email. Thank you to whoever made this. I haven't proven its worth but it should be worth a try.. here it goes...&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_COm-OXWGnMQ/TKiWMppALKI/AAAAAAAAAn4/iuwE2ron4aE/s1600/download.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="254" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/TKiWMppALKI/AAAAAAAAAn4/iuwE2ron4aE/s320/download.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size: small;"&gt;Its just a mix of&lt;/span&gt;&lt;span style="color: red; font-size: small;"&gt; water, brown sugar &lt;/span&gt;&lt;span style="font-size: small;"&gt;and &lt;/span&gt;&lt;span style="color: red; font-size: small;"&gt;yeast&lt;/span&gt;&lt;span style="font-size: small;"&gt;.&lt;/span&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_COm-OXWGnMQ/TKiXrsxspZI/AAAAAAAAAn8/-MLNjY5SLMo/s1600/2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="286" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/TKiXrsxspZI/AAAAAAAAAn8/-MLNjY5SLMo/s320/2.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: small;"&gt;Cut a &lt;span class="yshortcuts" id="lw_1286116673_11" style="background: none repeat scroll 0% 0% transparent; cursor: pointer;"&gt;plastic bottle&lt;/span&gt; in half, keep both parts. Can be &lt;span class="yshortcuts" id="lw_1286116673_12" style="background: none repeat scroll 0% 0% transparent; cursor: pointer;"&gt;soft drink bottle&lt;/span&gt;.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;Take the lower portion of the bottle. Dissolve the brown sugar in hot water. Let it cool down to ~70 deg F.&lt;/span&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color: black; font-size: small;"&gt;Add the yeast. &lt;/span&gt;&lt;span style="color: #0021bf; font-size: small;"&gt;&lt;span class="yshortcuts" id="lw_1286116673_13" style="background: none repeat scroll 0% 0% transparent; border-bottom: 2px dotted rgb(54, 99, 136); cursor: pointer;"&gt;Carbon dioxide&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-size: small;"&gt; will form &lt;/span&gt;&lt;span style="color: blue; font-size: small;"&gt;(This will attract the mosquitoes)&lt;/span&gt;&lt;span style="color: blue; font-size: small;"&gt; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;Cover the bottle with a dark wrap and &amp;nbsp;insert in the top portion upside down like a funnel. Place it in a corner in your house.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;In 2 weeks you will be surprised by the number of mosquitoes killed. &lt;/span&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;So there you go. It sounds simple and I hope through this it will help some families out there who are in danger of mosquito diseases..&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-9189356708122494581?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/9189356708122494581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2010/10/simple-way-to-fight-dengue.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/9189356708122494581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/9189356708122494581'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2010/10/simple-way-to-fight-dengue.html' title='Simple way to fight Dengue'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_COm-OXWGnMQ/TKiWMppALKI/AAAAAAAAAn4/iuwE2ron4aE/s72-c/download.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-600158469881700217</id><published>2009-10-10T22:36:00.000+08:00</published><updated>2009-10-15T10:02:03.122+08:00</updated><title type='text'>Activity 19: Restoration of blurred image</title><content type='html'>&lt;div style="text-align: justify;"&gt;In the previous activity, we only considered adding noise but without the application of the degradation function. In this activity, we perform restoration for an image degraded by a known function h(x,y) and added with noise n(x,y) (see FIG 1 of activity 18 for the image degradation and restoration model).&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/StChdNMmHsI/AAAAAAAAAmM/OSOif5P7Cno/s1600-h/image_eqn_model.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 94px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/StChdNMmHsI/AAAAAAAAAmM/OSOif5P7Cno/s400/image_eqn_model.png" alt="" id="BLOGGER_PHOTO_ID_5390986277093252802" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;FIG 1: Degradation process of an image f(x,y) by convolution of the degradation function h(x,y) with the image f(x,y) and addition of nosie n(x,y). By the convolution theorem this is represented as multiplication in the frequency domain represented in Eq (2) where capital letters denote the Fourier transform of the smaller letters in Eq (1). The '*' operator denotes convolution.&lt;br /&gt;&lt;br /&gt;In this activity we consider uniform linear motion blur and obtain an estimate of the analytical form of this kind of blurring. Thus, we find the transfer function H(u,v) of the motion blur.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Estimate of the degradation function, h&lt;/span&gt;&lt;br /&gt;Assuming that the opening and closing of the shutter of the imaging device occurs simultaneously and considering perfect optical imaging process, the degraded image g(x,y) in the frequency domain can be represented by Eq. (2) where the transfer function H follows the form below.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/StC-0XmzbWI/AAAAAAAAAmk/wqkrjzlvh0w/s1600-h/H.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 61px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/StC-0XmzbWI/AAAAAAAAAmk/wqkrjzlvh0w/s400/H.png" alt="" id="BLOGGER_PHOTO_ID_5391018560861728098" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;FIG 2: Estimate of the transfer function for uniform linear motion assuming perfect optical imaging and instantaneous opening and closing of the shutter of the imaging device. Where T is the duration of the exposure, a and b are the total distance for which the image was displaced in the x and y direction respectively.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Restoration of the degraded image g(x,y) to f^(x.y)&lt;br /&gt;&lt;/span&gt;In this activity, we use the Wiener filter which minimizes the mean square error between the restored image (f^) and the original image f. i.e., min{|f^-f|} The  Wiener filter assumes that the image and noise are random processes and ncorporates the statistical properties of the noise and degradation function in the restoration process. The minimum of the  mean square error is given below in the frequency domain as:&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/StC-0zlzCJI/AAAAAAAAAms/mOeOQAJ_i5g/s1600-h/WF.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 74px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/StC-0zlzCJI/AAAAAAAAAms/mOeOQAJ_i5g/s400/WF.png" alt="" id="BLOGGER_PHOTO_ID_5391018568373700754" border="0" /&gt;&lt;/a&gt;FIG 3: Wiener filter. H(u,v) is the degradation function from Eq. (3), |H(u,v)| = H*(u,v)H(u,v) where H*(u,v) above denotes complex conjugation, Sn(u,v)  = |N(u,v)|^2 and Sf(u,v) = |F(u,v)| ^2 are the power spectrum of the noise and the undergraded image.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/StMaQHE33SI/AAAAAAAAAnM/87OVVjjDKPU/s1600-h/H_HR.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 129px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/StMaQHE33SI/AAAAAAAAAnM/87OVVjjDKPU/s400/H_HR.png" alt="" id="BLOGGER_PHOTO_ID_5391682042972331298" border="0" /&gt;&lt;/a&gt;FIG 4: Transfer function H (frequency space, left) and the equivalent function h in real space, (right) for T=1, and a=b=0.01.&lt;br /&gt;&lt;br /&gt;The image below shows the results for an image degraded by H and added with a Gaussian noise of mean = 0.01 and var = 0.01 generated using scilab's grand function.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/StL_9FBFhgI/AAAAAAAAAm0/_Gi-IEmvpgg/s1600-h/gauss_noise.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 119px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/StL_9FBFhgI/AAAAAAAAAm0/_Gi-IEmvpgg/s400/gauss_noise.png" alt="" id="BLOGGER_PHOTO_ID_5391653128699741698" border="0" /&gt;&lt;/a&gt;FIG 5: Test image degraded by H following the form of Eq. (3) with T=1, a=0.01, b=0.01 and added by a Gaussian noise of mean=0.01 and variance = 0.01. The restoration using Wiener filter of Eq. (4) is visually successful.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;Usually when we are dealing with real images, the power spectrum Sf(u,v) of the undergraded image is unknown. We can estimate Eq. (4) by assuming a white noise with a constant power spectrum reducing Eq. (4) to the equation below.&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/_COm-OXWGnMQ/StME7aWW4uI/AAAAAAAAAm8/ZHAOgn0ZN5c/s1600-h/pseudo_wiener.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 335px; height: 91px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/StME7aWW4uI/AAAAAAAAAm8/ZHAOgn0ZN5c/s400/pseudo_wiener.png" alt="" id="BLOGGER_PHOTO_ID_5391658597624505058" border="0" /&gt;&lt;/a&gt;FIG 6: Estimate of the Wiener filter.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;For different values of K, we reconstruct the degraded image as shown in the images below.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/StMXvP08meI/AAAAAAAAAnE/6NDT9hFj5gM/s1600-h/diffK.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 160px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/StMXvP08meI/AAAAAAAAAnE/6NDT9hFj5gM/s400/diffK.png" alt="" id="BLOGGER_PHOTO_ID_5391679279362513378" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;FIG 7: Reconstruction for varying values of K = [1e-4 1e-3 1e-2 1e-1 1] for degraded image with T=1, a=b=0.01 added with Gaussian noise of mean = 0.01 and variance=0.01.&lt;br /&gt;&lt;br /&gt;Comparing the Wiener filter reconstruction with the 'estimate of the wiener filter' , the Wiener filter yields better reconstruction as compared to the 'estimate wiener filter'. The reconstruction for the 'estimate of the wiener filter' has good quality when the value of K is close to zero.&lt;br /&gt;&lt;br /&gt;For other combinations of a, b and T, the following reconstruction results.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/StMhiBsKA-I/AAAAAAAAAnU/1_S96dq6ysk/s1600-h/diffparams.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 276px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/StMhiBsKA-I/AAAAAAAAAnU/1_S96dq6ysk/s400/diffparams.png" alt="" id="BLOGGER_PHOTO_ID_5391690047345525730" border="0" /&gt;&lt;/a&gt;FIG 8. Reconstruction for different combinations of T and a=b. Generally, increasing T increases the quality of the image while increasing a=b decreases the quality of the image.&lt;br /&gt;&lt;br /&gt;From the above image, increase in T leads to better reconstruction. This result is most logical since increasing the exposure time of the imaging device increases the number of photons detected and thus better image quality. Since a and b indicates the amount that the image is displaced, increasing a and b will lead to further blurring leading to poor image quality.&lt;br /&gt;&lt;br /&gt;In this activity, I would give myself a grade of 9 for not knowing if the result is correct. I have doubts with the appearance of my transfer function and from the picture of the blurred image, it does not appear to be resembling that of a uniform linear blur. Instead, blurring seems to occur in both the x,y directions as oppose to single direction. The image cannot possibly move in both axis simultaneously. It is recommended that the form of the transfer function be checked for future research.&lt;br /&gt;&lt;br /&gt;Acknowledgements&lt;br /&gt;I would like to acknowledge Mark Jayson Villangca, Luis Buno and Miguel Sison for useful discussions.&lt;br /&gt;&lt;br /&gt;References:&lt;br /&gt;[1] Applied Physics 186 Activity 19 manual.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;[2] image source&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/273950707063911697-600158469881700217?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/600158469881700217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/10/activity-19-restoration-of-blurred.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/600158469881700217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/600158469881700217'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/10/activity-19-restoration-of-blurred.html' title='Activity 19: Restoration of blurred image'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_COm-OXWGnMQ/StChdNMmHsI/AAAAAAAAAmM/OSOif5P7Cno/s72-c/image_eqn_model.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-7987841507533799783</id><published>2009-09-22T10:47:00.000+08:00</published><updated>2009-10-12T22:31:45.962+08:00</updated><title type='text'>Activity 18: Noise model and basic image restoration</title><content type='html'>&lt;div style="text-align: justify;"&gt;In image restoration, the objective is to recover the original image f(x,y) from the observed image g(x,y) with an a priori knowledge of the degradation process h(x,y) and the noise n(x,y) added on the image. This kind of modeling is shown in the figure below.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/StCagw2rkFI/AAAAAAAAAl8/3qvCbgfXTbw/s1600-h/noiserestore.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 90px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/StCagw2rkFI/AAAAAAAAAl8/3qvCbgfXTbw/s400/noiserestore.png" alt="" id="BLOGGER_PHOTO_ID_5390978641623224402" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;FIG 1: Image degradation and restoration model. The original image f(x,y) undergoes degradation by a known process h(x,y) and added with noise n(x,y) leading th the observed image g(x,y). With the use of restoration filters, image restoration aims to recover f(x,y). [1]&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In this activity, we only cover half of the image restoration modelling by adding a known noise n(x,y) to the image and performing restoration algorithm to recover the original image. The strength and properties of the noise n(x,y) can be characterized from its probability distribution function PDF shown below for different noise models.&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/StCHCOp4zOI/AAAAAAAAAj8/DPubG55e6nU/s1600-h/PDF_nopise.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 162px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/StCHCOp4zOI/AAAAAAAAAj8/DPubG55e6nU/s400/PDF_nopise.png" alt="" id="BLOGGER_PHOTO_ID_5390957226325757154" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;FIG 2: PDF of the different noise models used characterized by its mean and variance. (click to zoom)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The different noise models were generated using scilab's builtin &lt;span style="font-weight: bold;"&gt;grand and imnoise&lt;/span&gt; function. The Rayleigh noise was generated using a module modnum downloaded from [2] while the other noise were generated using grand and imnoise (see scilabs documentation for more detail on these functions). Below is the resulting image after adding different noise to a test image.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/StCKPHrd7SI/AAAAAAAAAkE/gTr5Rb3Hyao/s1600-h/NoiseModels.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 130px; height: 400px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/StCKPHrd7SI/AAAAAAAAAkE/gTr5Rb3Hyao/s400/NoiseModels.png" alt="" id="BLOGGER_PHOTO_ID_5390960746326519074" border="0" /&gt;&lt;/a&gt;FIG 3: Image histograms after addition of different noise models.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-weight: bold;"&gt;Restoring in the presence of noise&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: justify;"&gt;Below are the different noise-reduction filters used when only noise is added to the image [1].&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/StCOK3pmWvI/AAAAAAAAAkM/GjOdtd8L4Ek/s1600-h/Fitlersr.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 293px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/StCOK3pmWvI/AAAAAAAAAkM/GjOdtd8L4Ek/s400/Fitlersr.png" alt="" id="BLOGGER_PHOTO_ID_5390965071350749938" border="0" /&gt;&lt;/a&gt;FIG 4: Mean filtering methods for a window of size m x n.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Consider a window, i.e., 3x3 window, we perform the 'mean filtering' on this window. For each pixel in the noisy image g(x,y), we choose a window and perform mean filtering for that pixel. This was done for all the pixels in the images. In order for the algorithm to be effective  around the boundaries, the image was tiled in the manner below:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/StCP2xdpnpI/AAAAAAAAAkU/gKm9yhXB4CE/s1600-h/tile.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 399px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/StCP2xdpnpI/AAAAAAAAAkU/gKm9yhXB4CE/s400/tile.png" alt="" id="BLOGGER_PHOTO_ID_5390966925115891346" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: justify;"&gt;FIG 5: Tiled image to wrap the boundary conditions. The red window represents the area where the spatial noise filtering was applied.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The following pictures below show the result of the restoration process using the different mean filtering methods in FIG 4 for each noise model. The window used is 5x5 and the restoration for the contraharmoic was divided into two depending on the value of Q, {Q=2 &amp;amp; Q=-2}.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/StCQuzcKRuI/AAAAAAAAAkc/NnJQ2DlF1rc/s1600-h/Gaussian.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 255px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/StCQuzcKRuI/AAAAAAAAAkc/NnJQ2DlF1rc/s400/Gaussian.png" alt="" id="BLOGGER_PHOTO_ID_5390967887719188194" border="0" /&gt;&lt;/a&gt;FIG 6: Image restoration results for an image added with a Gaussian noise. Looking at the histogram, the restoration was generally successful for all methods except for some error on the shift of the graylevel value of the three peaks in the original image. In particular, geometric, harmonic and contra-harmonic (Q=-2) appear to shift the graylevel value to the right (towards white) relative to arithmetic and contra-harmonic (Q=2). This means that the image shifted to the left will appear darker relative to those shifted to the right.&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://2.bp.blogspot.com/_COm-OXWGnMQ/StCRhyYcRaI/AAAAAAAAAkk/G2XI7qamP7s/s1600-h/Rayleigh.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 248px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/StCRhyYcRaI/AAAAAAAAAkk/G2XI7qamP7s/s400/Rayleigh.png" alt="" id="BLOGGER_PHOTO_ID_5390968763608483234" border="0" /&gt;&lt;/a&gt;FIG 7: Image restoration results for an image added with a Rayleigh noise. The restoration of the arithmetic and geometric filtering appears visually correct while for the contra-harmonic filtering, the image is either shifted to the left (Q=2) or right (Q=-2) depending on the value of Q used. Unlike geometric and arithmetic filtering, the histogram of harmonic and contra-harmonic filtering is wider along the peaks of the original image.&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://3.bp.blogspot.com/_COm-OXWGnMQ/StCS8DMo3FI/AAAAAAAAAks/kBEjphSlwks/s1600-h/Gamma.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 252px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/StCS8DMo3FI/AAAAAAAAAks/kBEjphSlwks/s400/Gamma.png" alt="" id="BLOGGER_PHOTO_ID_5390970314310605906" border="0" /&gt;&lt;/a&gt;FIG 8: Image restoration results for an image added with a Gamma noise. In general, the restoration appears successful except for the contraharmoic (Q=2) restoration where the histogram of the image is more wider.&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/_COm-OXWGnMQ/StCTiKvG6yI/AAAAAAAAAk0/q5YFT5SSYzc/s1600-h/exponential.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 255px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/StCTiKvG6yI/AAAAAAAAAk0/q5YFT5SSYzc/s400/exponential.png" alt="" id="BLOGGER_PHOTO_ID_5390970969169259298" border="0" /&gt;&lt;/a&gt;FIG 9: Image restoration results for an image added with an exponential noise. The contraharmonic restoration (Q=2 &amp;amp; Q=-2) failed in restoring the image due to wide histogram and overshifting to the left of the grayvalues. This degree of shifting is also manifested in the harmonic filtering.&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://2.bp.blogspot.com/_COm-OXWGnMQ/StCT_BB392I/AAAAAAAAAk8/AjZahEQnvXI/s1600-h/Uniform.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 254px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/StCT_BB392I/AAAAAAAAAk8/AjZahEQnvXI/s400/Uniform.png" alt="" id="BLOGGER_PHOTO_ID_5390971464779822946" border="0" /&gt;&lt;/a&gt;FIG 10: Image restoration results for an image added with a uniform noise. In general, the restoration is quite successful for all methods.&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://2.bp.blogspot.com/_COm-OXWGnMQ/StCUplBhkWI/AAAAAAAAAlE/UYG3cCze0XE/s1600-h/salt%26pepper.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 254px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/StCUplBhkWI/AAAAAAAAAlE/UYG3cCze0XE/s400/salt%26pepper.png" alt="" id="BLOGGER_PHOTO_ID_5390972195996537186" border="0" /&gt;&lt;/a&gt;FIG 11: Image restoration results for an image added with a salt &amp;amp; pepper noise. The restoration seems to have artifacts - presence of extra graylevel values. This could be attributed to the strength of the noise used which  might be too strong and filtering on a 5 x 5 window is not sufficient to recover the image.&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/_COm-OXWGnMQ/StCbE_KTGJI/AAAAAAAAAmE/0M2IVqICsog/s1600-h/lock_jay.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 268px; height: 400px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/StCbE_KTGJI/AAAAAAAAAmE/0M2IVqICsog/s400/lock_jay.jpg" alt="" id="BLOGGER_PHOTO_ID_5390979263938893970" border="0" /&gt;&lt;/a&gt;FIG 12. Applying the restoration process to a grayscale image shown above obtained from my brothers collection of images.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: justify;"&gt;Applying this restoration to a grayscale image (obtained from my brother's picture collection), we perform the same method, adding a known noise term to the image and restoring the image using the mean filters of FIG 4.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/StCWfli0x-I/AAAAAAAAAlM/rkOw2GNGkZ8/s1600-h/gaussian_image.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 392px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/StCWfli0x-I/AAAAAAAAAlM/rkOw2GNGkZ8/s400/gaussian_image.png" alt="" id="BLOGGER_PHOTO_ID_5390974223360772066" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: justify;"&gt;FIG 13: Grayscale image added with Gaussian noise with the corresponding restorations.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/StCWhR2LW5I/AAAAAAAAAlU/p1dVUl3aAPg/s1600-h/Rayleigh_image.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 395px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/StCWhR2LW5I/AAAAAAAAAlU/p1dVUl3aAPg/s400/Rayleigh_image.png" alt="" id="BLOGGER_PHOTO_ID_5390974252432972690" border="0" /&gt;&lt;/a&gt;FIG 14: Grayscale image added with Rayleigh noise with the corresponding restorations.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/StCWiamut5I/AAAAAAAAAlc/4bQvYchM9nU/s1600-h/Gamma_image.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 396px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/StCWiamut5I/AAAAAAAAAlc/4bQvYchM9nU/s400/Gamma_image.png" alt="" id="BLOGGER_PHOTO_ID_5390974271963969426" border="0" /&gt;&lt;/a&gt;FIG 15: Grayscale image added with Gamma noise with the corresponding restorations.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/StCWjtn_4QI/AAAAAAAAAlk/92R4u6Ncpm8/s1600-h/exponential_image.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 392px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/StCWjtn_4QI/AAAAAAAAAlk/92R4u6Ncpm8/s400/exponential_image.png" alt="" id="BLOGGER_PHOTO_ID_5390974294249431298" border="0" /&gt;&lt;/a&gt;FIG 16: Grayscale image added with an exponential noise with the corresponding restorations.&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/StCWk4nARJI/AAAAAAAAAls/5qleWNc3l1E/s1600-h/Uniform_image.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 395px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/StCWk4nARJI/AAAAAAAAAls/5qleWNc3l1E/s400/Uniform_image.png" alt="" id="BLOGGER_PHOTO_ID_5390974314377921682" border="0" /&gt;&lt;/a&gt;FIG 17: Grayscale image added with a uniform noise with the corresponding restorations.&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/_COm-OXWGnMQ/StCYYJ7Wa8I/AAAAAAAAAl0/y9k8BzYXvKU/s1600-h/salt%26pepper_image.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 391px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/StCYYJ7Wa8I/AAAAAAAAAl0/y9k8BzYXvKU/s400/salt%26pepper_image.png" alt="" id="BLOGGER_PHOTO_ID_5390976294711618498" border="0" /&gt;&lt;/a&gt;FIG 18: Grayscale image added with  salt &amp;amp; pepper noise with the corresponding restorations.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In general, geometric and arithemetic filtering work for all kinds of noise models presented. In particular, the author recommends geometric mean as it seems to be flexible and suitable enough for all noise models studied above.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In this activity, I give myself a grade of 10 for performing the restoration and doing all the required activities.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Acknowledgement&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I would like to acknowledge Gilbert Gubatan for providing the downloaded modnum module for generating Rayleigh noise and my brother for lending one of his collection pictures.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;References&lt;br /&gt;[1] Image Restoration. from&lt;a href="http://www.ph.tn.tudelft.nl/%7Elucas/education/et2720in/2002/ImageRestoration.pdf" target="_blank"&gt;http://www.ph.tn.tudelft.nl/~&lt;wbr&gt;lucas/education/et2720in/2002/&lt;wbr&gt;ImageRestoration.pdf&lt;/a&gt;&lt;br /&gt;[2] http://www.scicos.org/ScicosModNum/modnum_web/src/modnum_421/interf/scicoslab/help/eng/htm/rayleigh_sim.htm&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-7987841507533799783?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/7987841507533799783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/09/activity-18-noise-model-and-basic-image.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/7987841507533799783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/7987841507533799783'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/09/activity-18-noise-model-and-basic-image.html' title='Activity 18: Noise model and basic image restoration'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_COm-OXWGnMQ/StCagw2rkFI/AAAAAAAAAl8/3qvCbgfXTbw/s72-c/noiserestore.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-2088083104007350029</id><published>2009-09-17T19:24:00.000+08:00</published><updated>2009-10-11T00:42:03.324+08:00</updated><title type='text'>Activity 17: Photometric Stereo</title><content type='html'>&lt;div style="text-align: justify;"&gt;Photometric stereo is a technique that extracts surface elevation by computing the surface normals assuming the intensity is directly proportional to brightness. Using N light sources (V) ,  the surface normal of each point in the image can be computed following the steps in the image below. (click to zoom for clearer picture)&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/Srg4EVKdIkI/AAAAAAAAAjc/vUZPO3TVbSs/s1600-h/steps.PNG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 410px; height: 632px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/Srg4EVKdIkI/AAAAAAAAAjc/vUZPO3TVbSs/s400/steps.PNG" alt="" id="BLOGGER_PHOTO_ID_5384115001573057090" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;applying these steps to four light sources with images below, we reconstruct the corresponding shape elevation.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/Srg5fe9G7pI/AAAAAAAAAjk/CsoiYbYo5jo/s1600-h/combinedimages.PNG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 350px; height: 349px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/Srg5fe9G7pI/AAAAAAAAAjk/CsoiYbYo5jo/s400/combinedimages.PNG" alt="" id="BLOGGER_PHOTO_ID_5384116567569526418" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The result is shown below:&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/Srg5peM3LWI/AAAAAAAAAjs/-SB-mR8qgSY/s1600-h/recon.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 302px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/Srg5peM3LWI/AAAAAAAAAjs/-SB-mR8qgSY/s400/recon.png" alt="" id="BLOGGER_PHOTO_ID_5384116739165859170" border="0" /&gt;&lt;/a&gt;The reconstruction is relatively correct but with 'horns' on top and on the edges. Also the image is not smooth and some filtering is recommended.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In this activity, I give myself a grade of 10 for successfully reconstructing the image.&lt;br /&gt;&lt;br /&gt;I would like to thank Martin Tensuan for useful discussions.&lt;br /&gt;&lt;br /&gt;References:&lt;br /&gt;[1] Applied Physisc 187 Manual (c)2008 Maricor Soriano&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/273950707063911697-2088083104007350029?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/2088083104007350029/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.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/273950707063911697/posts/default/2088083104007350029'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/2088083104007350029'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/09/activity-17-photometric-stereo.html' title='Activity 17: Photometric Stereo'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_COm-OXWGnMQ/Srg4EVKdIkI/AAAAAAAAAjc/vUZPO3TVbSs/s72-c/steps.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-4544690390902106723</id><published>2009-09-14T03:19:00.001+08:00</published><updated>2009-10-11T00:40:21.038+08:00</updated><title type='text'>Activity 16: Neural Networks</title><content type='html'>&lt;div style="text-align: justify;"&gt;In activity 15, we used Linear discriminant analysis (LDA) as predictor to classify chronic lymphocytic leukemia (CLLs) from lymphocytes using two different sets of features, {area perimeter} and {%red %green}. We already know that using perimeter and area as features would yield 100% classification for LDA and minimum distance algorithm while using %red and %green as features yield 90% success rate for LDA. In this activity we used neural network as predictor to classify CLLs and lymphocytes using the %red and %green as features. Similar to activity 15, we used 5 images of both CLLs and lymphocytes as training set and 5 images from both classes as test set. (see fig 2 and fig 3 of activity 14).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Neural network is a computational model that mimics the behavior of biological neurons, the brain for example[1]. Essentially, the idea of neural network is to assign weights on the input (say features), sums them and pass it to an activation function that processes the weighted input into an output. The process of determining the weights of the input is an iterative process with an a priori knowledge of the output. What neural network does is to compare its output with the desired output and adjust the weights of the input depending on the deviation from the desired output. This process is called the learning process of the network. After the network learns how to classify objects based from their features, classification of the test set is straightforward by feeding the network with the objects' features. For detailed discussion on the subject matter, refer to article in [2]&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In order to understand more on how neural networks are modeled, fig 1 shows an artificial neuron as modeled by McCulloch and Pits (1943). A connection of many such neurons comprises a network.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SrDN3KmCM8I/AAAAAAAAAi8/Ki_Gy9uhIsM/s1600-h/neuron.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 172px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SrDN3KmCM8I/AAAAAAAAAi8/Ki_Gy9uhIsM/s400/neuron.png" alt="" id="BLOGGER_PHOTO_ID_5382027902328124354" border="0" /&gt;&lt;/a&gt;Figure 1: Artificial neuron (left) and many connections of an artificial neuron leading to a neural network (right). It typically consists of an input layer followed by a hidden layer and an output layer.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: justify;"&gt;In this activity, we used the ANN (artificial neural network) toolbox of scilab in performing artificial neural network computation. The process is straightforward and the parameter of interest adjusted are the learning rate and the training cycles. Table 1 shows the result of the computation for learning rate of 0.1,  i.e.,  l=(0.1 0) and training cycle of 10000&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Table 1: Neural network classification yielding 100% success rate for learning rate=0.1 and training cycle = 10000&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SrIHUf4PCKI/AAAAAAAAAjE/5FqMJwTUIpg/s1600-h/res.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 212px; height: 215px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SrIHUf4PCKI/AAAAAAAAAjE/5FqMJwTUIpg/s400/res.png" alt="" id="BLOGGER_PHOTO_ID_5382372553397307554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;We investigate the effect of learning rate and training cycle on the output of the neural network.  We used the lymphocytes as test object, if the network's output is close to 1 the classification is correct otherwise it is wrong. For a constant learning rate (i.e 0.01) and increasing training cycle (1000-10000) we expect the output of the network to approach a limiting value as shown in fig 2. This implies that for increasing training cycle, the neural network is improving and is able to classify the object better.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SrIUpyJrPLI/AAAAAAAAAjM/0olENguIv5I/s1600-h/diffT.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 304px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SrIUpyJrPLI/AAAAAAAAAjM/0olENguIv5I/s400/diffT.png" alt="" id="BLOGGER_PHOTO_ID_5382387212730711218" border="0" /&gt;&lt;/a&gt;Figure 2: Effect of different training cycle on the neural network's output for a constant learning rate(0.01). As shown, increasing the training cycle increases the output approaching the value 1 indicating that the network is learning better.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;For a constant training cycle (1000) , and increasing learning rate (0.1-1), the result also approaches the limiting value of 1 as shown in figure 3.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SrIYDnLYG8I/AAAAAAAAAjU/NLPKKVdXETc/s1600-h/diffL.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 319px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SrIYDnLYG8I/AAAAAAAAAjU/NLPKKVdXETc/s400/diffL.png" alt="" id="BLOGGER_PHOTO_ID_5382390954996538306" border="0" /&gt;&lt;/a&gt;Figure 3: Effect of different learning rate on the neural network's output for a constant training cycle (1000). As shown, increasing the learning rate increases the output approaching the value 1 indicating that the network is learning better.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In this activity, I give myself a grade of 10 for performing the classification well.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I would like to acknowledge Luis Buno for very useful discussions and for mentioning the idea of plotting the output for different training cycle and learning rate.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;References&lt;br /&gt;[1] http://en.wikipedia.org/wiki/Neural_Network#Learning_paradigms&lt;br /&gt;[2] C. Bishop. Neural Networks and Their Applications. Rev. Sci. Instrum. 65(6),&lt;br /&gt;June 1994.&lt;br /&gt;[3] Applied Physics 186 Activity 16 (c)2008 Maricor Soriano&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/273950707063911697-4544690390902106723?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/4544690390902106723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.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/273950707063911697/posts/default/4544690390902106723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/4544690390902106723'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/09/activity-16-neural-networks.html' title='Activity 16: Neural Networks'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_COm-OXWGnMQ/SrDN3KmCM8I/AAAAAAAAAi8/Ki_Gy9uhIsM/s72-c/neuron.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-6511599132210450296</id><published>2009-09-14T01:40:00.000+08:00</published><updated>2009-10-11T00:41:31.512+08:00</updated><title type='text'>Activity 15: Probabilistic Classification</title><content type='html'>&lt;div style="text-align: justify;"&gt;In the previous activity we used minimum distance classification as our predictor in classifying objects. Essentially, what we did is to calculate the deviation of an object from the mean features of different classes. However such classification fails when used with features that overlaps in both classes. In this activity we used Linear Discriminant analysis as predictor in classifying objects. We limit the number of classes to two and use the same features as the previous activity.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Consider the plot below of the features in phase space plot.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/Sq05n9i95YI/AAAAAAAAAhs/UHBbdPzuKF8/s1600-h/featureplot.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 329px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/Sq05n9i95YI/AAAAAAAAAhs/UHBbdPzuKF8/s400/featureplot.png" alt="" id="BLOGGER_PHOTO_ID_5381020488476517762" border="0" /&gt;&lt;/a&gt;Figure 1: Phase space plot using area and perimeter. The regions are well segmented and we expect that simple minimum distance classification should work well as demonstrated in activity 14.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/Sq05ne4GK7I/AAAAAAAAAhk/psRo8_AaiAY/s1600-h/featureplot.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 329px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/Sq05ne4GK7I/AAAAAAAAAhk/psRo8_AaiAY/s400/featureplot.png" alt="" id="BLOGGER_PHOTO_ID_5381020480243641266" border="0" /&gt;&lt;/a&gt;Figure 2: Phase space plot using red and green composition of the image. As can be seen, there are overlaps in both coordinates for both classes such that when the features (independent variables) are used alone, the classification would fail.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;LDA transforms a class as a linear superposition of features and assumes therefore that features are linearly independent from each other. The aim of LDA is to minimize the error of classification that an object belongs to a certain class. The classification rule is that an object belongs to a class if it has the highest conditional probability in that class. The probability of "belongingness" can be computed using the formula below. It is worthwhile to state that the equation below was derived with the assumption that each class has normally distributed conditional probability[1-3].&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/Sq0-xobWvCI/AAAAAAAAAh0/24GWcw0lTY0/s1600-h/equation.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 273px; height: 47px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/Sq0-xobWvCI/AAAAAAAAAh0/24GWcw0lTY0/s400/equation.png" alt="" id="BLOGGER_PHOTO_ID_5381026152164277282" border="0" /&gt;&lt;/a&gt;where&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;ui&lt;/span&gt;: mean features in group &lt;span style="font-style: italic;"&gt;i&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;C&lt;/span&gt;: pooled covariance defined as&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq1AVJ1WIzI/AAAAAAAAAh8/NJnR6A2kpV4/s1600-h/equation2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 58px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq1AVJ1WIzI/AAAAAAAAAh8/NJnR6A2kpV4/s400/equation2.png" alt="" id="BLOGGER_PHOTO_ID_5381027861938709298" border="0" /&gt;&lt;/a&gt;where &lt;span style="font-style: italic;"&gt;ci&lt;/span&gt; is defined as the covariance matrix of group &lt;span style="font-style: italic;"&gt;i, n&lt;/span&gt; is the total number of samples and &lt;span style="font-style: italic;"&gt;ni&lt;/span&gt; is the number of samples in group &lt;span style="font-style: italic;"&gt;i&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;Pi&lt;/span&gt;: prior probability usually assumed to be the number of samples in the group over the total number of samples, &lt;span style="font-style: italic;"&gt;ni/n&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;xi&lt;/span&gt;: features data of group i.&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;xk&lt;/span&gt;: feature data of row k for a certain group.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Using the above formulas we compute for &lt;span style="font-style: italic;"&gt;fi&lt;/span&gt; and determine the class with the highest &lt;span style="font-style: italic;"&gt;f&lt;/span&gt; for each test object using the features in figure 1 and 2.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Table 1: Calculated values of f1 and f2 for different test objects using area and perimeter as features.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq1DWN3exkI/AAAAAAAAAiM/lMQfKsFc3OQ/s1600-h/classification2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 254px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq1DWN3exkI/AAAAAAAAAiM/lMQfKsFc3OQ/s400/classification2.png" alt="" id="BLOGGER_PHOTO_ID_5381031178736158274" border="0" /&gt;&lt;/a&gt;The classification is 100% as expected since the phase space plot of area and perimeter are already well segmented as shown in figure 1.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Table 2:Calculated values of f1 and f2 for different test objects using red and green composition as features.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq1DV-WDOUI/AAAAAAAAAiE/-vIMc3Fl88c/s1600-h/classification.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 254px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq1DV-WDOUI/AAAAAAAAAiE/-vIMc3Fl88c/s400/classification.png" alt="" id="BLOGGER_PHOTO_ID_5381031174569408834" border="0" /&gt;&lt;/a&gt;The classfication failed 1/10 resulting to 90% success classification rate. This error is most probably due to the limited number of training sets (5) and the assumption of normal distribution conditional probability might not yet be satisfied.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In this activity, I give myself a grade of 10 for understanding a bit on LDA and performing the classifications well.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I would like to acknowledge Mark Jayson Villangca and Jay Samuel Combinido for useful discussions.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;References:&lt;br /&gt;[1] http://people.revoledu.com/kardi/tutorial/LDA/Numerical%20Example.html&lt;br /&gt;[2] Applied Physics 186 Activity manual (c)2007 Maricor Soriano&lt;br /&gt;[3] http://en.wikipedia.org/wiki/LDA&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-6511599132210450296?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/6511599132210450296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/09/activity-15-probabilistic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/6511599132210450296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/6511599132210450296'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/09/activity-15-probabilistic.html' title='Activity 15: Probabilistic Classification'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_COm-OXWGnMQ/Sq05n9i95YI/AAAAAAAAAhs/UHBbdPzuKF8/s72-c/featureplot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-4681187532675291272</id><published>2009-09-10T11:03:00.000+08:00</published><updated>2009-10-11T00:39:37.511+08:00</updated><title type='text'>Activity 14: Pattern Recognition</title><content type='html'>&lt;div style="text-align: justify;"&gt;In pattern recognition, the idea is to mimic the human brain in classifying objects into class. Similar to object oriented programming, an object has methods or attributes called features which are common to objects belonging to a certain class. Pattern recognition has two tasks, (a) finding the appropriate features such as color, area or perimeter for efficient separation of classes and (b) finding a decision function that can classify objects into class. We can define the  features as quantifiable properties and combine them together to form a feature vector. From the feature vector of objects, we use a method/function to classify them.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;In this activity we employ the minimum distance classification to classify objects. We use five features: area, perimeter, % red, % blue and % green in classifying chronic lymphocytic leukemia (CLL) cells from lymphocytes (T cells or B cells) [1]. In order to classify objects, an a priori knowledge of a class and its set of features must first be establish. We can think of it as training the classifier for further classification later on. Below is the image of a collection of  CLL cells and lymphocytes which we will use in our classification algorithm.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq0Upj0E4xI/AAAAAAAAAgc/d5QQ9xsYFGQ/s1600-h/fig04.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 301px; height: 400px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq0Upj0E4xI/AAAAAAAAAgc/d5QQ9xsYFGQ/s400/fig04.jpg" alt="" id="BLOGGER_PHOTO_ID_5380979833998467858" border="0" /&gt;&lt;/a&gt;Figure 1: Chronic lymphocytic leukemia cells (i.e., those pointed by the arrows, blue) and lymphoytes (light violet).&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;From the above image, five cropped images of lymphocytes and CLL cells were used as training sets and five more images of both classes were used as test sets. In classifying the objects, the minimum distance classification is used which can be represented using the equation below:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq0X-9qnQ4I/AAAAAAAAAgs/m_rtZ1Rm5mI/s1600-h/equation.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 151px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq0X-9qnQ4I/AAAAAAAAAgs/m_rtZ1Rm5mI/s400/equation.png" alt="" id="BLOGGER_PHOTO_ID_5380983500250235778" border="0" /&gt;&lt;/a&gt;where &lt;span style="font-weight: bold;"&gt;x&lt;/span&gt; is an array where each row represents an object and each column represents a feature, &lt;span style="font-weight: bold;"&gt;m&lt;/span&gt; is the mean feature for a certain class &lt;span style="font-weight: bold;"&gt;W&lt;/span&gt;. For each class &lt;span style="font-weight: bold;"&gt;W&lt;/span&gt;, we can obtain &lt;span style="font-weight: bold;"&gt;d&lt;/span&gt; and an object can be classified to a class if it has the largest value of &lt;span style="font-weight: bold;"&gt;d&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Below are the images used for the training sets and test sets for both classes (CLLs and lymphocytes). In order to extract the area and perimeter features, thresholding was used to segment the images (b) and bwlabel was used to clean the images from isolated spots (c) (see fig 2). Pixel count and the scilab's builtin command &lt;span style="font-style: italic;"&gt;follow &lt;/span&gt;was used to extract the area and perimeter respectively.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq0ik-w7HeI/AAAAAAAAAg0/2ATyfWLjp6Y/s1600-h/training.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 362px; height: 400px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq0ik-w7HeI/AAAAAAAAAg0/2ATyfWLjp6Y/s400/training.png" alt="" id="BLOGGER_PHOTO_ID_5380995148496444898" border="0" /&gt;&lt;/a&gt;Figure 2: Training set of images for both CLLs and lymphocytes with the corresponding image processing operations used (a) rgb (b) bw/thresholding and (c) bwlabel.&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://3.bp.blogspot.com/_COm-OXWGnMQ/Sq0jABsvshI/AAAAAAAAAg8/QQdqqiTsoQM/s1600-h/test.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 355px; height: 400px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/Sq0jABsvshI/AAAAAAAAAg8/QQdqqiTsoQM/s400/test.png" alt="" id="BLOGGER_PHOTO_ID_5380995613140693522" border="0" /&gt;&lt;/a&gt;Figure 3: Test set of images for both CLLs and lymphocytes with the corresponding image processing operations used (a) rgb (b) bw/thresholding and (c) bwlabel.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The table below shows the mean features obtained from the training set. It can be seen that the area and perimeter features segments the classes pretty well as shown in figure 4.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Table 1: Mean features of CLLs and lymphocytes.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/Sq0nv5FNO1I/AAAAAAAAAhE/UObXHrwU768/s1600-h/mean.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 293px; height: 87px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/Sq0nv5FNO1I/AAAAAAAAAhE/UObXHrwU768/s400/mean.png" alt="" id="BLOGGER_PHOTO_ID_5381000833507605330" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq0nwVMlFLI/AAAAAAAAAhM/Fio9a54KAms/s1600-h/featureplot.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 329px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq0nwVMlFLI/AAAAAAAAAhM/Fio9a54KAms/s400/featureplot.png" alt="" id="BLOGGER_PHOTO_ID_5381000841054721202" border="0" /&gt;&lt;/a&gt;Figure 4: Phase space plot of area and perimeter as major classifiers for lymphocytes and CLLs.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The table below shows the result of the classification after computing &lt;span style="font-weight: bold;"&gt;d&lt;/span&gt; for both classes (CLL and lymphocytes) applying on the test sets of figure 3. The algorithm correctly identifies 10/10 objects giving 100% correct classification.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;Table 2: Computed &lt;span style="font-weight: bold;"&gt;d&lt;/span&gt; of lymphocytes and CLLs.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/Sq0qyzklevI/AAAAAAAAAhU/5UCVZqPxzFg/s1600-h/classification.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 184px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/Sq0qyzklevI/AAAAAAAAAhU/5UCVZqPxzFg/s400/classification.png" alt="" id="BLOGGER_PHOTO_ID_5381004182103096050" border="0" /&gt;&lt;/a&gt;In this activity, I give myself a grade of 10 for attaining the objectives of the activity, correctly classifying objects.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I would like to acknowledge Jay Samuel Combinido for very useful discussions.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;References&lt;br /&gt;[1] http://www.vet.uga.edu/vpp/clerk/waikart/index.php&lt;br /&gt;[2] Applied Physics 186 activity 14 manual, (c)2008 Maricor Soriano&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-4681187532675291272?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/4681187532675291272/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/09/activity-14-pattern-recognition.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/4681187532675291272'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/4681187532675291272'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/09/activity-14-pattern-recognition.html' title='Activity 14: Pattern Recognition'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_COm-OXWGnMQ/Sq0Upj0E4xI/AAAAAAAAAgc/d5QQ9xsYFGQ/s72-c/fig04.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-1879164240712309339</id><published>2009-09-10T10:39:00.000+08:00</published><updated>2009-10-11T00:38:40.855+08:00</updated><title type='text'>Activity 13: Correcting Geometric Distortions</title><content type='html'>&lt;div style="text-align: justify;"&gt;Inherent in most imaging device is the presence of diffraction and aberration due to the finite collection aperture and geometry of the lens. Because of the shape and composition of the lens (i.e spherical), magnification and focusing is not isotropic resulting to unwanted distortions. Two of the most common distortions are pincushion and barrel distortion (fig 1).&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SqytzT_LHfI/AAAAAAAAAf8/XfSl7d5BxhU/s1600-h/distortion.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 228px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SqytzT_LHfI/AAAAAAAAAf8/XfSl7d5BxhU/s400/distortion.png" alt="" id="BLOGGER_PHOTO_ID_5380866751851077106" border="0" /&gt;&lt;/a&gt;Figure 1: Two kinds of radial distortion. (a) Barrel distortion appears expanded at the middle and pushed at the sides while (b) pincushion distortion is of the opposite, pushed at the middle and expanded at the sides. Images are taken from  [1].&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Distortions are usually undesirable in image processing especially in machine vision where slight distortions have major drawbacks [2]. Intuitively, a distorted image is the result of a transformation from an ideal image. Essentially, the process in correcting image distortion is to find the transformation from the ideal image to the distorted image.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Using a reference grid, we can correct image distortion as follows:&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SqyxRmy67-I/AAAAAAAAAgE/fOWNNT_lqXg/s1600-h/formula.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 292px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SqyxRmy67-I/AAAAAAAAAgE/fOWNNT_lqXg/s400/formula.png" alt="" id="BLOGGER_PHOTO_ID_5380870570830917602" border="0" /&gt;&lt;/a&gt;Figure 2: Transformation from ideal to distorted image of a grid. (a) Left distorted image can be mapped to the (b) ideal image using the transformation r and s assuming linear transformation in both directions simultaneously. This scheme is valid as long as the grid is not large relative to the image.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Consider fig 2, given the coordinates (x,y) of an ideal image (i.e., reference grid) we can find the distorted image coordinate &lt;span style="font-weight: bold; font-style: italic;"&gt;x',y'&lt;/span&gt; using the transformation &lt;span style="font-weight: bold; font-style: italic;"&gt;r, s&lt;/span&gt; by finding the coefficients c1-c8. The problem now reduces to solving systems of equation with eight unknown, c1-c8 (see fig 3). The eight equations can be obtained from the coordinates of the vertices (four corners) of the grid. It must be noted that the transformation is only valid inside the grid and the coefficients must be recomputed for a different grid.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/Sqy36FZ-6fI/AAAAAAAAAgM/fRnh179jr0g/s1600-h/transformation.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 196px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/Sqy36FZ-6fI/AAAAAAAAAgM/fRnh179jr0g/s400/transformation.png" alt="" id="BLOGGER_PHOTO_ID_5380877863312353778" border="0" /&gt;&lt;/a&gt;Figure 3: Finding the coefficients c1-c8. From the matrix transformation T (x1-x4 and y1-y4 can be obtained from the four corners of the grid) we can obtain C's by matrix inversion of T and multiplying them with the x's and y's coordinate of the ideal grid.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Per pixel in the ideal grid, we can find the corresponding distorted coordinate &lt;span style="font-weight: bold; font-style: italic;"&gt;r,s&lt;/span&gt; using the computed coefficients, c1-c8 (fig 2).&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;After finding the corresponding distorted coordinate, we have to find the graylevel value of the ideal image. If the computed distorted coordinate is integer valued, we just have to carry the graylevel value of the distorted image to the ideal image otherwise we have to interpolate. We use two kinds of interpolation, nearest neighbor and bilinear interpolation.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The nearest neighbor interpolation uses the graylevel value of the nearest integer-valued coordinate in the distorted image. This kind of reconstruction is very fast but the quality is poor and is ideal for thumbnails and images with relatively not varying graylevel value. On the other hand bilinear interpolation assumes linear interpolation in both directions simultaneously similar to what we did above. The graylevel value &lt;span style="font-weight: bold; font-style: italic;"&gt;v&lt;/span&gt; can be obtained as follows (fig 4).&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sqy9Ei5h1_I/AAAAAAAAAgU/tJ2YBzbTiio/s1600-h/bilinear.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 224px; height: 218px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sqy9Ei5h1_I/AAAAAAAAAgU/tJ2YBzbTiio/s400/bilinear.png" alt="" id="BLOGGER_PHOTO_ID_5380883540586125298" border="0" /&gt;&lt;/a&gt;Figure 4: Finding the graylevel value &lt;span style="font-weight: bold; font-style: italic;"&gt;v &lt;/span&gt;of the distorted image using the four neareast neighbors encompassing the distorted coordinate. The coefficients &lt;span style="font-weight: bold; font-style: italic;"&gt;abcd&lt;/span&gt; can be found in a similar manner using fig 3.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;Below is the result of the reconstruction using checkerboard and a distorted image of a window for nearest neighbor interpolation. To find the reference grid coordinates of the distorted image, scilab's locate was used to manually obtain the data points. Although this is very taxing, locating reference grid coordinates embedded with images is sometimes a formidable task. It is highly recommended though to obtain the coordinates using image processing techniques.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SrC8jumptHI/AAAAAAAAAiU/BBvYRNejPpQ/s1600-h/nearest_checker.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 199px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SrC8jumptHI/AAAAAAAAAiU/BBvYRNejPpQ/s400/nearest_checker.png" alt="" id="BLOGGER_PHOTO_ID_5382008876699333746" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SrC8koH5tFI/AAAAAAAAAic/jv6SMq6XsJo/s1600-h/nearest_window.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 133px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SrC8koH5tFI/AAAAAAAAAic/jv6SMq6XsJo/s400/nearest_window.png" alt="" id="BLOGGER_PHOTO_ID_5382008892139615314" border="0" /&gt;&lt;/a&gt;Figure 5: Nearest neighbor interpolation of (top) checkerboard and (bottom) distorted window. Typical of nearest neighbor interpolation is the presence of jagged regions due to the nature of the algorithm (picking the nearest neighbor). click to zoom.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;For the checkerboard, nearest neighbor interpolation is already acceptable since the image is only black and white but for the window, the details of the image was slightly diminished and we need better interpolation scheme.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In bilinear interpolation, the quality is better compared to the nearest neighbor scheme but the speed is very much slower, figure 6 shows this result.&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://4.bp.blogspot.com/_COm-OXWGnMQ/SrC9uOUdgoI/AAAAAAAAAik/Uym35vUyKqY/s1600-h/bilinear_checker.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 198px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SrC9uOUdgoI/AAAAAAAAAik/Uym35vUyKqY/s400/bilinear_checker.png" alt="" id="BLOGGER_PHOTO_ID_5382010156523291266" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SrC9u64b93I/AAAAAAAAAis/q1dJVKHeiqQ/s1600-h/bilinear_window.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 133px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SrC9u64b93I/AAAAAAAAAis/q1dJVKHeiqQ/s400/bilinear_window.png" alt="" id="BLOGGER_PHOTO_ID_5382010168485345138" border="0" /&gt;&lt;/a&gt;Figure 6: Bilinear interpolation of (top) checkerboard and (bottom) distorted window. The quality of the image is better compared to the nearest neighbor interpolation. click to zoom.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In this activity, I give myself a grade of 10 for correcting the distortion thereby achieving the goal of the activity.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I would like to acknowledge Mark Jayson Villangca, Jay Samuel Combinido and Luis Buno for all the help and jokes in doing this activity.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;References&lt;br /&gt;[1] http://en.wikipedia.org/wiki/Image_distortion&lt;br /&gt;[2] Applied Physics 186 manula (c)2008 Maricor Soriano&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-1879164240712309339?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/1879164240712309339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/09/activity-13-correcting-geometric.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/1879164240712309339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/1879164240712309339'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/09/activity-13-correcting-geometric.html' title='Activity 13: Correcting Geometric Distortions'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_COm-OXWGnMQ/SqytzT_LHfI/AAAAAAAAAf8/XfSl7d5BxhU/s72-c/distortion.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-5409123927706736763</id><published>2009-08-06T16:15:00.000+08:00</published><updated>2009-08-07T00:57:59.138+08:00</updated><title type='text'>Activity 12: Color Image Segmentation</title><content type='html'>&lt;div style="text-align: justify;"&gt;Segmentation by thresholding will not always work especially when the area of interest has the same grayscale value as the background. In such cases, segmentation can be done using the color of the image of interest. In this activity, we're going to demonstrate parametric and non-parametric color segmentation.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Normalize Chromaticity Coordinates (NCC)&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Before we proceed with color segmentation, it is convenient to convert the RGB space into NCC space. NCC has the advantage of separating the chromaticity and intensity of the image which is ideal for representing 3D objects. Essentially, a 3D object obtains its 3D effect through shading variations.&lt;br /&gt;&lt;/div&gt;To convert from an RGB space to NCC space we do the following: for each pixel,&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/Snr_5X8dNYI/AAAAAAAAAdQ/oUloLFSOktQ/s1600-h/equation.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 324px; height: 69px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/Snr_5X8dNYI/AAAAAAAAAdQ/oUloLFSOktQ/s400/equation.png" alt="" id="BLOGGER_PHOTO_ID_5366883267110581634" border="0" /&gt;&lt;/a&gt;Note that the chromaticity of the image is essentially reduced to two dimensions since &lt;span style="font-weight: bold; font-style: italic;"&gt;b&lt;/span&gt; can be obtained from &lt;span style="font-weight: bold; font-style: italic;"&gt;r&lt;/span&gt; and &lt;span style="font-weight: bold; font-style: italic;"&gt;g&lt;/span&gt; usng &lt;span style="font-weight: bold; font-style: italic;"&gt;b=1-(r+g)&lt;/span&gt;. The image below represents the normalize chromaticity coordinates where the &lt;span style="font-weight: bold; font-style: italic;"&gt;x-axis&lt;/span&gt; represents the &lt;span style="font-weight: bold; font-style: italic;"&gt;r&lt;/span&gt; and &lt;span style="font-weight: bold; font-style: italic;"&gt;y-axis&lt;/span&gt; represents the &lt;span style="font-weight: bold; font-style: italic;"&gt;g&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/Snr_5t8FTsI/AAAAAAAAAdY/dsukpzE_j8U/s1600-h/normalized_chromaticity.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 239px; height: 191px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/Snr_5t8FTsI/AAAAAAAAAdY/dsukpzE_j8U/s400/normalized_chromaticity.png" alt="" id="BLOGGER_PHOTO_ID_5366883273014595266" border="0" /&gt;&lt;/a&gt;Normalize chromaticity coordinate.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-weight: bold;"&gt;Color Segmentation: Parametric vs Non-parametric&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;To segment the image using its color, we must determine the probability that a pixel belongs into the color of interest. To do this, we need to extract the histogram of the color of interest and normalize it to  the number of pixels to obtain the normalized PDF. In the NCC space, chromaticity is reduced to two dimensions, r and g such that we need to obtain the PDF for each space. If we assume that r and g are independent, we can obtain the PDF for each space separately and multiply them to obtain the overall PDF of the image.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parametric Segmentation&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Parametric segmentation segments the color by fitting a PDF in the image. Assuming a Gaussian distribution independently along r and g axis, we can obtain the PDF by using the equation below: mu is the mean value and sigma is the standard deviation of the color of interest, r is the NCC r-space of the image.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnsEQw_X2HI/AAAAAAAAAdg/57CIjyMYa-I/s1600-h/equation2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 252px; height: 79px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnsEQw_X2HI/AAAAAAAAAdg/57CIjyMYa-I/s400/equation2.png" alt="" id="BLOGGER_PHOTO_ID_5366888067017201778" border="0" /&gt;&lt;/a&gt;Essentially, what this PDF does is to highlight all those pixels having pixel value near the mean and darkens those pixel values that deviates from the mean. Similarly we can obtain a similar PDF for the NCC-g space. The joint probability is obtained by multiplying p(r) and p(g). This PDF then contains all the highlighted pixel values near the desired color of interest.&lt;br /&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Nonparametric Segmentation&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span&gt;The drawback of parametric segmentation is that it assumes a PDF independent of the pixel values of the image. In non-parametric segmentation, we base the segmentation base on the histogram of the color of interest itself and use this to backproject it to the image. Essentially, we obtain the 2D histogram of the color of interest by first converting it to NCC space. The result of this histogram then is a 2D matrix with the r-axis (representing the x-axis), g-axis (&lt;/span&gt;&lt;span&gt;representing the y-axis) and the intensity (representing the count, frequency).  For each pixel in the image, we backproject the obtained histogram.&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt; The steps are as follows:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;obtain histogram of the color of interest, convert to NCC space first&lt;/li&gt;&lt;li&gt;for each pixel in the image, obtain its NCC r and g values&lt;br /&gt;&lt;/li&gt;&lt;li&gt;using the r and g values, find the pixel value from the histogram&lt;/li&gt;&lt;li&gt;replaec the pixel value of the image with the value obtained in the histogram&lt;/li&gt;&lt;/ul&gt;Below are reconstructed images of parametric and non-parametric segmentation.&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SnsIrON_EsI/AAAAAAAAAdo/6Ncej6XAvzI/s1600-h/parametric.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 396px; height: 400px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SnsIrON_EsI/AAAAAAAAAdo/6Ncej6XAvzI/s400/parametric.png" alt="" id="BLOGGER_PHOTO_ID_5366892919586230978" border="0" /&gt;&lt;/a&gt;Parametric reconstruction, observe that the segmentation is not perfect and contains two or more colors.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnsIr8LzkFI/AAAAAAAAAdw/C_7GUFZCQFw/s1600-h/nonparametric.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 398px; height: 400px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnsIr8LzkFI/AAAAAAAAAdw/C_7GUFZCQFw/s400/nonparametric.png" alt="" id="BLOGGER_PHOTO_ID_5366892931925119058" border="0" /&gt;&lt;/a&gt;Non-parametric segmentation. The images are segmented quite well except for the brown and yellow hounds. Image was taken from source [2]&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnsJVvLY9eI/AAAAAAAAAd4/h9-pF7jjGI4/s1600-h/parametric2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 244px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnsJVvLY9eI/AAAAAAAAAd4/h9-pF7jjGI4/s400/parametric2.png" alt="" id="BLOGGER_PHOTO_ID_5366893649988220386" border="0" /&gt;&lt;/a&gt;Parametric reconstruction. Note that for the gren shoe, artifacts of blue shoe are present in the segmentation. Image was taken from source [3].&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnsJV7eHM6I/AAAAAAAAAeA/Gr13aN7xRyQ/s1600-h/nonparametric2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 243px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnsJV7eHM6I/AAAAAAAAAeA/Gr13aN7xRyQ/s400/nonparametric2.png" alt="" id="BLOGGER_PHOTO_ID_5366893653287973794" border="0" /&gt;&lt;/a&gt;Non-parametric segmentation. Note that the segmentation is clearer as compared to the parametric segmentation.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;In general, non-parametric segmentation has better results in that it was able to segment the colored objects solely and cleanly as compared to the parametric segmentation. This is expected since in the paramtric segmentation, we assumed a Gaussian PDF whereas in the non-parametric segmentation, we base our segmentation solely from the image itself. It must be noted however that non-parametric segmentation highly depends on the cropped color of interest. For this reason, it is probably convenient to apply parametric segmetation for those that require automatic color segmentation.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In this activity, I give myself a grade of 10 for segmenting the images properly.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Acknowledgement&lt;/span&gt;&lt;br /&gt;I would like to acknowledge jaya for useful discussions regarding the non-parametric segmentation&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;References&lt;/span&gt;&lt;br /&gt;[1] App Physics 186 activity 12 manual&lt;br /&gt;[2] www.greytsoaps.com/greys.htm&lt;br /&gt;[3] http://www.whatsalltheracquet.com/archives/pictures/renelacoste.jpg&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/273950707063911697-5409123927706736763?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/5409123927706736763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/08/activity-12-color-image-segementation.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/5409123927706736763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/5409123927706736763'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/08/activity-12-color-image-segementation.html' title='Activity 12: Color Image Segmentation'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_COm-OXWGnMQ/Snr_5X8dNYI/AAAAAAAAAdQ/oUloLFSOktQ/s72-c/equation.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-6407013566440093673</id><published>2009-08-06T09:55:00.000+08:00</published><updated>2009-08-12T21:27:17.994+08:00</updated><title type='text'>Activity 11: Color Image Processing</title><content type='html'>&lt;div style="text-align: justify;"&gt;When imaging using a detector (i.e., a camera), the amount of light detected depends on the sensitivity of the detector, the intensity of the illuminating light and reflectance properties of the object. Similarly in digital imaging, a pixel is compose of different proportions of red, green and blue values overlaid in different proportions. The equation below describes how the RGB values are obtained. It is an integral product of the reflectance spectra of the object, spectral power distribution of the light source and camera sensitivity.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sno5zgk_k8I/AAAAAAAAAYg/beAjI5a6UrI/s1600-h/equation1.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 241px; height: 120px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sno5zgk_k8I/AAAAAAAAAYg/beAjI5a6UrI/s400/equation1.png" alt="" id="BLOGGER_PHOTO_ID_5366665463046575042" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/Sno6uDoPqZI/AAAAAAAAAYo/rsV5XG_I7CE/s1600-h/equation2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 172px; height: 74px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/Sno6uDoPqZI/AAAAAAAAAYo/rsV5XG_I7CE/s400/equation2.png" alt="" id="BLOGGER_PHOTO_ID_5366666468887865746" border="0" /&gt;&lt;/a&gt;The presence of the &lt;span style="font-weight: bold;"&gt;K &lt;/span&gt;values above normalizes the effect of camera sensitivity to obtain what we call white balancing. Note that if &lt;span style="font-weight: bold;"&gt;K&lt;/span&gt; is remove, cameras sensitive to certain spectral range will affect the overall color of the image. Also, the kind of illumination will affect the color of the object, i.e., incandescent light appears yellowish as compared to fluorescent light.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In this activity, we're going to apply two algorithms to achieve white balancing. They are the White Patch Algorithm and Gray World Algorithm.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;White Patch Algorithm&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Observe from equation above that the &lt;span style="font-weight: bold;"&gt;K's&lt;/span&gt; are essentially the inverse of the camera output when shown with a white object. Thus white balancing here is just dividing the raw camera output by the image of the white object. This is precisely the White Patch Algorithm.&lt;br /&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Gray World Algorithm&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In the gray world algorithm, it assumes that the average color of the world is gray. Taking the average of the red, green and blue channels can then serve as white balancing constants for the red, green and blue channels respectively. For a certain channel, when you divide the pixel values by the average value of that channel, it is probable that many pixels would contain values greater than 1 (i.e., if pixel value &gt; ave. pixel value). By normalization, (divide by the max) we can lower this value to 1. However, this has the overall effect of darkening the image. As compared to the white patch which divides each channel by the pixel value of the 'white', most probably contains the highest pixel value of the image.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In summary, the algorithm is as follows&lt;br /&gt;&lt;ul&gt;&lt;li&gt;read the image&lt;/li&gt;&lt;li&gt;obtain the constants for white balancing&lt;/li&gt;&lt;ul&gt;&lt;li&gt;white patch algorithm - obtain a white patch in the image and average the pixel values of this patch for each channel. This will serve as the white balancing constants&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li style="text-align: justify;"&gt;for the gray world - obtain the average of each channel and use as the white balancing constants&lt;/li&gt;&lt;li&gt;note that before we do the averaging, we remove all pixels that are saturated.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;divide each channel by the corresponding white balance constants&lt;/li&gt;&lt;li style="text-align: justify;"&gt;normalize the image by dividing the image by its maximum. Note that we avoided the use of clipping the image for in the gray algorithm, it is probable that for each channel many pixel values are greater than the average pixel value making the image look saturated when clipped.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;Below are images obtained from different lighting conditions and corrected using the white patch algorithm and the gray world algorithm. It is arrange such that each column represents the white balancing used by the camera while for each row is the corresponding algorithm used. Raw means without the use of the white and gray algorithm.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The picture below was taken around 9AM in the CSRC garden. (Cloudy condition)&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnqPX05E1RI/AAAAAAAAAcQ/QNzffrQe2wM/s1600-h/GardenSumTrue.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 357px; height: 400px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnqPX05E1RI/AAAAAAAAAcQ/QNzffrQe2wM/s400/GardenSumTrue.jpg" alt="" id="BLOGGER_PHOTO_ID_5366759545463166226" border="0" /&gt;&lt;/a&gt;From the above image, the raw, white patch and gray algorithm has generally the same color hue but the gray patch has darker image  compared to the white patch and raw.  Generally, the  raw image is still better since this image  was taken using the correct white balancing of the camera.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SnqPXQs8W_I/AAAAAAAAAcI/wBN_RipI6YQ/s1600-h/GardenSumFalse.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 357px; height: 400px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SnqPXQs8W_I/AAAAAAAAAcI/wBN_RipI6YQ/s400/GardenSumFalse.jpg" alt="" id="BLOGGER_PHOTO_ID_5366759535748602866" border="0" /&gt;&lt;/a&gt;The above picture has wrong white balancing set by the camera. The gray world algorithm was able to correct the image, adjusting the hue of the red and blue channels. The same can be said of the white patch algorithm. However, the image of the gray world algorithm appears darker as compared to the white patch. Again we attribute this to the constant we used in dividing the pixel values of the image and by normalization (see discussion above).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;We tried the algorithm for different lighting conditions and the results are seen below.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;Image of a table in the CSRC lobby (daylight)&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnqP8wiwPhI/AAAAAAAAAcw/l5LQ385SysY/s1600-h/TableSumFalse.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 356px; height: 400px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnqP8wiwPhI/AAAAAAAAAcw/l5LQ385SysY/s400/TableSumFalse.jpg" alt="" id="BLOGGER_PHOTO_ID_5366760179950960146" border="0" /&gt;&lt;/a&gt;Note that the white and gray algorithm was able to correct the "light blue hue" background of the raw image.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SnqQuYpsCSI/AAAAAAAAAc4/jhOqAdInyhk/s1600-h/TableSumTrue.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 353px; height: 400px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SnqQuYpsCSI/AAAAAAAAAc4/jhOqAdInyhk/s400/TableSumTrue.jpg" alt="" id="BLOGGER_PHOTO_ID_5366761032531052834" border="0" /&gt;&lt;/a&gt;Note that the raw image has yellowish hue which was corrected by the gray and white algorithm.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Another image taken inside the room (i.e., fluorescent lighting condition)&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SnqPYn2LrWI/AAAAAAAAAcg/tkXQFeGokPI/s1600-h/InsideSumFalse.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 355px; height: 400px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SnqPYn2LrWI/AAAAAAAAAcg/tkXQFeGokPI/s400/InsideSumFalse.jpg" alt="" id="BLOGGER_PHOTO_ID_5366759559141240162" border="0" /&gt;&lt;/a&gt;Note that the result of the gray world algorithm and white patch algorithm brings out the color of the table better compared to the raw image.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnqPY5aYeNI/AAAAAAAAAco/NhVwLbk86yc/s1600-h/InsideSumTrue.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 355px; height: 400px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnqPY5aYeNI/AAAAAAAAAco/NhVwLbk86yc/s400/InsideSumTrue.jpg" alt="" id="BLOGGER_PHOTO_ID_5366759563856476370" border="0" /&gt;&lt;/a&gt;In this picture, we can see that gray world algorithm is better compared to the white patch algorithm. In the raw picture, the image has yellowish hue background indicating that some channel is dominant over the other channels. Note that using the gray world algorithm, we are obtaining the average of each channel reducing the effect of dominance of other channels.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Another image inside the room of different hues of red. (fluorescent lighting conditions)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SnqPYNfdXpI/AAAAAAAAAcY/Fg10g2NP5so/s1600-h/HueRedFalse.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 357px; height: 400px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SnqPYNfdXpI/AAAAAAAAAcY/Fg10g2NP5so/s400/HueRedFalse.jpg" alt="" id="BLOGGER_PHOTO_ID_5366759552066608786" border="0" /&gt;&lt;/a&gt;Observe the corrected gray and white algorithm using incandescent white balancing of the camera.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Generally, I think that the gray world algorithm is much convenient and sometimes better compared to the white patch algorithm. Note that unless, we can obtain an algorithm for finding the white patch image in the white patch algorithm, our reconstruction would always depend on the patch that we're going to use. As compared to the gray world algorithm which makes use of averaging. The drawback of gray world algortithm is that it makes the image look darker. However, this can be remedied by using contrast enhancement, i.e., use an exponential cumulative distribution function to lighten up the image.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In this activity, I give myself a grade of 10, for obtaining the reconstructions and explaining the results&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Acknowledgement&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;I would like to acknowledge Kaye for lending me the McDo stuff toy and Carmen for the blue notebook.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;References&lt;/span&gt;&lt;br /&gt;[1] App Physics 186 Activity 11 Manual&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SnpmW2O1ktI/AAAAAAAAAYw/sOXl-wCD8vk/s1600-h/GardenSumTrue1.png"&gt;&lt;br /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-6407013566440093673?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/6407013566440093673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/08/activity-11-color-image-processing.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/6407013566440093673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/6407013566440093673'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/08/activity-11-color-image-processing.html' title='Activity 11: Color Image Processing'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_COm-OXWGnMQ/Sno5zgk_k8I/AAAAAAAAAYg/beAjI5a6UrI/s72-c/equation1.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-2163333619568016418</id><published>2009-08-06T09:46:00.000+08:00</published><updated>2009-08-09T08:53:49.547+08:00</updated><title type='text'>Activity 10: Preprocesing Text</title><content type='html'>When handwriting documents, usually the papers we are using are embedded with lines. In this activity, we are going to extract handwritten text from these kinds of papers. We're going to apply different image processing techniques to remove the lines and extract the text.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SnwxGcmmweI/AAAAAAAAAeI/ZEKWxbhmNTI/s1600-h/crop.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 400px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SnwxGcmmweI/AAAAAAAAAeI/ZEKWxbhmNTI/s400/crop.bmp" alt="" id="BLOGGER_PHOTO_ID_5367218842745881058" border="0" /&gt;&lt;/a&gt;Scanned image of a piece of paper with handwritten texts.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;We crop a portion of the above image and try to segment the handwritten texts individually.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/Snw51zjRL0I/AAAAAAAAAeQ/b-06ICLNPqM/s1600-h/rotated.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 118px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/Snw51zjRL0I/AAAAAAAAAeQ/b-06ICLNPqM/s400/rotated.png" alt="" id="BLOGGER_PHOTO_ID_5367228452452773698" border="0" /&gt;&lt;/a&gt;The image was rotated using mogrify at an angle ~1.219. Click to enlarge the image&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The lines can be removed by filtering in Fourier space by noting that the horizontal lines produce frequencies along the vertical axis in frequency space.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/Snw76D6WBeI/AAAAAAAAAe4/Ga-B8uvDUXQ/s1600-h/convolution.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 70px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/Snw76D6WBeI/AAAAAAAAAe4/Ga-B8uvDUXQ/s400/convolution.png" alt="" id="BLOGGER_PHOTO_ID_5367230724587259362" border="0" /&gt;&lt;/a&gt;Filtering in Fourier space. Click to enlarge the image&lt;div style="text-align: justify;"&gt;&lt;br /&gt;The filtered image was further polish using scilab's sharpen and enhance  (i.e., mogrify(img, ['-sharpen','2'])to highlight the letters better. Enhance is applied to remove the noise which will be useful when thresholing the imge.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/Snw52WTvMLI/AAAAAAAAAeg/sAfTRv8jbvY/s1600-h/binary.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 80px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/Snw52WTvMLI/AAAAAAAAAeg/sAfTRv8jbvY/s400/binary.png" alt="" id="BLOGGER_PHOTO_ID_5367228461782872242" border="0" /&gt;&lt;/a&gt;Sharpening and enhancing the image for thresholding. Click to enlarge the image&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;Note that after thresholing, the image is noisy. We apply closing followed by opening operator to clean the image and segment the letters as much as possible.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/Snw52t--R6I/AAAAAAAAAeo/eVdfHrOknvo/s1600-h/morphological.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 99px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/Snw52t--R6I/AAAAAAAAAeo/eVdfHrOknvo/s400/morphological.png" alt="" id="BLOGGER_PHOTO_ID_5367228468138231714" border="0" /&gt;&lt;/a&gt;From leftmost: (a) structuring element (b) result of closing operator and (c) result of opening operator. Click to enlarge the image&lt;br /&gt;&lt;br /&gt;We use scilab's built-in &lt;span style="font-weight: bold;"&gt;thin&lt;/span&gt; function to segment the image into 1 pixel width. Scilab's &lt;span style="font-weight: bold;"&gt;bwlabel&lt;/span&gt; was applied to separate each continuous blobs which represent the segmented letters.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/Snw524bhkxI/AAAAAAAAAew/esDLf369YX4/s1600-h/thinning.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 110px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/Snw524bhkxI/AAAAAAAAAew/esDLf369YX4/s400/thinning.png" alt="" id="BLOGGER_PHOTO_ID_5367228470942339858" border="0" /&gt;&lt;/a&gt;Segmented letters using bwlabel and thin. Click to enlarge the image&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;Note that although we are able to separate the letters into 1 pixel width, the segmentation is not perfect and needs lot of improvement.&lt;br /&gt;&lt;br /&gt;Recommendation:&lt;br /&gt;For the case of the image above, the handwritten letters were written using blue colored pen. Using color segmentation, we can separate the handwritten texts without having to worry about filtering. Morphological operations can then be used to segment the image better. It must be noted that most of the error in the above segmentation is due to thresholding after filtering the image. Segmentation by color might improve the reconstruction&lt;br /&gt;&lt;br /&gt;For the next part of this activity, we find other instances of the word &lt;span style="font-weight: bold;"&gt;description&lt;/span&gt; in the original image. We simply correlate the original image with the image of the word description and find the locations where the pixel value is highest.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/Sn4d0GLXc3I/AAAAAAAAAfY/HkXqMd3qNAM/s1600-h/corr.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 248px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/Sn4d0GLXc3I/AAAAAAAAAfY/HkXqMd3qNAM/s400/corr.png" alt="" id="BLOGGER_PHOTO_ID_5367760586720899954" border="0" /&gt;&lt;/a&gt;The images that we're going to correlate. (a) binarize image and (b) image of the word DESCRIPTION.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/Sn4dBh1cUfI/AAAAAAAAAfQ/_a_DDLF8rJA/s1600-h/correlated.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 400px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/Sn4dBh1cUfI/AAAAAAAAAfQ/_a_DDLF8rJA/s400/correlated.png" alt="" id="BLOGGER_PHOTO_ID_5367759717971808754" border="0" /&gt;&lt;/a&gt;Result of the correlation. The highlighted pixels correspond to the word DESCRIPTION.The bright dots correspond to high correlation. Click to zoom in&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;In this activity, I give myself a grade of 8 for below average reconstruction. However, I recommended an alternate solution to the problem and for this reason I give myself a grade of 8.5 (bonus of 0.5) =).&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;References&lt;/span&gt;&lt;br /&gt;[1] App Physics 186 activity 10 manual&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-2163333619568016418?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/2163333619568016418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/08/activity-10-preprocesing-text.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/2163333619568016418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/2163333619568016418'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/08/activity-10-preprocesing-text.html' title='Activity 10: Preprocesing Text'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_COm-OXWGnMQ/SnwxGcmmweI/AAAAAAAAAeI/ZEKWxbhmNTI/s72-c/crop.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-3526782872818755736</id><published>2009-08-01T16:49:00.000+08:00</published><updated>2009-08-07T01:00:15.728+08:00</updated><title type='text'>Activity 9: Binary Operations</title><content type='html'>&lt;div style="text-align: justify;"&gt;In this activity, we're going to obtain the best estimate of cell area (pixel count) by using all the morphological and binary operations we have learned. Below is the image of the "simulated" cells that we're going to measure, punched papers imaged using a flatbed scanner.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SnQDJIpLDYI/AAAAAAAAAXM/DgMp5H_NbLY/s1600-h/Circles001.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 330px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SnQDJIpLDYI/AAAAAAAAAXM/DgMp5H_NbLY/s400/Circles001.jpg" alt="" id="BLOGGER_PHOTO_ID_5364916511578983810" border="0" /&gt;&lt;/a&gt;Image of simulated cells, punched paper digitize using a scanner.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: justify;"&gt;A quick look at the image tells us that we need to analyze several ROI (region of interest) in order to obtain the best estimate. &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;Ofcourse&lt;/span&gt;, we could opt to obtain an isolated cell and perform area measurement but this will not always apply especially when the cells have areas that deviate slightly from one another. Also, the cells shape may not always be uniform. In order to obtain our region of interest, we could do &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;thresholding&lt;/span&gt; and &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;binarized&lt;/span&gt; our image for easier area measurements later on.&lt;br /&gt;&lt;/div&gt;Below is the histogram of our image:&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnQLH_K6F3I/AAAAAAAAAXU/mItIVyzlDhY/s1600-h/histogram.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 299px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnQLH_K6F3I/AAAAAAAAAXU/mItIVyzlDhY/s400/histogram.bmp" alt="" id="BLOGGER_PHOTO_ID_5364925287949277042" border="0" /&gt;&lt;/a&gt;Histogram of the simulated cells.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;We can see that most of the information in our image is roughly between 0.5 and 0.85. Base on this value, we could &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;binarize&lt;/span&gt; our image using a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;treshold&lt;/span&gt; of around 0.85.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Statistically, if we can obtain several measurements of different cells, we can plot the histogram of our measurement and base from this histogram, we can obtain our best estimate for area measurement. This is precisely what we're going to do. We obtain several &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;subimages&lt;/span&gt; (256 x256) from the original image and perform area measurement on each image. We do this by &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;thresholding&lt;/span&gt; the image and perform morphological operations like opening and closing to separate nearly touching cells and to remove isolated spots. A literature on opening and closing operation is available in source [2].&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In this activity, we obtain 20 &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;subimages&lt;/span&gt; of sizes (256x256) randomly on the image. &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SnQNkD5AeFI/AAAAAAAAAXc/anIgFIzYQLM/s1600-h/Raw.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 320px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SnQNkD5AeFI/AAAAAAAAAXc/anIgFIzYQLM/s400/Raw.png" alt="" id="BLOGGER_PHOTO_ID_5364927969275967570" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;Subimages&lt;/span&gt; of size 256 x 256.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;The above image was &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;thresholded&lt;/span&gt; at around 0.820 resulting to the image below:&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SnQOdLN4XkI/AAAAAAAAAXk/VAr0N1hB9Nc/s1600-h/Thresholded.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 320px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SnQOdLN4XkI/AAAAAAAAAXk/VAr0N1hB9Nc/s400/Thresholded.png" alt="" id="BLOGGER_PHOTO_ID_5364928950495108674" border="0" /&gt;&lt;/a&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;Thresholded&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;subimages&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: justify;"&gt;Observe the presence of nearly touching cells and isolated spots on the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;subimages&lt;/span&gt;. We can &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;futher&lt;/span&gt; clean this image by performing morphological operations. In this activity, we perform opening operation on the above image using a circle as structuring element having diameter = 8 pixels. Note that we have to be careful when choosing our structuring element for this could affect the sizes of the cells drastically.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Below is the resulting image after the opening operation.&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SnQRG7-diJI/AAAAAAAAAXs/Wj60cyesfpw/s1600-h/Open.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 320px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SnQRG7-diJI/AAAAAAAAAXs/Wj60cyesfpw/s400/Open.png" alt="" id="BLOGGER_PHOTO_ID_5364931866981664914" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Comparing to the "unopened image" above, we can see that the images are relatively clean and we are able to separate several nearly touching cells. Although, this separation is not 100% successful, we are somehow able to enhance our image for area measurement.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;After performing morphological operations on our image, we are now in the position to obtain area measurement by labeling all contiguous blobs and &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;couting&lt;/span&gt; their areas (pixel count). We can do this in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;scilab&lt;/span&gt; using the function  &lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;bwlabel&lt;/span&gt;&lt;/span&gt; &lt;/span&gt;which&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;labels all contiguous blobs and tabulates them in an array. Below is the resulting images after applying &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;bwlabel&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SnQSu-eVeHI/AAAAAAAAAX0/QI42Fr9NuO4/s1600-h/label.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 320px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SnQSu-eVeHI/AAAAAAAAAX0/QI42Fr9NuO4/s400/label.png" alt="" id="BLOGGER_PHOTO_ID_5364933654358620274" border="0" /&gt;&lt;/a&gt;Labeled &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;subimages&lt;/span&gt; using &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;scilabs&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;bwlabel&lt;/span&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;By looping on all the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;subimages&lt;/span&gt; and counting the area of each contiguous blobs, we can obtain a frequency distribution of the area of the cell. In our measurement, we disregarded area measurements greater than 800, since by visual investigation, the cells' pixel area is clearly below this value. Below is the histogram of the obtained cell areas.&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/_COm-OXWGnMQ/SnQX-J4OvBI/AAAAAAAAAX8/H1ntm5rKa7Y/s1600-h/areameasurement.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 309px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SnQX-J4OvBI/AAAAAAAAAX8/H1ntm5rKa7Y/s400/areameasurement.png" alt="" id="BLOGGER_PHOTO_ID_5364939412676197394" border="0" /&gt;&lt;/a&gt;Histogram of cell measurement&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;From the above histogram, we obtain an estimate of area = 530 pixels plus or minus 10 pixels since we use bins of spacing 20 pixels in our histogram. In the above histogram the number of cells having areas between 520-540 is 87, significantly higher than the other measured area.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Since our approach is statistical, the higher the number of subimages, the better. Although, we could perform morphological operations on nearly touching cells, it must be stressed that the approximation is much easier if we can obtain images of cells that are relatively sparse. We must think of this when we obtain images of cells in our experiment.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In this activity, I give myself a grade of 10 for performing the required measurement.&lt;br /&gt;&lt;br /&gt;Acknowledgement&lt;br /&gt;I would like to thank Irene for very useful conversations.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;References&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;[1] AP 186 Activity 9 manual&lt;br /&gt;[2] http://en.wikipedia.org/wiki/Mathematical_morphology#Opening_and_Closing&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-3526782872818755736?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/3526782872818755736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/08/binary-operations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/3526782872818755736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/3526782872818755736'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/08/binary-operations.html' title='Activity 9: Binary Operations'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_COm-OXWGnMQ/SnQDJIpLDYI/AAAAAAAAAXM/DgMp5H_NbLY/s72-c/Circles001.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-5040492905531384019</id><published>2009-07-23T19:17:00.000+08:00</published><updated>2009-08-07T01:00:31.221+08:00</updated><title type='text'>Activity 8: Morphological Operations</title><content type='html'>&lt;div style="text-align: justify;"&gt;An image contain informations that can be extracted using image processing. Usually before image processing, we try to enhance the input through morphological operations. Morphology refers to shape and structure manipulation, thinning, expanding, closing of holes and the like. Because of its versatility,morphological operations find many applications in area measurement, counting, and tracking to name a few [1]. Morphological operations make use of set theory. A brief rundown of set theory is available in source[2].&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;In this activity, we're going to demonstrate two basic morphological operations, dilation and erosion. We proceed by defining dilation and erosion using set theory and provide examples using different images. To futher understand dilation and erosion better, the reader is recommended to predict the outcome of dilation and erosion on a piece of paper before programming it on a computer.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;DILATION&lt;/span&gt;&lt;br /&gt;From our activity manual, "dilation of &lt;span style="font-style: italic;"&gt;A&lt;/span&gt; by &lt;span style="font-style: italic;"&gt;B&lt;/span&gt; denoted by &lt;span style="font-style: italic;"&gt;A&lt;/span&gt; dilation &lt;span style="font-style: italic;"&gt;B&lt;/span&gt; is defined as".&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SnP-Kl7XKMI/AAAAAAAAAW8/HjeK7x-xC6I/s1600-h/dilation.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 151px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SnP-Kl7XKMI/AAAAAAAAAW8/HjeK7x-xC6I/s400/dilation.png" alt="" id="BLOGGER_PHOTO_ID_5364911039061633218" border="0" /&gt;&lt;/a&gt;It is important to note that dilation of A by B is the set of all &lt;span style="font-weight: bold;"&gt;Z's&lt;/span&gt; such that B translated by Z union A is not an empty set. B here is called the structuring element. The figure above demonstrates this effect of dilation. In general, we can say that dilation expands the image by the shape of B.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In this activity we use images of square (50×50) , a triangle (base = 50 , height= 30), a circle  radius 25), a hollow square (60×60, edges are 4 pixels thick), and a plus sign (8 pixels thick and 50 pixels long for each line). The structuring elements used are 4 x 4 ones, 2 x 4 ones, 4 x 2 ones and a cross. Below are the result of my predictions and the corresponding dilated images.&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;my predictions were mostly correct, except for the dilation of a cross using a cross as structuring element. I failed to account for the corners of the cross.&lt;/li&gt;&lt;li&gt;Results below can be summarize in general as follows:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;4x4 ones just increase the size uniformly adding 3 pixels&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;2x4 makes the image wider (horizontally) by about 3 pixels&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;4x2 makes the image longer (vertically) by about 3 pixels&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;cross adds 2 pixels on all sides except on corners&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Or as a rule of thumb, dilation expands the object similar to the shape of the structuring element (see definition above).&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SmhG_93SzBI/AAAAAAAAAWs/6y71n-ibzPk/s1600-h/DILATION.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 380px; height: 400px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SmhG_93SzBI/AAAAAAAAAWs/6y71n-ibzPk/s400/DILATION.png" alt="" id="BLOGGER_PHOTO_ID_5361613421136759826" border="0" /&gt;&lt;/a&gt;Dilation of different images (leftmost) by different structuring elements (columns 2 to 5)&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;EROSION&lt;/span&gt;&lt;br /&gt;From our activity manual, "The erosion of A by B is the set of all &lt;span style="font-weight: bold;"&gt;z's&lt;/span&gt; such that B translated by z is contained in A."&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnQACw2G2TI/AAAAAAAAAXE/Khncj_MexjU/s1600-h/erosion.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 148px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SnQACw2G2TI/AAAAAAAAAXE/Khncj_MexjU/s400/erosion.png" alt="" id="BLOGGER_PHOTO_ID_5364913103576684850" border="0" /&gt;&lt;/a&gt;Similar to dilation, the effect of erosion is to reduce the image by the shape of B.&lt;br /&gt;&lt;/div&gt;Summarize below are my predictions and the result of my simulation.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;I failed to predict erosion of the hollow figure using a cross (i.e., presence of 4 dots) and the erosion of the cross using a cross as structuring elements.&lt;/li&gt;&lt;li&gt;similar to the dilation, the effect of erosion can be thought of as eroding the shape of the element by the structuring element.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SmhHKZUZ_SI/AAAAAAAAAW0/rS13hL73_5w/s1600-h/EROSION.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 379px; height: 400px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SmhHKZUZ_SI/AAAAAAAAAW0/rS13hL73_5w/s400/EROSION.png" alt="" id="BLOGGER_PHOTO_ID_5361613600305315106" border="0" /&gt;&lt;/a&gt;Erosion of different images (leftmost) by different structuring elements (columns 2 to 5)&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;I give myself a grade of 10 for performing the activity on time and for predicting the results quite well.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I want to acknowledge master, jaya, thirdy for the laughs while programming the code and predicting the results of the erosion and dilation. Miguel for the gimp and the incident about his computer :-p.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;References&lt;/span&gt;&lt;br /&gt;[1] AP 186 Activity 8 manual&lt;br /&gt;[2] http://en.wikipedia.org/wiki/Set_(mathematics)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-5040492905531384019?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/5040492905531384019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/07/activity-8-morphological-operations.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/5040492905531384019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/5040492905531384019'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/07/activity-8-morphological-operations.html' title='Activity 8: Morphological Operations'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_COm-OXWGnMQ/SnP-Kl7XKMI/AAAAAAAAAW8/HjeK7x-xC6I/s72-c/dilation.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-8233971909035330255</id><published>2009-07-17T14:21:00.000+08:00</published><updated>2009-08-07T01:01:09.162+08:00</updated><title type='text'>Activity 7 Enhancement in the Frequency Domain</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Filtering in Fourier Space&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span&gt;Signal processing as the name implies is an area that deals with analyzing and processing of signals. A major concern in signal processing is the signal to noise ratio. By definition, anything that you do not want is considered noise [1]. One of the methods use in signal processing is filtering in Fourier space. In essence, if we know the characteristic frequency of a signal we can use a filter to remove unwanted frequencies and enhance the signal thereby increasing the signal to noise ratio. In this activity, we demonstrate basic use of filtering in Fourier space to remove unwanted signals.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;Activity 7.A: Convolution Theorem&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Before we dwell on filtering, we must first familiarize ourselves with the convolution theorem. This is a crucial step since the process of filtering in Fourier space is basically just a convolution. For example, the convolution of a Dirac delta is just equal to the function itself on the location of the Dirac delta. Below are  Fourier Transform images of different patterns. &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SmAfL0cnWhI/AAAAAAAAAVc/-jt4M7lBtfM/s1600-h/twodots.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 201px; height: 102px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SmAfL0cnWhI/AAAAAAAAAVc/-jt4M7lBtfM/s400/twodots.png" alt="" id="BLOGGER_PHOTO_ID_5359317844488575506" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;FT of two dots is a sinusoid with a distinct frequency(Dirac delta at f).&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SmSHfK0qAwI/AAAAAAAAAWE/7RjSci5J5dQ/s1600-h/circle.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 211px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SmSHfK0qAwI/AAAAAAAAAWE/7RjSci5J5dQ/s400/circle.png" alt="" id="BLOGGER_PHOTO_ID_5360558426028638978" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;FT of circles of different radius. As we increase the radius of the circle the FT decreases in radius. This is expected. i.e., similar to the rect function since FT is anamorphic.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SmAZB1yF9wI/AAAAAAAAAUU/KJXAYWP09Vs/s1600-h/square.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 206px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SmAZB1yF9wI/AAAAAAAAAUU/KJXAYWP09Vs/s400/square.png" alt="" id="BLOGGER_PHOTO_ID_5359311075978639106" border="0" /&gt;&lt;/a&gt;FT of squares of different sides. Again as we increase the length of the side, the width of the FT decreases. In fact, the limit (side -&gt; inf) will result to a dirac delta (point).&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SmSHfRVm2gI/AAAAAAAAAWM/_i-9tXbH6Us/s1600-h/gauss.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 268px; height: 400px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SmSHfRVm2gI/AAAAAAAAAWM/_i-9tXbH6Us/s400/gauss.png" alt="" id="BLOGGER_PHOTO_ID_5360558427777456642" border="0" /&gt;&lt;/a&gt;FT of gaussian of varying variance. The unique property of a gaussian is that its FT is also a gaussian. Again similar to square and cirlces, as you increase the variance of  a gaussian its FT decreases in variance.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Comparing the imaginary and real part of gaussian and inverse gaussian.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;click on the image to ZOOM&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SmAlEE34URI/AAAAAAAAAVk/v4UUJcY2nKM/s1600-h/gauss1.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 192px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SmAlEE34URI/AAAAAAAAAVk/v4UUJcY2nKM/s400/gauss1.png" alt="" id="BLOGGER_PHOTO_ID_5359324308528714002" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SmAlEh_DvNI/AAAAAAAAAVs/nQyGcxWYTnU/s1600-h/gauss2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 191px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SmAlEh_DvNI/AAAAAAAAAVs/nQyGcxWYTnU/s400/gauss2.png" alt="" id="BLOGGER_PHOTO_ID_5359324316343450834" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SmAlEo1WGuI/AAAAAAAAAV0/SxK4nfdDpyQ/s1600-h/gauss3.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 192px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SmAlEo1WGuI/AAAAAAAAAV0/SxK4nfdDpyQ/s400/gauss3.png" alt="" id="BLOGGER_PHOTO_ID_5359324318181759714" border="0" /&gt;&lt;/a&gt;Gaussian of varying variance with the (a)[leftmost] image of gaussian (b) its real part (c) imag part (d) and FT  (e) [bottom] inverse gaussian image (f) real part of inv gaussian (g) imag part of inv gaussian and (h) FFT of inv gaussian.&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;Observe that the real part of the gaussian and inverse gaussian are the same.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Activity 7.B Fingerprints: Ridge Enhancement&lt;/span&gt;&lt;br /&gt;One of the use of filtering in Fourier space is through ridge enhancement of fingerprints. The process can be basically summarize as follows&lt;br /&gt;&lt;ul&gt;&lt;li style="text-align: justify;"&gt;the FT of the image (i.e, fingerprint - input) was obtained. In order to enhance the visibility of the frequencies, the FT was obtained in log scale.&lt;br /&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;The obtained FT was analyzed and was used as a template to create a mask that will enhance the frequencies of ridge while decreasing other unwanted frequencies.&lt;br /&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;It must be noted that use of binary mask is not too adviseable as this will pick only the desired frequencies but not enhance them relative to the other frequencies. Use of gradient mask or grayscale mask is more adviseable. If we know exactly the frequency of the object we want, we can maximize the pixel value of the mask at that location while blurring or decreasing the pixel value of other frequencies that we do not want.&lt;br /&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;In this example, the author was having a hard time separating the background from the frequency of the ridges. As as a solution, I use a gradient mask on the frequencies of the ridges while blurring it as you go away from the signal. Similarly for the zero order (background), a gradient mask was used which is darker at the center and increasingly bright moving away from the center. This was done because complete removal of the zero-order will not result to a very good reconstruction.&lt;br /&gt;&lt;/li&gt;&lt;/ul&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/_COm-OXWGnMQ/SmAdmXe3abI/AAAAAAAAAU0/wEOk2kBpYeE/s1600-h/fingerprint.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 384px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SmAdmXe3abI/AAAAAAAAAU0/wEOk2kBpYeE/s400/fingerprint.png" alt="" id="BLOGGER_PHOTO_ID_5359316101546600882" border="0" /&gt;&lt;/a&gt;For our purposes, this reconstruction is not the best reconstruction that could be achieve but its a start. The ridges are well defined and darkening of the background provided additional contrast. It is recommended however that further refining be done for better reconstruction.&lt;br /&gt;&lt;/div&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;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SmAeJXvl-tI/AAAAAAAAAU8/-gt_1HRIeuY/s1600-h/lunar.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 301px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SmAeJXvl-tI/AAAAAAAAAU8/-gt_1HRIeuY/s400/lunar.png" alt="" id="BLOGGER_PHOTO_ID_5359316702912182994" border="0" /&gt;&lt;/a&gt;From our previous discussion of FT, we know that the FT of vertical lines are two points symmetric about the center along the horizontal axis. The picture of the lunar above was filled with vertical lines resulting from stitching of several digital "framelets" to obtain a composite image. We can remove this in Fourier space by filtering the image using a mask by filtering the frequencies along the horizontal direction. (see mask used)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 7.D Canvass Weave Modelling and Removal&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/Snqpp1hsOzI/AAAAAAAAAdI/MDWGXPb22z0/s1600-h/canvass.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 289px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/Snqpp1hsOzI/AAAAAAAAAdI/MDWGXPb22z0/s400/canvass.png" alt="" id="BLOGGER_PHOTO_ID_5366788442173487922" border="0" /&gt;&lt;/a&gt;Similar to ridge enhancement we can remove the pattern created by the canvass weave using filtering in Fourier space. Observe that the canvass weave looks a lot like corrugated sinusoids, thus, we must remove frequencies along the vertical and horizontal side. Also by virtue of rotation, other frequencies might also be evident around the center. The presence of dots in the masked pattern was due to thresholding in scilab (i.e, img(img~=0)=1).&lt;br /&gt;&lt;br /&gt;For this activity, I give myself a grade of 10 for obtaining the requirements needed to complete the activity. However, I admit that the reconstructions I presented above are not the best reconstructions. Further research can be devoted to this area to provide better algorithms for filtering and pattern recognition.&lt;br /&gt;&lt;br /&gt;I would like to acknowledge Irene and Miguel for all the help they've given while doing this activity. (jokes, company and intellectual discussions)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;References&lt;/span&gt;&lt;br /&gt;[1] http://en.wikipedia.org/wiki/Noise&lt;br /&gt;[2] Applied Physics 186 Activity 7 Manual.&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/273950707063911697-8233971909035330255?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/8233971909035330255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/07/enhancement-in-frequency-domain.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/8233971909035330255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/8233971909035330255'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/07/enhancement-in-frequency-domain.html' title='Activity 7 Enhancement in the Frequency Domain'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_COm-OXWGnMQ/SmAfL0cnWhI/AAAAAAAAAVc/-jt4M7lBtfM/s72-c/twodots.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-1335332774533785799</id><published>2009-07-09T10:47:00.000+08:00</published><updated>2009-07-09T16:17:00.935+08:00</updated><title type='text'>Activity 6: Properties of the 2D Fourier Transform</title><content type='html'>&lt;div style="text-align: justify;"&gt;Fourier Theorem states that any function can be expressed as infinite sum of sinusoids of different frequencies. In imaging, this translates to finding the spatial frequencies of an image. In 2D FT, rotation of the image results to rotation of the resulting FT, we will investigate this property in a while but let us first familiarize ourselves with FT of different patterns [1]&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 6.A: Familiarization with FT of different 2D patterns&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Below is the FT of different patterns. A quick way to check if the result is correct is to imagine placing a mask(aperture) in front of a light source and observe the image in a screen far away. The resulting FT should have the somewhat the same symmetry as the object.&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlVb15EhVBI/AAAAAAAAAP8/yYaVdRkWIVM/s1600-h/square.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlVb15EhVBI/AAAAAAAAAP8/yYaVdRkWIVM/s400/square.PNG" alt="" id="BLOGGER_PHOTO_ID_5356288313238049810" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlVb1--8OkI/AAAAAAAAAQE/E49vuKAMuB4/s1600-h/FTsquare.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlVb1--8OkI/AAAAAAAAAQE/E49vuKAMuB4/s400/FTsquare.bmp" alt="" id="BLOGGER_PHOTO_ID_5356288314825259586" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVb2TmMwuI/AAAAAAAAAQM/isjbt5gbJ0A/s1600-h/square_annulus.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVb2TmMwuI/AAAAAAAAAQM/isjbt5gbJ0A/s400/square_annulus.PNG" alt="" id="BLOGGER_PHOTO_ID_5356288320358630114" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVb2VsIM3I/AAAAAAAAAQU/ur43kKH3AkQ/s1600-h/FTsqurea_ann.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVb2VsIM3I/AAAAAAAAAQU/ur43kKH3AkQ/s400/FTsqurea_ann.bmp" alt="" id="BLOGGER_PHOTO_ID_5356288320920367986" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Observe the difference with the square above, i.e. similar to subtracting terms in your diffraction. In Fresnel diffraction, this amounts to removing zones in your image.&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlVb2p0JZeI/AAAAAAAAAQc/V40InNI_N3I/s1600-h/donut.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlVb2p0JZeI/AAAAAAAAAQc/V40InNI_N3I/s400/donut.PNG" alt="" id="BLOGGER_PHOTO_ID_5356288326322709986" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlVciv0CxoI/AAAAAAAAAQk/eInj1AFJP_U/s1600-h/FTdonut.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 127px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlVciv0CxoI/AAAAAAAAAQk/eInj1AFJP_U/s400/FTdonut.bmp" alt="" id="BLOGGER_PHOTO_ID_5356289083847132802" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlVci4trN6I/AAAAAAAAAQ0/A-SXFNirkLQ/s1600-h/slits_span.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlVci4trN6I/AAAAAAAAAQ0/A-SXFNirkLQ/s400/slits_span.PNG" alt="" id="BLOGGER_PHOTO_ID_5356289086236342178" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVci7PGRPI/AAAAAAAAAQs/AfRHLaA6dTo/s1600-h/FTslit_s.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVci7PGRPI/AAAAAAAAAQs/AfRHLaA6dTo/s400/FTslit_s.bmp" alt="" id="BLOGGER_PHOTO_ID_5356289086913398002" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Textbook example of two slits along the x-axis (see Hecht, section diffraction on Fraunhoffer diffraction)&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlVcjfDtM-I/AAAAAAAAARE/nKscY_B8z_8/s1600-h/slits_center.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlVcjfDtM-I/AAAAAAAAARE/nKscY_B8z_8/s400/slits_center.PNG" alt="" id="BLOGGER_PHOTO_ID_5356289096529294306" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlVcjGT33zI/AAAAAAAAAQ8/WKmH2uaLWYI/s1600-h/FTslit_c.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 126px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlVcjGT33zI/AAAAAAAAAQ8/WKmH2uaLWYI/s400/FTslit_c.bmp" alt="" id="BLOGGER_PHOTO_ID_5356289089886215986" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The FT of two dots is a sinousoid. This is textbook example of Young's double slit experiment.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 6.B: Anamorphic Property of the Fourier Transform&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlVgDXhrUhI/AAAAAAAAARM/f0SrvBjVl9U/s1600-h/sinusoid.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlVgDXhrUhI/AAAAAAAAARM/f0SrvBjVl9U/s400/sinusoid.bmp" alt="" id="BLOGGER_PHOTO_ID_5356292942798213650" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlVgD7-5GPI/AAAAAAAAARc/GVQ_Lc39b3U/s1600-h/FTsinusoid.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlVgD7-5GPI/AAAAAAAAARc/GVQ_Lc39b3U/s400/FTsinusoid.bmp" alt="" id="BLOGGER_PHOTO_ID_5356292952584427762" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sinusoid of frequency 4 generated using sin(2*pi*f*x).&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlVgDh3sFrI/AAAAAAAAARU/ZIGstr_wIGA/s1600-h/sinusoid_f8.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlVgDh3sFrI/AAAAAAAAARU/ZIGstr_wIGA/s400/sinusoid_f8.bmp" alt="" id="BLOGGER_PHOTO_ID_5356292945574893234" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVgEMMZBSI/AAAAAAAAARk/Dn7YOtmCQ2Y/s1600-h/FTsinusoid_f8.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVgEMMZBSI/AAAAAAAAARk/Dn7YOtmCQ2Y/s400/FTsinusoid_f8.bmp" alt="" id="BLOGGER_PHOTO_ID_5356292956936013090" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Sinusoid of frequency 8. The dots are more widely separated. Imagine placing a frequency axis on the y-axis above. The higher the frequency of the sinusoid, the farther apart the dots.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In digital imaging, there is no negative values, adding a bias to an image results to the presence of zero order. This is exactly what happens when we add bias to the image of the sinusoids above.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlVhFBL3OZI/AAAAAAAAARs/TAfsxdAY0kg/s1600-h/FTsinusoid_bias.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlVhFBL3OZI/AAAAAAAAARs/TAfsxdAY0kg/s400/FTsinusoid_bias.bmp" alt="" id="BLOGGER_PHOTO_ID_5356294070672505234" border="0" /&gt;&lt;/a&gt;Sinusoid of frequency 4 with bias. The center dot is the zero-order frequency. In electronics, we can imagine a DC bias or in imaging, the image is offset by the background.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Suppose then that we took a picture of an interferogram, we can obtain the actual frequencies of the object by adding a constant bias to the image (i.e., min value). Or we just obtain the FT and neglect the zero order frequency. However, if the resulting interferogram has non-constant bias then we can add a filter to obtain the desired frequencies. For example, suppose that the image was added with very low frequency sinusoids. We can obtain the frequencies by obtaining the FT of the image and multiply the resulting FT with a high pass filter (i.e, to remove the low frequencies) and then obtain the inverse FT to get the final image of the object. Depending on the bias, we can adjust the filter to obtain the desired frequencies.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In 2D FT, rotating the sinusoids result to a rotated FT.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlVh9AvoKWI/AAAAAAAAAR0/x9XlFW16nDA/s1600-h/sinusoid_rotated2.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlVh9AvoKWI/AAAAAAAAAR0/x9XlFW16nDA/s400/sinusoid_rotated2.bmp" alt="" id="BLOGGER_PHOTO_ID_5356295032626751842" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVh9erkByI/AAAAAAAAAR8/IgoPSMaqQqA/s1600-h/FTsinusoid_rotated.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVh9erkByI/AAAAAAAAAR8/IgoPSMaqQqA/s400/FTsinusoid_rotated.bmp" alt="" id="BLOGGER_PHOTO_ID_5356295040662767394" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Rotated sinusoid with its corresponding FT. Observe that the resulting FT is also rotated in the same direction as the object.&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlViRWOfSEI/AAAAAAAAASM/GLxcjxFTcnU/s1600-h/corrugated_roofs2.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlViRWOfSEI/AAAAAAAAASM/GLxcjxFTcnU/s400/corrugated_roofs2.bmp" alt="" id="BLOGGER_PHOTO_ID_5356295381990721602" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlViRPi9g3I/AAAAAAAAASE/eLExrF0YPOA/s1600-h/FTcorrugated_roofs.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlViRPi9g3I/AAAAAAAAASE/eLExrF0YPOA/s400/FTcorrugated_roofs.bmp" alt="" id="BLOGGER_PHOTO_ID_5356295380197540722" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Fourier transform of combination of sinusoids. Left: multiplication of two corrugated roofs, in the X and Y direction and right: FT of the object, 4 dots of the same distance signifying same frequency in the X and Y direction.&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlViroprdNI/AAAAAAAAASk/npwncpysL_8/s1600-h/cor_add_f16_90rot.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlViroprdNI/AAAAAAAAASk/npwncpysL_8/s400/cor_add_f16_90rot.bmp" alt="" id="BLOGGER_PHOTO_ID_5356295833613202642" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;We added a rotated sinusoid to the corrugated image above using different frequency (f=16 and rotated for 90 degrees). Observe the presence of the 4 dots similar above and the addition of two dots.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVireVM6DI/AAAAAAAAASc/ijR-Aovruw0/s1600-h/cor_add_f12_30rot.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 127px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVireVM6DI/AAAAAAAAASc/ijR-Aovruw0/s400/cor_add_f12_30rot.bmp" alt="" id="BLOGGER_PHOTO_ID_5356295830842959922" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;We added a different rotated sinusoid using different frequency (f=12 and rotated for 30 degrees).&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlVireXlXAI/AAAAAAAAASU/0FCysSpVQp4/s1600-h/cor_add_f8_60rot.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlVireXlXAI/AAAAAAAAASU/0FCysSpVQp4/s400/cor_add_f8_60rot.bmp" alt="" id="BLOGGER_PHOTO_ID_5356295830852951042" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Added rotated sinusoid of f=8 and rotated for 60 degrees.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlVisNJPUYI/AAAAAAAAASs/o6W9kmNeh1g/s1600-h/cor_add_all.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlVisNJPUYI/AAAAAAAAASs/o6W9kmNeh1g/s400/cor_add_all.bmp" alt="" id="BLOGGER_PHOTO_ID_5356295843409252738" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Combination of all the above rotated sinusoids. Here we can see that the result is just the addition of all the FT of the different rotated sinusoids. This is because FT is a linear transform, i.e.,&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;let X=A+B+C then F{X} = F{A} + F{B} + F{C}&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: justify;"&gt;Here, we investigated the different properties of the 2D Fourier Transform, in particular&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;rotation of the object results to a rotated FT&lt;/li&gt;&lt;li&gt;FT is a linear transform&lt;/li&gt;&lt;li&gt;FT obtains the spatial frequencies of the image&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;For this activity, I give myself a grade of 10 for doing the required objectives.&lt;br /&gt;&lt;br /&gt;I would like to acknowledge miguel and martin for useful discussions and master for knowing the spelling of Hecht =).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;References:&lt;br /&gt;&lt;/span&gt;[1] Activity 6 Manual&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlVgEMMZBSI/AAAAAAAAARk/Dn7YOtmCQ2Y/s1600-h/FTsinusoid_f8.bmp"&gt;&lt;br /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-1335332774533785799?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/1335332774533785799/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/07/properties-of-2d-fourier-transform.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/1335332774533785799'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/1335332774533785799'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/07/properties-of-2d-fourier-transform.html' title='Activity 6: Properties of the 2D Fourier Transform'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_COm-OXWGnMQ/SlVb15EhVBI/AAAAAAAAAP8/yYaVdRkWIVM/s72-c/square.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-6686437713986263308</id><published>2009-07-07T10:29:00.000+08:00</published><updated>2009-07-09T13:45:05.458+08:00</updated><title type='text'>Activity 5: Fourier Transform Model of Image Formation</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Lens as a Fourier Transform&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;Activity 5.A Familiarization with discrete FFT&lt;br /&gt;&lt;/span&gt;Using the built-in FT of scilab, fft2, we are going to obtain the FFT of different patterns.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlK0nO_wDhI/AAAAAAAAAM0/3pKUZI3Uel8/s1600-h/circle.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 124px; height: 120px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlK0nO_wDhI/AAAAAAAAAM0/3pKUZI3Uel8/s400/circle.bmp" alt="" id="BLOGGER_PHOTO_ID_5355541493030325778" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlK0mybC6dI/AAAAAAAAAMs/XpALL8FVQyg/s1600-h/Ftcircle.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 123px; height: 122px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlK0mybC6dI/AAAAAAAAAMs/XpALL8FVQyg/s400/Ftcircle.bmp" alt="" id="BLOGGER_PHOTO_ID_5355541485360179666" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Left: image of circle, right: Fourier transform of circle. As expected, the FT is a bright spot most intense in the center, imagine imaging uniform disk of same intensity.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlK29vOcCTI/AAAAAAAAANM/B56E58DmqXU/s1600-h/A.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 118px; height: 118px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlK29vOcCTI/AAAAAAAAANM/B56E58DmqXU/s400/A.PNG" alt="" id="BLOGGER_PHOTO_ID_5355544078662240562" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlK291KikLI/AAAAAAAAANU/yR1zln1IZ6A/s1600-h/FT_A2.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 123px; height: 120px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlK291KikLI/AAAAAAAAANU/yR1zln1IZ6A/s400/FT_A2.bmp" alt="" id="BLOGGER_PHOTO_ID_5355544080256503986" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Left: image of letter 'A' and right: Fourier tranform of circle. The resulting FT has higher frequency components as expected from the shape of letter A.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 5.B Convolution: Simulation of an imaging device&lt;/span&gt;&lt;br /&gt;The representation of an image using an imaging device is not a perfect reconstruction but is a "smeared/convolve" image of the original image. Consider the equation below in frequency space&lt;br /&gt;&lt;div style="text-align: center;"&gt;H=FG&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;Where F is the transfer function of the imaging device and G is the original image. The convolution of f and g results to the image we actually see. In frequency space, by the Convolution theorem, this is just the multiplication of the linear transform (i.e, Laplace of Fourier) of f and g. We simulate an imaging device using an aperture as our transfer function (i.e, this can be modeled as a lens) and convolve to an image of our choice. Below is the image of letters "VIP" which we are going to image using different sets of apertures.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlK7fYHclAI/AAAAAAAAANk/sGuDQQFUPlg/s1600-h/VIP.PNG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlK7fYHclAI/AAAAAAAAANk/sGuDQQFUPlg/s320/VIP.PNG" alt="" id="BLOGGER_PHOTO_ID_5355549054620963842" border="0" /&gt;&lt;/a&gt;Original image that we will image.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlK89MckN3I/AAAAAAAAAN8/0M-CxQkn3cs/s1600-h/VIPrecon4.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 126px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlK89MckN3I/AAAAAAAAAN8/0M-CxQkn3cs/s400/VIPrecon4.bmp" alt="" id="BLOGGER_PHOTO_ID_5355550666396022642" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlK89fanMaI/AAAAAAAAAOE/lHmTpRbYbNQ/s1600-h/aperture4.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlK89fanMaI/AAAAAAAAAOE/lHmTpRbYbNQ/s400/aperture4.PNG" alt="" id="BLOGGER_PHOTO_ID_5355550671488102818" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;Left: Convolution of the original image using the aperture on the right. Observe that the resulting image is blurry (i.e., diffraction effect). We can imagine in our real life model, i.e lens, that the aperture did not collect sufficient amount of photons resulting to blurry image or the other way to put it is that the NA (numerical aperture) of the lens is very low.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlK7uhUVfPI/AAAAAAAAAN0/yyV-xeuzI48/s1600-h/VIPrecon1.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlK7uhUVfPI/AAAAAAAAAN0/yyV-xeuzI48/s400/VIPrecon1.bmp" alt="" id="BLOGGER_PHOTO_ID_5355549314788982002" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlK7uEwNdRI/AAAAAAAAANs/jxVcDssDnC0/s1600-h/aperture1.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlK7uEwNdRI/AAAAAAAAANs/jxVcDssDnC0/s400/aperture1.PNG" alt="" id="BLOGGER_PHOTO_ID_5355549307121267986" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;Left: Convolution of the FT of the aperture in the right with the original image. Observe the significant change in resolution when we increase the size of the aperture. (increase NA)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlK89hTlIUI/AAAAAAAAAOM/GDwHZHkOYPo/s1600-h/VIPrecon2.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 127px; height: 128px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlK89hTlIUI/AAAAAAAAAOM/GDwHZHkOYPo/s400/VIPrecon2.bmp" alt="" id="BLOGGER_PHOTO_ID_5355550671995478338" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlK89tAd6RI/AAAAAAAAAOU/bdl3orpOiNE/s1600-h/aperture2.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlK89tAd6RI/AAAAAAAAAOU/bdl3orpOiNE/s400/aperture2.PNG" alt="" id="BLOGGER_PHOTO_ID_5355550675136538898" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Left: Convolution of the FT of the aperture in the right with the original image. Further increase in the aperture results to better resolution.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlK-b2aLJOI/AAAAAAAAAOc/GzQHmzD-zGQ/s1600-h/VIPrecon3.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlK-b2aLJOI/AAAAAAAAAOc/GzQHmzD-zGQ/s400/VIPrecon3.bmp" alt="" id="BLOGGER_PHOTO_ID_5355552292567983330" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlK-cG1f0-I/AAAAAAAAAOk/RXP4Aen42p4/s1600-h/aperture3.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlK-cG1f0-I/AAAAAAAAAOk/RXP4Aen42p4/s400/aperture3.PNG" alt="" id="BLOGGER_PHOTO_ID_5355552296977552354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Left: Convolution of the FT of the aperture in the right with the original image. The largest apertuer that we can construct. Although observe that even with the highest NA, we cannot replicate the original image (i.e, presence of blurring at the edges) this is because in the mathematics of Fourier Analysis, in order to perfectly reconstruct we must have infinite coefficients to represent a function, but in our case, we are limited to discrete frequencies.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 5.C: Template Matching using correlation&lt;/span&gt;&lt;br /&gt;Correlation is basically finding the overlap of two functions. Thus, it can be used for pattern matching.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlLAC3c5gBI/AAAAAAAAAO0/i2mKHA2OAB0/s1600-h/COR_RAIN.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlLAC3c5gBI/AAAAAAAAAO0/i2mKHA2OAB0/s400/COR_RAIN.PNG" alt="" id="BLOGGER_PHOTO_ID_5355554062374371346" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlLACid-j8I/AAAAAAAAAOs/gGH41na3lCE/s1600-h/COR_A.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlLACid-j8I/AAAAAAAAAOs/gGH41na3lCE/s400/COR_A.PNG" alt="" id="BLOGGER_PHOTO_ID_5355554056741752770" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlLADHlk3XI/AAAAAAAAAO8/p1DBRZmG_a0/s1600-h/cor_result.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlLADHlk3XI/AAAAAAAAAO8/p1DBRZmG_a0/s400/cor_result.bmp" alt="" id="BLOGGER_PHOTO_ID_5355554066705735026" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"The rain...": Image that we will correlate with the image with letter 'A'. The resulting image results with the all the letter 'A' in the image to have high intensity (appear white in the result).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Activity 6.D: Edge Detection&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Using similar concept as above, we can correlate an image with different patterns and thus highlighting those parts that we need depending on the pattern.&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlLBu-znRSI/AAAAAAAAAPU/QbIRzQefBRA/s1600-h/pattern3.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 150px; height: 150px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SlLBu-znRSI/AAAAAAAAAPU/QbIRzQefBRA/s400/pattern3.bmp" alt="" id="BLOGGER_PHOTO_ID_5355555919774565666" border="0" /&gt;&lt;/a&gt;&lt;img src="file:///Users/orly/Library/Caches/TemporaryItems/moz-screenshot.jpg" alt="" /&gt;&lt;img src="file:///Users/orly/Library/Caches/TemporaryItems/moz-screenshot-1.jpg" alt="" /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlMp0tZqlcI/AAAAAAAAAP0/uIFP-CuD4KQ/s1600-h/pattern3.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 135px; height: 85px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlMp0tZqlcI/AAAAAAAAAP0/uIFP-CuD4KQ/s400/pattern3.png" alt="" id="BLOGGER_PHOTO_ID_5355670367390832066" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;br /&gt;Edge detection using the pattern in the right. As observed, the pattern can be deduced to detect all point in the edges.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlLBujG7RZI/AAAAAAAAAPM/nJhm76GUOZk/s1600-h/pattern2.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 150px; height: 146px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlLBujG7RZI/AAAAAAAAAPM/nJhm76GUOZk/s400/pattern2.bmp" alt="" id="BLOGGER_PHOTO_ID_5355555912339375506" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlMp0i_Uj2I/AAAAAAAAAPs/pGmirHR9MzE/s1600-h/pattern2.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 135px; height: 95px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlMp0i_Uj2I/AAAAAAAAAPs/pGmirHR9MzE/s400/pattern2.png" alt="" id="BLOGGER_PHOTO_ID_5355670364595982178" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Edge detection using a vertical pattern, as expected, all the vertical parts of the letter VIP are highlighted.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlLBuRROz5I/AAAAAAAAAPE/tBrXP66ofmE/s1600-h/pattern1.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 150px; height: 150px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlLBuRROz5I/AAAAAAAAAPE/tBrXP66ofmE/s400/pattern1.bmp" alt="" id="BLOGGER_PHOTO_ID_5355555907550760850" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlMp0fgJ8rI/AAAAAAAAAPk/i1u5USoqHYw/s1600-h/pattern1.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 135px; height: 86px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlMp0fgJ8rI/AAAAAAAAAPk/i1u5USoqHYw/s400/pattern1.png" alt="" id="BLOGGER_PHOTO_ID_5355670363659956914" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Edge detection using horizontal pattern. The horizontal edges are highlighted.&lt;br /&gt;It must be noted that the sum of the matrix in the pattern is zero.&lt;br /&gt;&lt;br /&gt;For this activity, I give myself a grade of 10 for performing all the requirements needed.&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/273950707063911697-6686437713986263308?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/6686437713986263308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.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/273950707063911697/posts/default/6686437713986263308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/6686437713986263308'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/07/activity-5-fourier-transform-model-of.html' title='Activity 5: Fourier Transform Model of Image Formation'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_COm-OXWGnMQ/SlK0nO_wDhI/AAAAAAAAAM0/3pKUZI3Uel8/s72-c/circle.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-1070926403793470852</id><published>2009-07-01T21:08:00.001+08:00</published><updated>2009-07-07T19:06:39.738+08:00</updated><title type='text'>Activity 4: Enhancement by Histogram Manipulation</title><content type='html'>By looking at the histogram of an image, one can can determine wether the image is too bright or too dark, has poor or good contrast, i.e, if it has good dynamic range. Usually, we want an image to span all the gray levels resulting to a high contrast image. By manipulating the histogram of an image we can improve the quality of the image highlighting or enhancing certain features, or  depending on the user, can mimick other imaging system[1].&lt;br /&gt;&lt;br /&gt;The histogram of an image when normalized is equal to graylevel probability distribution function (PDF). We can alter the PDF of our image to the desired PDF by backprojecting the grayscale level values of the desired cumulative distribution function (CDF) to the grayscale values of the original CDF.&lt;br /&gt;&lt;br /&gt;The steps in overview are as follows:&lt;br /&gt;1. Per pixel in the image having grayscale r, find its CDF value T(r).&lt;br /&gt;2. Find the value of T(r) in the y-axis of the desired CDF G(z).&lt;br /&gt;3. Find the z value of this G(z).&lt;br /&gt;4. Replace the image with grayscale value r to grayscale value z.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SkuOx68kw7I/AAAAAAAAAJk/NeOzV7uyVow/s1600-h/steps.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 171px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SkuOx68kw7I/AAAAAAAAAJk/NeOzV7uyVow/s400/steps.JPG" alt="" id="BLOGGER_PHOTO_ID_5353529570348024754" border="0" /&gt;&lt;/a&gt;This process is called HISTOGRAM EQUALIZATION.&lt;br /&gt;&lt;br /&gt;I have provided two methods in solving the problem, the difference is essentially in obtaining the PDF and CDF of the image. In the first solution, we use binning (middle of bin, i.e, 0.5, 1.5...254.5) in obtaining the histogram of the image. In the second solution, we use the function &lt;span style="font-weight: bold;"&gt;tabul &lt;/span&gt;of scilab which tabulates the frequency of distinct grayscale level values.&lt;br /&gt;&lt;br /&gt;1st solution:&lt;span style="color: rgb(255, 102, 102);font-size:85%;" &gt;&lt;br /&gt;&lt;br /&gt;directory = 'C:\Documents and Settings\Orly\Desktop\AP186\Activity 4';&lt;br /&gt;chdir(directory);&lt;br /&gt;//load image in grayscale&lt;br /&gt;img1=gray_imread('img2.png');&lt;br /&gt;img2=img1; //holder&lt;br /&gt;//obtain the histogram&lt;br /&gt;bits=255;&lt;br /&gt;bins = 0.5:bits; bins = bins./bits; //bins for [0,1] image.&lt;br /&gt;for i=1:bits,&lt;br /&gt;frequency(i) = sum(img1&gt;=(bins(i)-1/(2*bits))&amp;amp;img1&lt;(bins(i)+1/(2*bits))); end; frequency = frequency./max(cumsum(frequency)); f1=scf(1); plot(bins.*bits, frequency); //normalized histogram f2=scf(2); cdf = cumsum(frequency); //cumulative distribution function plot(bins.*bits,cdf); //desired cdf is a straight line, can be change descdf = (0:1.0/(length(cdf)-1):1); f3=scf(3); plot(bins.*bits, descdf); //mapping for i=1:bits-1,   index = find(descdf&gt;=cdf(i) &amp;amp; descdf&lt;cdf(i+1)); returns="" index="" if=""&gt;=1 then //satisfied condtion above&lt;br /&gt;//get first index&lt;br /&gt;imgval = bins(index(1)); //desired pixel value&lt;br /&gt;imgcur = bins(i); //current pixel value of image&lt;br /&gt;img2(img2&gt;=(imgcur-1/(2*bits))&amp;amp;img2&lt;(imgcur+1/(2*bits))) = imgval;   end, end; //for comparison of images f4=scf(4); imshow(img1); f5=scf(5); imshow(img2); //check the resulting CDF and PDF of the equalized image for i=1:bits,   frequency2(i) = sum(img2&gt;=(bins(i)-1/(2*bits))&amp;amp;img2&lt;(bins(i)+1/(2*bits))); end; f6=scf(6); plot(bins.*bits, frequency2./max(cumsum(frequency2))); f7=scf(7); plot(bins.*bits, cumsum(frequency2)./max(cumsum(frequency2)))&lt;/cdf(i+1));&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The image below is the original image which we will use to demonstrate contrast enhancement.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/Skuj-_iEsjI/AAAAAAAAALs/Puu_Ytk6NR0/s1600-h/img2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 200px; height: 200px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/Skuj-_iEsjI/AAAAAAAAALs/Puu_Ytk6NR0/s200/img2.png" alt="" id="BLOGGER_PHOTO_ID_5353552884661531186" border="0" /&gt;&lt;/a&gt;Poor contrast image&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SkuSeoprFpI/AAAAAAAAAJ8/pjQ4z0JQp7Y/s1600-h/hist_orig_1.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 302px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SkuSeoprFpI/AAAAAAAAAJ8/pjQ4z0JQp7Y/s400/hist_orig_1.gif" alt="" id="BLOGGER_PHOTO_ID_5353533637065905810" border="0" /&gt;&lt;/a&gt;Histogram of the original image, min = 0.5, max =181.5&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkuSecC57zI/AAAAAAAAAJ0/ltU9GVq6FWc/s1600-h/CDF_orig_1.gif"&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/_COm-OXWGnMQ/SkuSecC57zI/AAAAAAAAAJ0/ltU9GVq6FWc/s400/CDF_orig_1.gif" alt="" id="BLOGGER_PHOTO_ID_5353533633682075442" border="0" /&gt;&lt;/a&gt;CDF of the original image.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/Skua3-BFCtI/AAAAAAAAAKk/r6WG_-vGnnk/s1600-h/des_CDF.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 302px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/Skua3-BFCtI/AAAAAAAAAKk/r6WG_-vGnnk/s400/des_CDF.gif" alt="" id="BLOGGER_PHOTO_ID_5353542868390972114" border="0" /&gt;&lt;/a&gt;Desired CDF which is just the CDF of a uniform distribution&lt;br /&gt;&lt;div style="text-align: left;"&gt;Using the above code, the resulting image and histograms is as follows.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkujbzunH_I/AAAAAAAAALk/FXzb4uO2hHo/s1600-h/combination.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 200px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkujbzunH_I/AAAAAAAAALk/FXzb4uO2hHo/s400/combination.png" alt="" id="BLOGGER_PHOTO_ID_5353552280197472242" border="0" /&gt;&lt;/a&gt;Resulting image: Note that in our process, we span all the gray levels and redistribute them in the image in a uniform process. The midtones are enhanced but the problem is the image got saturated on parts with high gray level and too much shadows on parts with low gray level value. Also, the result is a bit noisy compared to the original.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SkuVWvZ9KzI/AAAAAAAAAKU/IIYXtJrx_Jo/s1600-h/result_hist.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 302px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SkuVWvZ9KzI/AAAAAAAAAKU/IIYXtJrx_Jo/s400/result_hist.gif" alt="" id="BLOGGER_PHOTO_ID_5353536799974959922" border="0" /&gt;&lt;/a&gt;Histogram of the resulting image, min = 0.5, max =253.5. The contrast of the resulting image base on the minimum and maximum gray values increased dramatically.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SkuVW9Daq9I/AAAAAAAAAKc/GfvMY75Yrjc/s1600-h/result_CDF.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 302px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SkuVW9Daq9I/AAAAAAAAAKc/GfvMY75Yrjc/s400/result_CDF.gif" alt="" id="BLOGGER_PHOTO_ID_5353536803638520786" border="0" /&gt;&lt;/a&gt;The  CDF of the resulting image follows the shape of the desired CDF above.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Main problem encountered with the above solution is that for those images with limited dynamic range (i.e, 100-150), the resulting image would be too saturated for those pixels with higher pixel value (130-150) and too dark for those pixels with lower pixel value (100-120) because essentially, we are uniformly stretching the image into all the gray levels (0-255). The resulting image might not be too pleasing but it would have better dynamic range.&lt;br /&gt;&lt;br /&gt;Another solution for this is to uniformly distribute the image (i.e, linear CDF) in the range of the original histogram. (i.e., from 100-150). In essence, we LOCALIZED the histogram equalization.&lt;br /&gt;&lt;br /&gt;2nd Solution&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);font-size:85%;" &gt;directory = 'C:\Documents and Settings\UP DILIMAN\Desktop\ORLY\Acads\AP186\Activity 4';&lt;br /&gt;chdir(directory);&lt;br /&gt;&lt;br /&gt;//load image in grayscale&lt;br /&gt;img1=gray_imread('img2.png');&lt;br /&gt;info = imfinfo('img2.png');&lt;br /&gt;img2=img1; //holder&lt;br /&gt;bits=(2^info.Depth)-1;&lt;br /&gt;//find frequency of distinct values&lt;br /&gt;hist=tabul(img1,'i'); //arrange in increasing order&lt;br /&gt;frequency = hist(:,2)./max(cumsum(hist(:,2))); //normalized frequency&lt;br /&gt;bins=hist(:,1);&lt;br /&gt;&lt;br /&gt;//displaying histogram&lt;br /&gt;histogram=fhistogram(img1, info.Depth);&lt;br /&gt;frequency2 = histogram(:,2)./max(cumsum(histogram(:,2)));&lt;br /&gt;f1=scf(1);&lt;br /&gt;plot(histogram(:,1).*bits, frequency2);&lt;br /&gt;&lt;br /&gt;//find the minimum and maximum grayscale values&lt;br /&gt;index=find(frequency~=0);&lt;br /&gt;minB = bins(index(1))*255;&lt;br /&gt;maxB = bins(index(length(index)))*255;&lt;br /&gt;&lt;br /&gt;f2=scf(2);&lt;br /&gt;cdf = cumsum(frequency);&lt;br /&gt;plot(bins.*bits,cdf);&lt;br /&gt;//desired cdf is a straight line, can be change&lt;br /&gt;descdf = (min(cdf):(max(cdf)-min(cdf))/(length(cdf)-1):max(cdf));&lt;br /&gt;desbins = (min(bins):(max(bins)-min(bins))/(length(bins)-1):max(bins));&lt;br /&gt;f3=scf(3);&lt;br /&gt;plot(desbins.*255, descdf);&lt;br /&gt;&lt;br /&gt;//mapping&lt;br /&gt;for i=1:length(bins)-1,&lt;br /&gt;//returns the index in descdf where cdf(i) belongs&lt;br /&gt;index = find(descdf&gt;=cdf(i)); //returns a list of indices&lt;br /&gt;if sum(index)&gt;=1 then&lt;br /&gt;//get first index&lt;br /&gt;imgval = desbins(index(1)); //desired pixel value&lt;br /&gt;imgcur = bins(i); //current pixel value&lt;br /&gt;img2(img2==imgcur) = imgval;&lt;br /&gt;else&lt;br /&gt;x_message('cdf index is' + string(i));&lt;br /&gt;end,&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;f4=scf(4);&lt;br /&gt;imshow(img1);&lt;br /&gt;f5=scf(5);&lt;br /&gt;imshow(img2);&lt;br /&gt;f6=scf(6);&lt;br /&gt;histogram2=fhistogram(img2, info.Depth);&lt;br /&gt;frequency3 = histogram2(:,2)./max(cumsum(histogram2(:,2)));&lt;br /&gt;plot(histogram2(:,1).*bits, frequency3);&lt;br /&gt;f7=scf(7);&lt;br /&gt;plot(histogram2(:,1).*bits, cumsum(frequency3));&lt;br /&gt;&lt;br /&gt;code of filename: fhistogram.sce&lt;br /&gt;&lt;br /&gt;function histogram = fhistogram(img, depth)&lt;br /&gt;bits=(2^depth)-1;&lt;br /&gt;histogram = zeros(bits,2);&lt;br /&gt;bins = 0.5:bits; bins = bins./bits; //bins for [0,1] image.&lt;br /&gt;for i=1:bits,&lt;br /&gt;frequency(i) = sum(img&gt;=(bins(i)-1/(2*bits))&amp;amp;img&lt;(bins(i)+1/(2*bits)));   end;   histogram(:,1)=bins';   histogram(:,2)=frequency; endfunction  &lt;/span&gt;&lt;br /&gt;Using tabul, the bins are the distinct grayscale values and the frequency is just the occurrence of that distinct grayscale value.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SkujbyKtm-I/AAAAAAAAALc/xkANXtsboCs/s1600-h/combination.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 199px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SkujbyKtm-I/AAAAAAAAALc/xkANXtsboCs/s400/combination.png" alt="" id="BLOGGER_PHOTO_ID_5353552279778466786" border="0" /&gt;&lt;/a&gt;Resulting image after mapping. Note that the image has better contrast compared to the reconstruction using the first method. The advantage of this reconstruction is that, the image would not be too saturated on some areas and too dark on other areas because we uniformly distributed the image in the range of the min and max grayscale values.&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SkxRMylr-aI/AAAAAAAAAL0/x8NCacyw3x8/s1600-h/histo_result.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 302px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SkxRMylr-aI/AAAAAAAAAL0/x8NCacyw3x8/s400/histo_result.gif" alt="" id="BLOGGER_PHOTO_ID_5353743337216801186" border="0" /&gt;&lt;/a&gt;Resulting histogram, min=0, max=182&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SkxRNGrsdWI/AAAAAAAAAL8/TUKnsmv3vUQ/s1600-h/cdf_result.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 302px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SkxRNGrsdWI/AAAAAAAAAL8/TUKnsmv3vUQ/s400/cdf_result.gif" alt="" id="BLOGGER_PHOTO_ID_5353743342610707810" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: center;"&gt;Resulting CDF, note that it is almost similar to the desired CDF.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;By defining another set of bins ('desbins') that are also uniform in the min and max grayscale level values, we have essentially equally redistributed the histogram of the image.&lt;br /&gt;&lt;br /&gt;Using other images:&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkxWJ0hW1GI/AAAAAAAAAME/AElH7fm8wjA/s1600-h/xray_combined.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 178px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkxWJ0hW1GI/AAAAAAAAAME/AElH7fm8wjA/s400/xray_combined.png" alt="" id="BLOGGER_PHOTO_ID_5353748783754040418" border="0" /&gt;&lt;/a&gt;Original: left, Contrast enhanced: right. The reconstructed image has better contrast compared to the original image. Image obtained from source [2].&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/Skxb-arNGNI/AAAAAAAAAMU/Tc2ejTy6LBU/s1600-h/face2_combined.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 198px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/Skxb-arNGNI/AAAAAAAAAMU/Tc2ejTy6LBU/s400/face2_combined.png" alt="" id="BLOGGER_PHOTO_ID_5353755184907229394" border="0" /&gt;&lt;/a&gt;Original: left, Reconstructed: right. Note that the effect of the histogram equalization is not quite visible. This is because the dynamic range of the image is limited as can be seen in the histogram and CDF of the reconstructed image. Image was obtained from source [3].&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/Skxb9h_cqzI/AAAAAAAAAMM/AKibD1hjk0Y/s1600-h/cdf_hist_combined.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 150px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/Skxb9h_cqzI/AAAAAAAAAMM/AKibD1hjk0Y/s400/cdf_hist_combined.png" alt="" id="BLOGGER_PHOTO_ID_5353755169691314994" border="0" /&gt;&lt;/a&gt;Note that in this histogram and CDF, we can see clearly how the method works. The histogram was equally distributed in the range of the histogram (min - max) hence the resulting CDF is linear in that range only.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;USING OTHER CDF:&lt;br /&gt;&lt;/span&gt;As a proof of principle, we use an exponential CDF to demonstrate what happens on the image when using nonlinear CDF. Depending on the user, we can opt to highlight the darker areas (low grayscale values), the whiter areas (high grayscale values) or the midtones (middle grayscale values). When highlighting the darker areas, we can use logarithmic CDF, when highlighting whiter areas, we can use exponential CDF and when highlighting the midtones we can use S-curve CDF.&lt;br /&gt;&lt;br /&gt;The code above can be altered by defining the appropriate desired CDF. We just inserted the following code:&lt;br /&gt;&lt;span style="font-size:85%;"&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;desbins = (min(bins):(max(bins)-min(bins))/(length(bins)-1):max(bins));&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;sigma =2; //strength of exponential&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;descdf = exp(sigma*desbins);&lt;br /&gt;descdf = (descdf - descdf(1))./max(descdf-descdf(1));&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Resulting image using exponential CDF. Note that the resulting image highlighted the higher grayscale values (whiter areas) as expected from the shape of an exponential curve.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SkxzEAxXgrI/AAAAAAAAAMc/vGr7E92Ruic/s1600-h/exp_combined.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 198px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SkxzEAxXgrI/AAAAAAAAAMc/vGr7E92Ruic/s400/exp_combined.png" alt="" id="BLOGGER_PHOTO_ID_5353780569800409778" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/Skx1lwy5xPI/AAAAAAAAAMk/cl_IoXp6olE/s1600-h/exp_combined_cdf.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 151px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/Skx1lwy5xPI/AAAAAAAAAMk/cl_IoXp6olE/s400/exp_combined_cdf.png" alt="" id="BLOGGER_PHOTO_ID_5353783348650689778" border="0" /&gt;&lt;/a&gt;Left: Desired CDF, Right: CDF of the resulting image.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;We have provided a solution for contrast enhancing an image by histogram manipulation. Our solution involves locally equalizing the histogram of an image using the available min and max pixel values of the image.&lt;br /&gt;&lt;br /&gt;It must be noted that there is no single CDF that can enhance the contrast of every image. Each CDF has its own limitations and use. Care must be taken when contrast enhancing an image and knowledge of how each CDF alters the image must be understood.&lt;br /&gt;&lt;br /&gt;Please email me (orly.tarun@gmail.com) if you plan to use the code above! Please leave your comments and suggestions. =)&lt;br /&gt;&lt;br /&gt;For this activity, I give myself a grade of 10 for performing acceptable contrast enhancement algorithms.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;References:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;[1] Activity 4 Manual.&lt;br /&gt;[2] http://myweb.lsbu.ac.uk/dirt/museum/margaret/08--452-1000120.jpg&lt;br /&gt;[3] http://www.andrew.cmu.edu/user/timothyz/hw3/low_contrast.jpg&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-1070926403793470852?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/1070926403793470852/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/07/activity-4-enhancement-by-histogram.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/1070926403793470852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/1070926403793470852'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/07/activity-4-enhancement-by-histogram.html' title='Activity 4: Enhancement by Histogram Manipulation'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_COm-OXWGnMQ/SkuOx68kw7I/AAAAAAAAAJk/NeOzV7uyVow/s72-c/steps.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-8781623158937605397</id><published>2009-06-23T09:27:00.001+08:00</published><updated>2009-07-09T16:19:34.101+08:00</updated><title type='text'>Activity 3: Image types and basic image enhancement</title><content type='html'>Digitize image comes in four different types. They are,&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Binary image which are either 1 or 0, black or white. For an image of size 128 x 128 pixels, each pixel occupies 1 bit, so 128 x 128 = 2048bytes or 2KB.&lt;/li&gt;&lt;li&gt;Grayscale image which contain 8 bits of information. That is, their pixel value can span the range between 0-255. Since it contains 8 bits of information, each pixel occupies 1 byte, for an image of 128x128 pixels = 16384 bytes or 16KB.&lt;/li&gt;&lt;li&gt;Truecolor image is equivalent to 3 grayscale images called channels. Truecolor images are also know as RGB because each R, G, B represent the 3 different channels of the image (red, green and blue). Per pixel, there are 256^3 possible combination of information. Most colored photos, i.e, taken using digital cameras are RGB.&lt;/li&gt;&lt;li&gt;Indexed images are color images that contain index numbers mapped to a color map. Thus, they contain two data, the colormap and image. They are generally smaller in file size compared to RGB but less color information because the maximum colors it can contain are indicated in the colormap.&lt;/li&gt;&lt;/ul&gt;Below are examples of different types of images.&lt;br /&gt;JPEG images of Lena obtained from this source [1]. Note of the difference in file size between the different image file types: Truecolor (RgB), grayscale and binary (black and white).&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlWH0qhTpiI/AAAAAAAAAS0/KUkTeRmnz08/s1600-h/lena_.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 137px; height: 137px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SlWH0qhTpiI/AAAAAAAAAS0/KUkTeRmnz08/s400/lena_.bmp" alt="" id="BLOGGER_PHOTO_ID_5356336670664009250" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SkA4kWSeEEI/AAAAAAAAAEs/s1Qnm-o83PE/s1600-h/lena_gray.jpg"&gt;&lt;img style="cursor: pointer; width: 139px; height: 139px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SkA4kWSeEEI/AAAAAAAAAEs/s1Qnm-o83PE/s200/lena_gray.jpg" alt="" id="BLOGGER_PHOTO_ID_5350338554425643074" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlWK47oP0eI/AAAAAAAAATE/WKDHs2InVLE/s1600-h/lena_index.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 136px; height: 136px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlWK47oP0eI/AAAAAAAAATE/WKDHs2InVLE/s400/lena_index.png" alt="" id="BLOGGER_PHOTO_ID_5356340042510881250" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlWK4rVIVxI/AAAAAAAAAS8/jNWE0mm-Z-o/s1600-h/lena_rgb.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 136px; height: 136px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlWK4rVIVxI/AAAAAAAAAS8/jNWE0mm-Z-o/s400/lena_rgb.png" alt="" id="BLOGGER_PHOTO_ID_5356340038135731986" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;File Properties:           RGB (72.4KB)                            Grayscale (26KB)           Black and white (5KB) Index(31.6KB)&lt;br /&gt;*(http://www.ee.columbia.edu/~cylin/course/mss/MSS_hw1.html)&lt;br /&gt;&lt;br /&gt;In the next part, we are going to apply what we learned in activity 2 by obtaining the area of a scanned image. I would like to acknowledge Mark Jayson 'master' Villangca for lending me his scanned image for this activity. In order to check if our area calculation is correct, a ruler was placed side by side with the image. We can then obtain a pixel:physical unit calibration to obtain the true area of the image.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlWN25dBlhI/AAAAAAAAATM/h_0UwU0JEj0/s1600-h/master.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 197px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlWN25dBlhI/AAAAAAAAATM/h_0UwU0JEj0/s400/master.png" alt="" id="BLOGGER_PHOTO_ID_5356343306102085138" border="0" /&gt;&lt;/a&gt;FileName: master.png&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt; FileSize: 208681&lt;br /&gt;Format: PNG&lt;br /&gt;Width: 905&lt;br /&gt;Height: 446&lt;br /&gt;Depth: 8&lt;br /&gt;StorageType: truecolor&lt;br /&gt;NumberOfColors: 0&lt;br /&gt;ResolutionUnit: centimeter&lt;br /&gt;XResolution: 59.050000&lt;br /&gt;YResolution: 59.050000&lt;br /&gt;&lt;div style="text-align: left;"&gt;In order to obtain the area of the image above, we need to binarize the image using im2bw. In doing this, we need to select the correct threshold using the histogram of the image.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlWSycdxadI/AAAAAAAAATc/Edt2h2vlTM0/s1600-h/histogram.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 313px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlWSycdxadI/AAAAAAAAATc/Edt2h2vlTM0/s400/histogram.bmp" alt="" id="BLOGGER_PHOTO_ID_5356348727159253458" border="0" /&gt;&lt;/a&gt;Histogram of the above image using my own code for histogram below,&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;function histogram = fhistogram(img, depth)&lt;br /&gt;bits=(2^depth)-1;&lt;br /&gt;histogram = zeros(bits,2);&lt;br /&gt;bins = 0.5:bits; bins = bins./bits; //bins for [0,1] image.&lt;br /&gt;for i=1:bits,&lt;br /&gt;frequency(i) = sum(img&gt;=(bins(i)-1/(2*bits))&amp;amp;img&lt;(bins(i)+1/(2*bits)));   end;   histogram(:,1)=bins';   histogram(:,2)=frequency; endfunction&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;From the histogram we can choose a suitable threshold (i.e, ~ pixel value of 100). Using im2bw, we can then set the threshold (since 0-1, divide 100 by 255) and specify the ROI in the image by defining another matrix. In the above image, we opted to remove the ruler in the thresholding and focused on the image.&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlWbHF0uJII/AAAAAAAAAT8/f11tYNLqgxw/s1600-h/roi_bw_master.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 196px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SlWbHF0uJII/AAAAAAAAAT8/f11tYNLqgxw/s320/roi_bw_master.png" alt="" id="BLOGGER_PHOTO_ID_5356357877951767682" border="0" /&gt;&lt;/a&gt;Resulting image after converting to binary and applying a region of interest&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlWbG5YZPpI/AAAAAAAAAT0/HQzFzGRetqY/s1600-h/contour.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 196px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SlWbG5YZPpI/AAAAAAAAAT0/HQzFzGRetqY/s320/contour.bmp" alt="" id="BLOGGER_PHOTO_ID_5356357874611732114" border="0" /&gt;&lt;/a&gt;After using the contour follow, we obtain the contour of the image.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Using the algorithm in activity 2, we obtain the following results&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Area of master = 16576 pixels. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Pixel count = 16894 pixels. &lt;/span&gt;&lt;br /&gt;Observe the converted binary image has extra white pixels outside the contour 'master'.&lt;br /&gt;&lt;br /&gt;In order to calibrate this to physical units we can obtain the pixel:physical ratio using paint. (i.e., we obtained 1cm:30pixels ~ ). Thus the area of the contour in physical units is&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Area = 552.533 cm^2.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;For this activity I give myself a grade of 9 for finishing the activity although a bit late and additional bonus for providing my own code for the histogram.&lt;br /&gt;&lt;br /&gt;I would like to acknowledge Mark Jayson Villangca for lending me the scanned image. Jica and Miguel for useful discussions.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;References:&lt;/span&gt;&lt;br /&gt;[1] Activity 3 manual.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;[2] http://www.ee.columbia.edu/~cylin/course/mss/MSS_hw1.html&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/273950707063911697-8781623158937605397?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/8781623158937605397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.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/273950707063911697/posts/default/8781623158937605397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/8781623158937605397'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/06/activity-3-image-types-and-basic-image.html' title='Activity 3: Image types and basic image enhancement'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_COm-OXWGnMQ/SlWH0qhTpiI/AAAAAAAAAS0/KUkTeRmnz08/s72-c/lena_.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-8901662997800728264</id><published>2009-06-23T09:23:00.000+08:00</published><updated>2009-07-07T19:08:03.444+08:00</updated><title type='text'>Activity 2: Area Estimation  of Images with Defined Edges</title><content type='html'>Area estimation finds many applications in the field of material science, biology, geology and the natural science in general . Biologists are especially interested in the difference in size between cancer cells and healthy cells. In material science, area measurement of leads and semiconductor materials among others is an effective tool for processing and failure analysis. In geology, remote sensing is an active area of research used widely in environmental and marine science researches [1].&lt;br /&gt;&lt;br /&gt;The method below discusses image area measurement using Green's Theorem. It must be noted that before using this method, there are several limitations that must be considered. We will discuss these limitations at the end of the article.&lt;br /&gt;&lt;br /&gt;We start with the following.&lt;br /&gt;Below are sample images (256 x 256 ) of triangle, square, circle and several irregular polygons which we will use in our area estimation method.&lt;br /&gt;&lt;br /&gt;Circle of diameter=125px, Square of side=130px, triangle of base=height=150px. These measurements are obtained from MS Paint while creating the images. It must be noted that these measurements are just guidelines for checking our results and must not be used as the theoretical area of the image. In creating these images, the border already occupied several pixels, so the area of the shape (white) does not necessarily reflect the analytically expected result. (i.e, Area_square = 130*130)&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkcFgh6U9LI/AAAAAAAAAHk/HmrHpzLTvjc/s1600-h/quadrilateral_130side.JPG"&gt;&lt;img style="cursor: pointer; width: 200px; height: 200px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkcFgh6U9LI/AAAAAAAAAHk/HmrHpzLTvjc/s200/quadrilateral_130side.JPG" alt="" id="BLOGGER_PHOTO_ID_5352252738570089650" border="0" /&gt;&lt;/a&gt;&lt;span&gt;&lt;br /&gt;Pixel Count: 16129&lt;br /&gt;Computed Area: 16129&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SkcFgtmNdtI/AAAAAAAAAHc/qDDmdGkazLI/s1600-h/triangle_150bh.JPG"&gt;&lt;img style="cursor: pointer; width: 200px; height: 200px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SkcFgtmNdtI/AAAAAAAAAHc/qDDmdGkazLI/s200/triangle_150bh.JPG" alt="" id="BLOGGER_PHOTO_ID_5352252741706938066" border="0" /&gt;&lt;/a&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Pixel Count: 11644&lt;br /&gt;Computed Area: 11644&lt;/span&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SkcFgXi2PcI/AAAAAAAAAHU/jVYH14phxRY/s1600-h/circle_125diam.JPG"&gt;&lt;img style="cursor: pointer; width: 200px; height: 200px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SkcFgXi2PcI/AAAAAAAAAHU/jVYH14phxRY/s200/circle_125diam.JPG" alt="" id="BLOGGER_PHOTO_ID_5352252735787253186" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span&gt;Pixel Count: 10731&lt;br /&gt;Computed Area: 10731&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SkcF10AeboI/AAAAAAAAAHs/0X0HvwlKmqg/s1600-h/irregA.JPG"&gt;&lt;img style="cursor: pointer; width: 200px; height: 200px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SkcF10AeboI/AAAAAAAAAHs/0X0HvwlKmqg/s200/irregA.JPG" alt="" id="BLOGGER_PHOTO_ID_5352253104204967554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span&gt;Pixel Count: 17522&lt;br /&gt;Computed Area: 17522&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkcF2KYiuXI/AAAAAAAAAH0/BUDeOZ3hr04/s1600-h/irregB.JPG"&gt;&lt;img style="cursor: pointer; width: 200px; height: 200px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkcF2KYiuXI/AAAAAAAAAH0/BUDeOZ3hr04/s200/irregB.JPG" alt="" id="BLOGGER_PHOTO_ID_5352253110211492210" border="0" /&gt;&lt;/a&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Pixel Count: 14058&lt;br /&gt;Computed Area: 14056&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkcF2DCSLbI/AAAAAAAAAH8/6wC-ITIh9AI/s1600-h/irregC.JPG"&gt;&lt;img style="cursor: pointer; width: 200px; height: 200px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkcF2DCSLbI/AAAAAAAAAH8/6wC-ITIh9AI/s200/irregC.JPG" alt="" id="BLOGGER_PHOTO_ID_5352253108239084978" border="0" /&gt;&lt;/a&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Pixel Count: 14913&lt;br /&gt;Computed Area: 7414&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;In order to compute the area of the above images, we use the SIP toolbox of scilab-4.1.2 using the command follow.  Excerpt from the description of follow command from scilab:&lt;br /&gt;&lt;br /&gt;"follow - A contour follower. Function follow extracts parametric contours of binary objects. This is useful for further extracting object features such as curvature and bending energy."&lt;br /&gt;&lt;br /&gt;Note that before we use the command follow, our images must be first binarize. This can be done in scilab using the command im2bw. The command follow returns the [x,y] coordinates of the contour. We can then use this contour coordinates to compute the area using Green's Theorem found below. For more detailed discussion of area measurement using Green's Theorem please follow this source [2] (http://www.attewode.com/Calculus/AreaMeasurement/area.htm).&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SkcJF46mxNI/AAAAAAAAAIE/-0JwMLAen5g/s1600-h/formula.JPG"&gt;&lt;img style="cursor: pointer; width: 200px; height: 65px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SkcJF46mxNI/AAAAAAAAAIE/-0JwMLAen5g/s200/formula.JPG" alt="" id="BLOGGER_PHOTO_ID_5352256678935315666" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;Since the image is binarized, we can compute the thoretical area by summing the pixels of the image (white~1 and black~0). We designated the theoretical area as "pixel count" in the above images and "computed area" when using Green's Theorem.&lt;br /&gt;&lt;br /&gt;Below is the code in scilab used to obtain the pixel count and the computed area:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);font-size:85%;" &gt;//load image&lt;br /&gt;directory='C:\Documents and Settings\2004-29578\Desktop\Activities\Activity 2\'&lt;br /&gt;filename='quadrilateral_130side.jpg';&lt;br /&gt;img1= imread(directory+filename);&lt;br /&gt;&lt;br /&gt;//binarize image&lt;br /&gt;img2=im2bw(img1, 0.5);&lt;br /&gt;&lt;br /&gt;//get the contour using follow&lt;br /&gt;[x,y]=follow(img2);&lt;br /&gt;//get the dimensions of x and y&lt;br /&gt;[M,N]=size(x)&lt;br /&gt;//complete the contour setting the last pixel=first pixel&lt;br /&gt;x(M+1)=x(1);&lt;br /&gt;y(M+1)=y(1);&lt;br /&gt;&lt;br /&gt;plot(x,y);&lt;br /&gt;&lt;br /&gt;//get the area using Greens Theorem. we use round since the area (number of pixels (1 or 0)) can only take //integer values.&lt;br /&gt;Area = round(0.5*sum((x(1:M).*y(2:(M+1)))-(y(1:M).*x(2:(M+1)))))+&lt;span style="font-weight: bold;"&gt; round((M+1)/2)&lt;/span&gt;;&lt;br /&gt;//pixel count&lt;br /&gt;TArea = sum(img2);&lt;br /&gt;&lt;br /&gt;//imshow to scale to grascale, i.e., highest pixel becomes white, lowest pixel becomes black&lt;br /&gt;//binarize image using im2bw&lt;br /&gt;//increase memory for scilab use, stacksize.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note that in obtaining the computed area, we added a correcting factor  "round((M+1)/2)" in our code where M is the length of the  x or y vector.&lt;br /&gt;&lt;br /&gt;Results and Limitations&lt;br /&gt;(1) For the regular polygons and the first irregular polygon, the pixel count and the computed area are the same, meaning that the algorithm successfully estimated the area of the images.&lt;br /&gt;(2) For the next irregular polygon (figure batman) there is a discrepancy in the pixel count and the computed area.&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/Skte3BeF3DI/AAAAAAAAAJE/Mwo3StK7NNk/s1600-h/irregB_zoom.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 313px; height: 320px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/Skte3BeF3DI/AAAAAAAAAJE/Mwo3StK7NNk/s320/irregB_zoom.png" alt="" id="BLOGGER_PHOTO_ID_5353476881440431154" border="0" /&gt;&lt;/a&gt;In the figure above, note the extra 2 pixels in 'batman's" horn which accounted for the discrepancy. This error is due to the command "follow" of scilab which assumes only &lt;span style="font-weight: bold;"&gt;ONE&lt;/span&gt; contour per image. In order to check this, we made two contours in the next image and as expected there is a huge discrepancy between the pixel count and the computed area.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;(3) The algorithm and theory for computing the area is pretty solid (Green's Theorem) hence most of our errors should come from the input and processing of the input. That is, our limitations will most probably due to the command follow and im2bw of scilab.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SktfEVfoxnI/AAAAAAAAAJM/9OVggWWdXZo/s1600-h/square%29overlay.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 152px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SktfEVfoxnI/AAAAAAAAAJM/9OVggWWdXZo/s320/square%29overlay.png" alt="" id="BLOGGER_PHOTO_ID_5353477110153922162" border="0" /&gt;&lt;/a&gt;Overlayed image of the binared square and its contour using the command follow. Note that there is an offset in the contour compared to the image of ~2 pixels. Similar observation is found in the next image.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_COm-OXWGnMQ/SktfObYu5bI/AAAAAAAAAJU/D9lVqMuLWKg/s1600-h/irreg_overlay.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 161px;" src="http://1.bp.blogspot.com/_COm-OXWGnMQ/SktfObYu5bI/AAAAAAAAAJU/D9lVqMuLWKg/s320/irreg_overlay.png" alt="" id="BLOGGER_PHOTO_ID_5353477283534267826" border="0" /&gt;&lt;/a&gt;Note the offset between the contour and the image.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;(4) The command im2bw is similar to thresholding and thus depending on your threshold, the computed area will change. This effect would most probably depend on the user setting the threshold and making measurements.&lt;br /&gt;&lt;br /&gt;(5) It is expected that in large scale images (2048x2048) the computed area will approach the analytical area. This would be very useful in applications like remote sensing and geological survey.&lt;br /&gt;&lt;br /&gt;For this activity, I give myself a grade of 10 for exact area measurement as proven by the sets of images used.&lt;br /&gt;&lt;br /&gt;References:&lt;br /&gt;&lt;br /&gt;[1] Activity 2 Handout&lt;br /&gt;[2] http://www.attewode.com/Calculus/AreaMeasurement/area.htm&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/273950707063911697-8901662997800728264?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/8901662997800728264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/06/activity-2-area-estimation-of-images.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/8901662997800728264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/8901662997800728264'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/06/activity-2-area-estimation-of-images.html' title='Activity 2: Area Estimation  of Images with Defined Edges'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_COm-OXWGnMQ/SkcFgh6U9LI/AAAAAAAAAHk/HmrHpzLTvjc/s72-c/quadrilateral_130side.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-273950707063911697.post-2220302729066331327</id><published>2009-06-16T10:38:00.000+08:00</published><updated>2009-06-23T11:07:27.148+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ratio'/><category scheme='http://www.blogger.com/atom/ns#' term='proportion.'/><category scheme='http://www.blogger.com/atom/ns#' term='excel'/><category scheme='http://www.blogger.com/atom/ns#' term='paint'/><category scheme='http://www.blogger.com/atom/ns#' term='digital scanning'/><title type='text'>Activity 1: Digital Scanning</title><content type='html'>excerpt from activity 1 handout...&lt;br /&gt;"In this activity, we use ratio and proportion to find the numerical values of a digitally scanned hand-drawn plot. For now, you will need the following software, Paint for finding the pixel locations on the graph, and Excel of Open Office Spreadsheet to tabulate the values of the graph."&lt;br /&gt;&lt;br /&gt;What I did.&lt;br /&gt;1. Photocopied a plot from the College of Science Libray from the following journal.&lt;br /&gt;The Renormalization Group and Cricitical Phenomena I: Renormalization Group and the Kardanoff Scaling Picture by Kenneth Wilson from the Laboratory of Nuclear Studies, Cornell University, Ithaca New York, 14850 on 1974.&lt;br /&gt;&lt;br /&gt;The photocopied image was then digitally scanned. (see picture below)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkBF8fNw3JI/AAAAAAAAAGE/jvUqZcRPfvI/s1600-h/orly.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 283px; height: 400px;" src="http://4.bp.blogspot.com/_COm-OXWGnMQ/SkBF8fNw3JI/AAAAAAAAAGE/jvUqZcRPfvI/s400/orly.jpg" alt="" id="BLOGGER_PHOTO_ID_5350353262789844114" border="0" /&gt;&lt;/a&gt;For convenience, I cropped the image at the origin resulting to the image below.&lt;br /&gt;The cropped image was then opened in MS Paint.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/SkBGy-MAXMI/AAAAAAAAAGM/OU2mU7LzS2M/s1600-h/image_recon2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 324px; height: 400px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/SkBGy-MAXMI/AAAAAAAAAGM/OU2mU7LzS2M/s400/image_recon2.jpg" alt="" id="BLOGGER_PHOTO_ID_5350354198816906434" border="0" /&gt;&lt;/a&gt;Producing the Plot in Open Office:&lt;br /&gt;Using MS Paint, the pixel location of the origin was recorded. Note that in paint, the (0,0) mark is at the top-left of the document. In this activity, the pixel location of the origin of the cropped image is at (220,1053).&lt;br /&gt;&lt;br /&gt;Using Open Office, I successively obtained the pixel locations of the graph at 50 pixel interval in the x-axis amounting to 33 data points. Using the pixel locations of the origin, I calibrated the pixel location obtained previously by noting that the top-left part of Paint is the (0,0) mark using the following formula:&lt;br /&gt;Xexcel=Xpixel-220,&lt;br /&gt;Yexcel=1053-Ypixel (see picture below for sample data points)&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sjm2oaWJwZI/AAAAAAAAAEE/8aKsZCiWbn4/s1600-h/data.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 134px;" src="http://2.bp.blogspot.com/_COm-OXWGnMQ/Sjm2oaWJwZI/AAAAAAAAAEE/8aKsZCiWbn4/s320/data.bmp" alt="" id="BLOGGER_PHOTO_ID_5348506837862433170" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Next, I obtained the number of pixels/unit in the graph and obtained the following:&lt;br /&gt;Pixels/unit in the x-axis = 648&lt;br /&gt;Pixels/unit in the y-axis = 1276&lt;br /&gt;Using this calibration I divided all the values of the Xexcel by 648 and all values of Yexcel by 1276. This will give the calibrated values of the graph in physical units.&lt;br /&gt;&lt;br /&gt;In order to check if the reconstructed image and the original image are perfectly matched, the two images were overlayed. This can be easily done in open office by importing the scanned image as graphic. (Format-&gt;graphic-&gt;bitmap-&gt;import the image). After importing the image, click on the reconstructed graph and set the Area to the imported image (click on the graph-&gt;object properties-&gt;area-&gt;select bitmap-&gt;select your imported image).&lt;br /&gt;&lt;br /&gt;At first, the images will not be perfectly matched. In order to overlay it perfectly, you must obtain the maximum locations of the grid in the x and y axis. Use this and modify the axes of the graph and set it to the obtained maximum.&lt;br /&gt;&lt;br /&gt;The image below is the reconstructed image overlayed with the scanned image.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_COm-OXWGnMQ/SkBGzNtob8I/AAAAAAAAAGU/nJy44yTeupc/s1600-h/Img_scanned.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 324px; height: 400px;" src="http://3.bp.blogspot.com/_COm-OXWGnMQ/SkBGzNtob8I/AAAAAAAAAGU/nJy44yTeupc/s400/Img_scanned.JPG" alt="" id="BLOGGER_PHOTO_ID_5350354202984476610" border="0" /&gt;&lt;/a&gt;Observe that the image grids in the scanned image and the reconstructed image are perfectly matched. Furthermore, the graph is well-matched with no visible offset. For this activity, I give myself a grade of 10 for perfectly reconstructing the scanned image.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/273950707063911697-2220302729066331327?l=otarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otarun.blogspot.com/feeds/2220302729066331327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://otarun.blogspot.com/2009/06/activity-1-digital-scanning.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/2220302729066331327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/273950707063911697/posts/default/2220302729066331327'/><link rel='alternate' type='text/html' href='http://otarun.blogspot.com/2009/06/activity-1-digital-scanning.html' title='Activity 1: Digital Scanning'/><author><name>Orly Tarun</name><uri>http://www.blogger.com/profile/09068343081809417885</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_COm-OXWGnMQ/SkBF8fNw3JI/AAAAAAAAAGE/jvUqZcRPfvI/s72-c/orly.jpg' height='72' width='72'/><thr:total>3</thr:total></entry></feed>
