<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Northstartup &#187; programming</title>
	<atom:link href="http://www.nesota.com/blog/archives/category/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://www.nesota.com/blog</link>
	<description>Entrepreneurship in the North Star State</description>
	<lastBuildDate>Mon, 12 Jul 2010 05:04:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Challenges</title>
		<link>http://www.nesota.com/blog/archives/32</link>
		<comments>http://www.nesota.com/blog/archives/32#comments</comments>
		<pubDate>Sat, 12 Sep 2009 23:00:09 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[photography]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[computational photography]]></category>
		<category><![CDATA[deblurring]]></category>
		<category><![CDATA[deconvolution]]></category>
		<category><![CDATA[ill-posed]]></category>
		<category><![CDATA[photos]]></category>

		<guid isPermaLink="false">http://www.nesota.com/blog/?p=32</guid>
		<description><![CDATA[The deblurring of images, subject of Nesota&#8217;s upcoming product,  is an extremely difficult problem.  How difficult?  Let&#8217;s give it a look.
Conceptually, it isn&#8217;t too bad: given an observed blurry image y, find the corresponding unobserved (latent) sharp image x.  The complexity stems from the noise in the problem (and there&#8217;s always noise), the challenge in [...]]]></description>
			<content:encoded><![CDATA[<p>The deblurring of images, subject of Nesota&#8217;s upcoming product,  is an extremely difficult problem.  How difficult?  Let&#8217;s give it a look.</p>
<p>Conceptually, it isn&#8217;t too bad: given an observed blurry image <em>y</em>, find the corresponding unobserved (latent) sharp image <em>x</em>.  The complexity stems from the noise in the problem (and there&#8217;s always noise), the challenge in deciding when an image is &#8220;sharp,&#8221; and the overall vagueness of the problem.</p>
<p>The problem is usually modeled using an equation like</p>
<p style="text-align: center;"><em>y</em> = <em>x</em> &otimes; <em>h</em> + <em>n</em></p>
<p>where <em>y</em> is the observed blurry image, <em>x</em> is the unobserved sharp image (the recovery of which is our goal), <em>n</em> is noise, &otimes; is the convolution operator, and <em>h</em> describes the blur (commonly known as the Point Spread Function, or PSF).  Since we&#8217;re solving for<em> x</em>, and we know only <em>y</em>, the problem is clearly ill-posed: we have three unknowns and only one equation.  What to do?</p>
<p>The problem can be helped somewhat by imposing constraints on the variables.  Here&#8217;s an example.  For simplicity, assume that all of the variables are scalars and * is the multiplication operator.  If we are told that</p>
<p style="text-align: center;">41 = <em>x</em> * <em>h</em> + <em>n</em></p>
<p>and nothing more, then there are many valid solutions.  For example, a valid solution is <em>x</em>=7,<em> h</em>=3, and <em>n</em>=20.  Another equally valid solution could be <em>x</em>=41, <em>h</em>=1, and <em>n</em>=0.  However, if we are told instead that</p>
<p style="text-align: center;">41 = <em>x</em> * <em>h</em> + <em>n</em></p>
<p style="text-align: center;">s.t. <em> x </em>is even, 2 &lt; <em>h</em> &lt; 5, and <em>n</em> &isin; {0,1}</p>
<p>then we can clearly see that the only valid solution satisfying the constraints is <em>x</em>=10, <em>h</em>=4, and <em>n</em>=1.</p>
<p>Similarly, the challenge in solving the deblurring problem is imposing the proper constraints on the variables.  In the image deblurring problem, the variables are typically represented as matrices, which may each have millions of elements, which means that there are, essentially, millions of unknowns.  A brute-force, exhaustive search of the solution space &#8212; trying every possible combination of values &#8212; is completely infeasible.  We need some constraints.</p>
<p>Fortunately, we do know a few things about the sharp image, PSF, and noise that can get us pointed in the right direction.  First, the image values are bounded.  On computers, in files like JPEGs and PNGs, every pixel, for every channel (red, green, and blue), has an integer value between 0 and 255, inclusive; that is, there are 8 bits per pixel (2^8 = 256), and 3 channels, leading to 24 bits of data per pixel, or 24-bit color.  That&#8217;s one constraint: all of the pixels in our blurry and sharp images need to have values between 0 and 255, inclusive.</p>
<p>A second constraint, this time on the PSF, is that the PSF is energy-conserving.  In other words, when the PSF blurs the image, it doesn&#8217;t add or remove any energy to the pixel, so instead of a single bright pixel, you might instead get several dim pixels that sum to the same value as the bright pixel.  This tells us two things: first, the range of element values in the PSF is between 0 and 1, inclusive; and second, the sum of all of the elements in the PSF must equal exactly 1.</p>
<p>Constraints on the noise term can be a bit tricky, and tend to be chosen for simplicity.  Fortunately, the model tends not to be overly sensitive to the accuracy of the noise (noisy noise!), so a Gaussian or Poisson distribution is often chosen, with 0 mean and a standard deviation chosen based on empirical observation of known images.  The noise term has a lot to absorb: optical imperfections, inconsistencies across the frame, sensor noise, quantization noise, compression noise, and more.</p>
<p>From there, however, the problem gets really tricky.  How do we know when we&#8217;ve found the sharp image?  How do we solve a system with so many variables?  The plot thickens&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nesota.com/blog/archives/32/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tools</title>
		<link>http://www.nesota.com/blog/archives/29</link>
		<comments>http://www.nesota.com/blog/archives/29#comments</comments>
		<pubDate>Sat, 22 Aug 2009 01:34:37 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.nesota.com/blog/?p=29</guid>
		<description><![CDATA[In Star Trek, one need merely describe a desired application in vague terms, and the computer creates a program.  Instantaneously.  Completely satisfying the creator&#8217;s intent.  With no bugs.  Sadly, those of us stuck back here in reality aren&#8217;t so lucky, but there are things we can do to ease our own programming efforts.
All of modern [...]]]></description>
			<content:encoded><![CDATA[<p>In Star Trek, one need merely describe a desired application in vague terms, and the computer creates a program.  Instantaneously.  Completely satisfying the creator&#8217;s intent.  With no bugs.  Sadly, those of us stuck back here in reality aren&#8217;t so lucky, but there are things we can do to ease our own programming efforts.</p>
<p>All of modern civilization is built upon the effort and productivity of generations past.  So it goes in the software world.  For my quasi-stealth-mode computational photography project, I&#8217;m making use of some great tools:</p>
<ul>
<li><a href="http://www.ubuntu.com/">Linux</a> &#8212; Operating system.  Free.  Fast.  Familiar.</li>
<li><a href="http://www.apache.org/">Apache</a> &#8212; Web server.  Can be overkill, but it does a good job integrating with&#8230;</li>
<li><a href="http://rubyonrails.org/">Ruby on Rails</a> &#8212; Framework.  Ruby is a wonderful, modern language.  Rails is getting increasingly mature.   Also using a bunch of packages and related tools, like Mongrel, which make life easier.</li>
<li><a href="http://aptana.com/rails/">Aptana/RadRails</a> &#8212; Integrated Development Environment (IDE).  Specifically, RadRails.  Development for Rails in Aptana is made easier by the underlying Eclipse engine, the cooperation with the Ruby debugger, and the decent integration with&#8230;</li>
<li><a href="http://subversion.tigris.org/">Subversion</a> &#8212; Version control.  Because I had it installed, Rails plays nicely with it, and I haven&#8217;t had a chance to get familiar with Git.</li>
<li><a href="http://www.gnu.org/software/octave/">Octave</a> &#8212; Numerical computation.  Very similar to Matlab in its vector-based programming language, but it has some nice features that make it particularly well-suited for my needs.  Also, it&#8217;s free, whereas acquiring Matlab would force me to mortgage my firstborn child.</li>
<li><a href="http://www.fogcreek.com/FogBUGZ/">FogBugz</a> &#8212; Bug tracking.  And scheduling.  I thought I should give it a spin, seeing as how several of my friends from <a href="http://www.rose-hulman.edu/">Rose</a> and <a href="http://www.stanford.edu/">Stanford</a> work at Fog Creek.</li>
<li><a href="http://aws.amazon.com/fps/">Amazon Flexible Payments Service</a> &#8212; Payments.  A business is about money, and money requires being paid.  Amazon FPS makes accepting credit cards easier than, say, getting a merchant account and putting together a PCI-compliant server.   That, and Amazon doesn&#8217;t have the stigma of PayPal.</li>
</ul>
<p>It hasn&#8217;t all been a smooth ride.  Aptana crashes at least twice a day.  I&#8217;m still in the process of learning Ruby (which is one of my motivations for using it).  I&#8217;ve had to patch bugs in Octave and Rails.  That said, it&#8217;s easier than doing everything from scratch in, say, C++.</p>
<p>At first, I felt a bit guilty for standing on the shoulders of others.  Hell, the entire motivation behind the project is based on decades of academic research.  But like the architects who use the steel alloys of others to build their skyscrapers, and the auto manufacturers who use minerals mined by others in the distant corners of the globe, I too will take pieces from others and combine them to make 2+2=5.  Perhaps one day, somebody will incorporate my work into their own, thus continuing the great cycle of humanity.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nesota.com/blog/archives/29/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
