<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="new1">
  <name>Digital Image Processing Basics</name>
  <metadata>
  <md:version>2.1</md:version>
  <md:created>2002/12/20</md:created>
  <md:revised>2003/02/28</md:revised>
  <md:authorlist>
      <md:author id="nowak">
      <md:firstname>Rob</md:firstname>
      <md:othername>"The Kid"</md:othername>
      <md:surname>Nowak</md:surname>
      <md:email>nowak@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="mjhaag">
      <md:firstname>Michael</md:firstname>
      
      <md:surname>Haag</md:surname>
      <md:email>mjhaag@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="nowak">
      <md:firstname>Rob</md:firstname>
      <md:othername>"The Kid"</md:othername>
      <md:surname>Nowak</md:surname>
      <md:email>nowak@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>2d convolution</md:keyword>
    <md:keyword>2d fourier transforms</md:keyword>
    <md:keyword>2d FT</md:keyword>
    <md:keyword>sampling</md:keyword>
  </md:keywordlist>

  <md:abstract>The module provides an introduction to the concepts of digital imaging processing through basic equations and examples.</md:abstract>
</metadata>

  <content>
    <section id="sec1">
      <name>Digital Image Processing</name>
      <para id="p1">
	A sampled image gives us our usual 2D array of pixels 
	<m:math>
	  <m:apply>
	    <m:ci type="fn" class="discrete">f</m:ci>
	    <m:ci>m</m:ci>
	    <m:ci>n</m:ci>
	  </m:apply>
	</m:math> (<cnxn target="fig1" strength="9"/>):
      </para>

      <figure id="fig1">
	<media type="image/png" src="smiley.png"/>
	<caption>
	  We illustrate a "pixelized" smiley face.
	</caption>
      </figure>

      <para id="p2">
	We can filter 
	<m:math>
	  <m:apply>
	    <m:ci type="fn" class="discrete">f</m:ci>
	    <m:ci>m</m:ci>
	    <m:ci>n</m:ci>
	  </m:apply>
	</m:math>  
	by applying a 2D discrete-space <cnxn document="m10087" strength="8">convolution</cnxn> as shown below (where 
	<m:math>
	  <m:apply>
	    <m:ci type="fn" class="discrete">h</m:ci>
	    <m:ci>m</m:ci>
	    <m:ci>n</m:ci>
	  </m:apply>
	</m:math> is our PSF):

	<equation id="eq1">
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:apply>
		<m:ci type="fn" class="discrete">g</m:ci>
		<m:ci>m</m:ci>
		<m:ci>n</m:ci>
	      </m:apply>
	      <m:apply>
		<m:csymbol definitionURL="http://cnx.rice.edu/cd/cnxmath.ocd#convolve"/> 
		<m:apply>
		  <m:ci type="fn" class="discrete">h</m:ci>
		    <m:ci>m</m:ci>
		  <m:ci>n</m:ci>
		</m:apply>
		<m:apply>
		  <m:ci type="fn" class="discrete">f</m:ci>
		  <m:ci>m</m:ci>
		  <m:ci>n</m:ci>
		</m:apply>
	      </m:apply>
	      <m:apply>
		<m:sum/>
		<m:bvar><m:ci>k</m:ci></m:bvar>
		<m:uplimit>
		  <m:infinity/>
		</m:uplimit>
		<m:lowlimit>
		  <m:apply>
		    <m:minus/>
		    <m:infinity/>
		  </m:apply>
		</m:lowlimit>
		<m:apply>
		  <m:sum/>
		  <m:bvar><m:ci>l</m:ci></m:bvar>
		  <m:uplimit>
		    <m:infinity/>
		  </m:uplimit>
		  <m:lowlimit>
		    <m:apply>
		      <m:minus/>
		      <m:infinity/>
		    </m:apply>
		  </m:lowlimit>
		  <m:apply>
		    <m:times/>
		    <m:apply>
		      <m:ci type="fn" class="discrete">h</m:ci>
		      <m:apply>
			<m:minus/>
			<m:ci>m</m:ci>
			<m:ci>k</m:ci>
		      </m:apply>
		      <m:apply>
			<m:minus/>
			<m:ci>n</m:ci>
			<m:ci>l</m:ci>
		      </m:apply>
		    </m:apply> 
		    <m:apply>
		      <m:ci type="fn" class="discrete">f</m:ci>
		      <m:ci>k</m:ci>
		      <m:ci>l</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:math>
	</equation>
      </para>

      
      <example id="eg1">
	<name>Sampled Image</name>
	<figure id="fig2">
	  <media type="image/png" src="sec2_eg1.png"/>
	  <caption>
	    Illustrate the "pixelized" nature of all digital images.
	  </caption>
	</figure>  

      </example>

      <para id="p3">
	We also have discrete-space FTS:

	<equation id="eq2">
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:apply>
		<m:ci type="fn" class="discrete">F</m:ci>
		<m:ci>u</m:ci>
		<m:ci>v</m:ci>
	      </m:apply>
	      <m:apply>
		<m:sum/>
		<m:bvar><m:ci>m</m:ci></m:bvar>
		<m:uplimit>
		  <m:infinity/>
		</m:uplimit>
		<m:lowlimit>
		  <m:apply>
		    <m:minus/>
		    <m:infinity/>
		  </m:apply>
		</m:lowlimit>
		<m:apply>
		  <m:sum/>
		  <m:bvar><m:ci>n</m:ci></m:bvar>
		  <m:uplimit>
		    <m:infinity/>
		  </m:uplimit>
		  <m:lowlimit>
		    <m:apply>
		      <m:minus/>
		      <m:infinity/>
		    </m:apply>
		  </m:lowlimit>
		  <m:apply>
		    <m:times/>
		    <m:apply>
		      <m:ci type="fn" class="discrete">f</m:ci>
		      <m:ci>m</m:ci>
		      <m:ci>n</m:ci>
		    </m:apply>
		    <m:apply>
		      <m:exp/>
		      <m:apply>
			<m:minus/>
			<m:apply>
			  <m:times/>
			  <m:imaginaryi/>
			  <m:ci>u</m:ci>
			  <m:ci>m</m:ci>
			</m:apply>
		      </m:apply>
		    </m:apply>
		    <m:apply>
		      <m:exp/>
		      <m:apply>
			<m:minus/>
			<m:apply>
			  <m:times/>
			  <m:imaginaryi/>
			  <m:ci>v</m:ci>
			  <m:ci>m</m:ci>
			</m:apply>
		      </m:apply>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:math>
	</equation>

	where 
	<m:math>
	  <m:apply>
	    <m:ci type="fn" class="discrete">F</m:ci>
	    <m:ci>u</m:ci>
	    <m:ci>v</m:ci>
	  </m:apply>
	</m:math> is analogous to <cnxn document="m10247" strength="8">DTFT</cnxn> in 1D.  

	<note type="note">
	  "Convolution in Time" is the <emphasis>same</emphasis> as
	  "Multiplication in Frequency"
	</note>

	<equation id="eq3">
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:apply>
		<m:ci type="fn" class="discrete">g</m:ci>
		<m:ci>m</m:ci>
		<m:ci>n</m:ci>
	      </m:apply>
	      <m:apply>
		<m:csymbol definitionURL="http://cnx.rice.edu/cd/cnxmath.ocd#convolve"/> 
		<m:apply>
		  <m:ci type="fn" class="discrete">h</m:ci>
		  <m:ci>m</m:ci>
		  <m:ci>n</m:ci>
		</m:apply>
		<m:apply>
		  <m:ci type="fn" class="discrete">f</m:ci>
		  <m:ci>m</m:ci>
		  <m:ci>n</m:ci>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:math>
	</equation>

	which, as stated above, is the same as: 

	<equation id="eq4">
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:apply>
		<m:ci type="fn" class="discrete">G</m:ci>
		<m:ci>u</m:ci>
		<m:ci>v</m:ci>
	      </m:apply>
	      <m:apply>
		<m:times/>
		<m:apply>
		  <m:ci type="fn" class="discrete">H</m:ci>
		  <m:ci>u</m:ci>
		  <m:ci>v</m:ci>
		</m:apply>
		<m:apply>
		  <m:ci type="fn" class="discrete">F</m:ci>
		  <m:ci>u</m:ci>
		  <m:ci>v</m:ci>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:math>
	</equation>
      </para>

      <example id="eg2">
	<name>Magnitude of FT of Cameraman Image</name>
	<figure id="fig3">
	  <media type="image/png" src="cam_mag.png"/>
	</figure>  

	<para id="p1_eg2">
	  To get a better image, we can use the
	  <code>fftshift</code> command in Matlab to center
	  the Fourier Transform.  The resulting image is shown in
	  <cnxn target="fig4" strength="9"/>:
	</para>

	<figure id="fig4">
	  <media type="image/png" src="cam_mag_center.png"/>
	</figure> 

      </example>

    </section>

  </content>
</document>
