<?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>nklein software &#187; javascript</title>
	<atom:link href="http://nklein.com/tags/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://nklein.com</link>
	<description>software development and consulting</description>
	<lastBuildDate>Tue, 22 May 2012 03:48:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>HTML + JS + LISP.  Oh My.</title>
		<link>http://nklein.com/2012/03/html-js-lisp-oh-my/</link>
		<comments>http://nklein.com/2012/03/html-js-lisp-oh-my/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 03:37:49 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[cl-who]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[hunchentoot]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[parenscript]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=1812</guid>
		<description><![CDATA[I started a Javascript + HTML application some time back. I decided that I wanted to get some Lisp on. So, it was time to pull out Hunchentoot, CL-WHO, and Parenscript. It&#8217;s been awkward slogging so far. I still don&#8217;t have a good user-model of when exactly I need to wrap something in a &#40;cl-who:str [...]]]></description>
			<content:encoded><![CDATA[<p>I started a Javascript + HTML application some time back.  I decided that I wanted to get some Lisp on.  So, it was time to pull out Hunchentoot, CL-WHO, and Parenscript.</p>
<p>It&#8217;s been awkward slogging so far.  I still don&#8217;t have a good user-model of when exactly I need to wrap something in a <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">&#40;</span>cl-who<span style="color: #66cc66;">:</span><span style="color: #555;">str</span> <span style="color: #66cc66;">...</span><span style="color: #66cc66;">&#41;</span></span></code> or when Parenscript will expand my macro rather than convert it into a function call or how I managed to get the <code class="codecolorer lisp default"><span class="lisp">cl-who<span style="color: #66cc66;">:</span>*attribute-quote-char*</span></code> to finally stick for a few REPLs.</p>
<p>The other half of the awkwardness is that I started writing the application in idiomatic javascript with prototype-based objects.</p>
<div class="codecolorer-container javascript blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> MyClass <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">myfirst</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">myarray</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
MyClass.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">mymethod</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>arg1<span style="color: #339933;">,</span> arg2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">myfirst</span> <span style="color: #339933;">=</span> arg1<span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">myarray</span>.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>arg2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div>
<p>This makes for some awkward javascript when converted directly into Parenscript because:</p>
<ul>
<li>The method <code class="codecolorer javascript default"><span class="javascript">mymethod<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> will try to return the result of <code class="codecolorer javascript default"><span class="javascript">Array.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> (which, technically, is fine, but not really the intent of the method).</li>
<li>Almost every statement on the Lisp side ends up wrapping just about everything in <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">&#40;</span>parenscript<span style="color: #66cc66;">:</span><span style="color: #555;">chain</span> <span style="color: #66cc66;">...</span><span style="color: #66cc66;">&#41;</span></span></code>. (<b>Edit:</b> Of course, I discovered right after posting this that the dot is left untouched in the Parenscript symbol conversion, so I can do <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">&#40;</span>this<span style="color: #66cc66;">.</span>myarray<span style="color: #66cc66;">.</span>push arg2<span style="color: #66cc66;">&#41;</span></span></code> instead of <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">&#40;</span>parenscript<span style="color: #66cc66;">:</span><span style="color: #555;">chain</span> this my <span style="color: #b1b100;">array</span> <span style="color: #66cc66;">&#40;</span>push arg2<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></span></code>.  I&#8217;m certainly pleased with the brevity, but it pegs my <q>something&#8217;s fishy here, Batman</q> meter.)</li>
<li>I have an aversion to using any package other than <code class="codecolorer lisp default"><span class="lisp">COMMON-LISP</span></code>, so everything is way clunkier than all of the tutorials and examples online.</li>
</ul>
<p>I think that I&#8217;m going to scratch all of the Javascript and Parenscript code that I have right now and start over with a mindset of <q>How would I do this if it were just in Lisp?  Now, what extra hoops do I need to get Parenscript to make usable Javascript?</q> rather than <q>How would I do this in Javascript? Oh, and then, how can I make Parenscript say exactly that?</q>  And, I may bite the bullet and <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">&#40;</span>use-package <span style="color: #66cc66;">...</span><span style="color: #66cc66;">&#41;</span></span></code> both CL-WHO and Parenscript.</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2012/03/html-js-lisp-oh-my/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Blur and Edge Detect your Fourier Transforms</title>
		<link>http://nklein.com/2009/09/blur-and-edge-detect-your-fourier-transforms/</link>
		<comments>http://nklein.com/2009/09/blur-and-edge-detect-your-fourier-transforms/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 23:04:10 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=862</guid>
		<description><![CDATA[I have now added convolutions to my FFT Paint application. Here, I started with the following image (again, magnitude on the left and phase on the right): &#160;&#160; From there, I took the Fourier Transform: &#160;&#160; Then, I did a horizontal Sobel operator on it to get this: &#160;&#160; From there, I did the Inverse [...]]]></description>
			<content:encoded><![CDATA[<p>I have now added convolutions to <a href="http://nklein.com/mas-961/fft-paint/">my FFT Paint application</a>.  Here, I started with the following image (again, magnitude on the left and phase on the right):<br />
<center><a href="http://nklein.com/wp-content/uploads/2009/09/conv_orig_m.png"><img src="http://nklein.com/wp-content/uploads/2009/09/conv_orig_m-300x300.png" alt="conv_orig_m" title="conv_orig_m" width="300" height="300" class="alignnone size-medium wp-image-863" /></a>&nbsp;&nbsp;<a href="http://nklein.com/wp-content/uploads/2009/09/conv_orig_p.png"><img src="http://nklein.com/wp-content/uploads/2009/09/conv_orig_p-300x300.png" alt="conv_orig_p" title="conv_orig_p" width="300" height="300" class="alignnone size-medium wp-image-864" /></a></center></p>
<p>From there, I took the Fourier Transform:<br />
<center><a href="http://nklein.com/wp-content/uploads/2009/09/conv_pre_m.png"><img src="http://nklein.com/wp-content/uploads/2009/09/conv_pre_m-300x300.png" alt="conv_pre_m" title="conv_pre_m" width="300" height="300" class="alignnone size-medium wp-image-865" /></a>&nbsp;&nbsp;<a href="http://nklein.com/wp-content/uploads/2009/09/conv_pre_p.png"><img src="http://nklein.com/wp-content/uploads/2009/09/conv_pre_p-300x300.png" alt="conv_pre_p" title="conv_pre_p" width="300" height="300" class="alignnone size-medium wp-image-866" /></a></center></p>
<p>Then, I did a horizontal <a href="http://en.wikipedia.org/wiki/Sobel_operator">Sobel operator</a> on it to get this:<br />
<center><a href="http://nklein.com/wp-content/uploads/2009/09/conv_post_m.png"><img src="http://nklein.com/wp-content/uploads/2009/09/conv_post_m-300x300.png" alt="conv_post_m" title="conv_post_m" width="300" height="300" class="alignnone size-medium wp-image-867" /></a>&nbsp;&nbsp;<a href="http://nklein.com/wp-content/uploads/2009/09/conv_post_p.png"><img src="http://nklein.com/wp-content/uploads/2009/09/conv_post_p-300x300.png" alt="conv_post_p" title="conv_post_p" width="300" height="300" class="alignnone size-medium wp-image-868" /></a></center></p>
<p>From there, I did the Inverse Fourier Transform to obtain this:<br />
<center><a href="http://nklein.com/wp-content/uploads/2009/09/conv_final_m.png"><img src="http://nklein.com/wp-content/uploads/2009/09/conv_final_m-300x300.png" alt="conv_final_m" title="conv_final_m" width="300" height="300" class="alignnone size-medium wp-image-869" /></a>&nbsp;&nbsp;<a href="http://nklein.com/wp-content/uploads/2009/09/conv_final_p.png"><img src="http://nklein.com/wp-content/uploads/2009/09/conv_final_p-300x300.png" alt="conv_final_p" title="conv_final_p" width="300" height="300" class="alignnone size-medium wp-image-870" /></a></center></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2009/09/blur-and-edge-detect-your-fourier-transforms/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Simple Function Plotting in Javascript</title>
		<link>http://nklein.com/2009/09/simple-function-plotting-in-javascript/</link>
		<comments>http://nklein.com/2009/09/simple-function-plotting-in-javascript/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 15:02:59 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=843</guid>
		<description><![CDATA[Rather than work more on my FFT Paint program yesterday, I took a break to make a simple function plotter. There are lots of useful Java applets out there that do more than what I&#8217;ve done here. And, certainly, gnuplot is much more complete and useful. On the other hand, if you just want to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://nklein.com/wp-content/uploads/2009/09/graph.png"><img src="http://nklein.com/wp-content/uploads/2009/09/graph-300x200.png" alt="graph" title="graph" width="300" height="200" class="alignright size-medium wp-image-846" style="margin-top: 4mm;"/></a>Rather than work more on my <a href="http://nklein.com/mas-961/fft-paint/">FFT Paint</a> program yesterday, I took a break to make a <a href="http://nklein.com/math-scripts/simple-graph/">simple function plotter</a>.  There are lots of useful Java applets out there that do more than what I&#8217;ve done here.  And, certainly, <a href="http://www.gnuplot.info/">gnuplot</a> is much more complete and useful.</p>
<p>On the other hand, if you just want to quickly plot something that you can save as an image, you either have to re-learn gnuplot (every time I use it, I have to sift through the help to figure out how to set up my tics and labels and output size and output filename) or you have to do screen grabs from one of the Java applets.</p>
<p>With the <a href="http://nklein.com/math-scripts/simple-graph/">plotter that I wrote yesterday</a>, you click on the <q>Snapshot</q> button, then right-click to save the image or copy it to your clipboard.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2009/09/simple-function-plotting-in-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Better Examples of Fourier Transform Painting</title>
		<link>http://nklein.com/2009/09/better-examples-of-fourier-transform-painting/</link>
		<comments>http://nklein.com/2009/09/better-examples-of-fourier-transform-painting/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 18:00:43 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=832</guid>
		<description><![CDATA[I have now added symmetry options to my Fourier Transform painting application. As PC pointed out in a comment to my previous post, examples with higher frequency information are more interesting. Here are some images of the background tile of this website. The magnitude is on the left and the phase is on the right. [...]]]></description>
			<content:encoded><![CDATA[<p>I have now added symmetry options to my <a href="http://nklein.com/mas-961/fft-paint/">Fourier Transform painting</a> application.  As PC pointed out in a comment to my <a href="http://nklein.com/2009/09/playing-with-your-fourier-transforms/">previous post</a>, examples with higher frequency information are more interesting.  Here are some images of the background tile of this website.  The magnitude is on the left and the phase is on the right.  You can click them for the full-sized images.</p>
<p>This is the original:<br />
<center><a href="http://nklein.com/wp-content/uploads/2009/09/squares_m.png"><img src="http://nklein.com/wp-content/uploads/2009/09/squares_m-300x300.png" alt="squares_m" title="squares_m" width="300" height="300" class="alignnone size-medium wp-image-833" /></a>&nbsp;&nbsp;<a href="http://nklein.com/wp-content/uploads/2009/09/squares_p.png"><img src="http://nklein.com/wp-content/uploads/2009/09/squares_p-300x300.png" alt="squares_p" title="squares_p" width="300" height="300" class="alignnone size-medium wp-image-834" /></a></center></p>
<p>This is the Fourier transform of the original:<br />
<center><a href="http://nklein.com/wp-content/uploads/2009/09/squares_mf.png"><img src="http://nklein.com/wp-content/uploads/2009/09/squares_mf-300x300.png" alt="squares_mf" title="squares_mf" width="300" height="300" class="alignnone size-medium wp-image-835" /></a>&nbsp;&nbsp;<a href="http://nklein.com/wp-content/uploads/2009/09/squares_pf.png"><img src="http://nklein.com/wp-content/uploads/2009/09/squares_pf-300x300.png" alt="squares_pf" title="squares_pf" width="300" height="300" class="alignnone size-medium wp-image-836" /></a></center></p>
<p>This is my edited version of that transform.  I wiped out lots of the off-axis frequencies.  I tinted the center red.  And, I added some green blotches along the diagonals.<br />
<center><a href="http://nklein.com/wp-content/uploads/2009/09/squares_mfe.png"><img src="http://nklein.com/wp-content/uploads/2009/09/squares_mfe-300x300.png" alt="squares_mfe" title="squares_mfe" width="300" height="300" class="alignnone size-medium wp-image-837" /></a>&nbsp;&nbsp;<a href="http://nklein.com/wp-content/uploads/2009/09/squares_pfe.png"><img src="http://nklein.com/wp-content/uploads/2009/09/squares_pfe-300x300.png" alt="squares_pfe" title="squares_pfe" width="300" height="300" class="alignnone size-medium wp-image-838" /></a></center></p>
<p>And, here is the inverse transform of my edited data.<br />
<center><a href="http://nklein.com/wp-content/uploads/2009/09/squares_mfei.png"><img src="http://nklein.com/wp-content/uploads/2009/09/squares_mfei-300x300.png" alt="squares_mfei" title="squares_mfei" width="300" height="300" class="alignnone size-medium wp-image-839" /></a>&nbsp;&nbsp;<a href="http://nklein.com/wp-content/uploads/2009/09/squares_pfei.png"><img src="http://nklein.com/wp-content/uploads/2009/09/squares_pfei-300x300.png" alt="squares_pfei" title="squares_pfei" width="300" height="300" class="alignnone size-medium wp-image-840" /></a></center></p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2009/09/better-examples-of-fourier-transform-painting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Playing with your Fourier Transforms</title>
		<link>http://nklein.com/2009/09/playing-with-your-fourier-transforms/</link>
		<comments>http://nklein.com/2009/09/playing-with-your-fourier-transforms/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 18:18:30 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=822</guid>
		<description><![CDATA[Earlier, I posted a small script that lets you do Fast Fourier Transforms in Javascript. I did this in to test the waters to see if I could do the exercises for the Numeric Photography study group in Javascript. I am well underway, now, with the first exercise/assignment. The goal is to create an image [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier, I posted a small script that lets you do <a href="http://nklein.com/2009/09/fourier-transforms-in-javascript/">Fast Fourier Transforms in Javascript.</a>  I did this in to test the waters to see if I could do the exercises for the <a href="https://www.ibm.com/developerworks/mydeveloperworks/blogs/algomusic/entry/numeric_photography2">Numeric Photography study group</a> in Javascript.</p>
<p>I am well underway, now, with the first exercise/assignment.  The goal is to create an image editor that lets you work on either the image or the Fourier transform of the image.  I have only tested it under Safari and Firefox so far.  I do intend to add <a href="http://excanvas.sourceforge.net/">excanvas</a> into it later and test it on some other browsers.</p>
<p>If you are interested (and have Safari or Firefox), here is <a href="http://nklein.com/mas-961/fft-paint/">the current state</a>.</p>
<p><strong>Edit</strong> (four hours later):  I have now debugged it under Firefox 3.5.2.</p>
<p><center><a href="http://nklein.com/wp-content/uploads/2009/09/orig.png"><img src="http://nklein.com/wp-content/uploads/2009/09/orig-150x300.png" alt="The original image" title="orig" width="150" height="300" class="size-medium wp-image-826" /></a>&nbsp;<a href="http://nklein.com/wp-content/uploads/2009/09/trans.png"><img src="http://nklein.com/wp-content/uploads/2009/09/trans-150x300.png" alt="Fourier transform with some additions" title="trans" width="150" height="300" class="size-medium wp-image-827" /></a>&nbsp;<a href="http://nklein.com/wp-content/uploads/2009/09/processed.png"><img src="http://nklein.com/wp-content/uploads/2009/09/processed-150x300.png" alt="The inverse transform of the processed image." title="processed" width="150" height="300" class="size-medium wp-image-828" /></a></center></p>
<p>These are the original image, the Fourier transform in which I painted some green dots and phase-rotated the lowest-order frequencies, and the image after the inverse transform.</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2009/09/playing-with-your-fourier-transforms/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Fourier Transforms in JavaScript</title>
		<link>http://nklein.com/2009/09/fourier-transforms-in-javascript/</link>
		<comments>http://nklein.com/2009/09/fourier-transforms-in-javascript/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 17:07:52 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[imgui]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[opengl]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=789</guid>
		<description><![CDATA[In preparation for a study group on Numeric Photography, I started toying with what language to use for the coding projects. Feature shopping My inclination, of course, was to go with Lisp. Part of the goal of the assignments, however, was to make interactive web applications for each assignment and a gallery at the end [...]]]></description>
			<content:encoded><![CDATA[<p>In preparation for <a href="https://www.ibm.com/developerworks/mydeveloperworks/blogs/algomusic/entry/numeric_photography2">a study group</a> on <a href="http://ocw.mit.edu/OcwWeb/Media-Arts-and-Sciences/MAS-961Fall1998/CourseHome/index.htm">Numeric Photography</a>, I started toying with what language to use for the coding projects.</p>
<h3>Feature shopping</h3>
<p>My inclination, of course, was to go with Lisp.  Part of the goal of the assignments, however, was to make interactive web applications for each assignment and a gallery at the end of the completed assignments.  I experimented a bit with <a href="http://common-lisp.net/project/armedbear/">Armed Bear Common Lisp</a>.  The hurdles that I would need a user to go through to use my application safely were too great.  The user would have to edit their own java.policy file to give my applet permission.  If I wanted to let the user do that with a single click or something, I would have to spring for a $200/year code-signing cert.</p>
<p>My next choice then was stand-alone Lisp applications.  Rather than online, interactive applications, I would have downloadable ones.  Not ideal, but doable.  The big hurdle here is crafting a GUI to run the application.  The GUI wouldn&#8217;t be too terrible thanks to an interesting concept that Dirk Gerrits pointed out:  <a href="http://mollyrocket.com/861">Immediate Mode GUIs</a>.  I have already implemented the buttons from <a href="http://sol.gfxile.net/imgui/">this tutorial</a> in OpenGL under SBCL.</p>
<p>Late one night, I remembered <a href="http://common-lisp.net/project/parenscript/">Parenscript</a>.  It is a Lisp-like language that compiles to Javascript.  Parenscript was a little bit more its own thing and a little bit less Lisp than I had wanted.  But, it got me thinking.  What can you do in Javascript these days?</p>
<p>I searched for <a href="http://www.google.com/search?client=safari&#038;rls=en&#038;q=image+processing+javascript&#038;ie=UTF-8&#038;oe=UTF-8">image processing javascript</a>.  The first hit was <a href="http://www.pixastic.com/">Pixastic</a>.  It is a library of basic image processing functions that you can run on any image on your page.  At its heart, it uses the Canvas element that is available on Safari, Firefox, and Opera.  So, I figured, why not?  If I can get an FFT working in Javascript, then there is nothing keeping me from implementing all of the assignments in Javascript.  Yes, Javascript is awful, but it&#8217;s a dream compared to Java.  The new Javascript debugging features in Safari are quite useful, too.</p>
<h3>Success</h3>
<p>Below is a simple example of what I have working.  When you first load the page, you see an image of my son and my dad at the Pittsburgh Zoo.  This image is actually loaded in a hidden image and copied into a visible canvas.  You are seeing the canvas.</p>
<p>If you press the <q>FFT</q> button and wait for it, you will see a representation of the 2-D Discrete Fourier Transform of the image.  Really, the DFT output is complex numbers.  The representation is just the magnitude of the complex numbers.  The actual complex numbers are kept around in a variable so that when you hit the <q>IFFT</q> button, it has enough information to actually reconstruct the image.  So, the <q>FFT</q> button works from the pixels in the canvas.  The <q>IFFT</q> button works from the data generated with the last <q>FFT</q>.  So, unfortunately, you cannot meaningfully FFT-FFT-IFFT-IFFT here.  It is interesting, but not meaningful.</p>
<p>Also, I was trying to add a text box here so that you could use your own image, but I am not getting it right.  You&#8217;re going to have to wait until I finish the whole assignment.</p>
<p><script type="text/javascript" src="http://nklein.com/wp-content/uploads/2009/09/fft.js"></script><br />
<script type="text/javascript">
var _fftData;
</script><br />
<canvas id="the_canvas" width="256" height="256"><br />
      You need a browser that supports the Canvas tag.<br />
      Firefox, Safari, and Opera should all work.<br />
</canvas></p>
<div style="visibility: hidden; width: 0; height: 0;"><img id="the_original" style="visibility: collapse;" src="http://nklein.com/wp-content/uploads/2009/09/ppz.jpg" onload="return prepImageForFFT('the_original','the_canvas');"></img></div>
<form method="post" action="#" onsubmit="loadNewImage('the_original'); return false;">
<input type="button" name="do_fft" value="FFT" onclick="_fftData = FFT( 'the_canvas' ); return true;" />
<input type="button" name="do_ifft" value="IFFT" onclick="IFFT( _fftData, 'the_canvas' ); return true;" />
</form>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2009/09/fourier-transforms-in-javascript/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

