<?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>CleVR » Panoramic photography and image stitching blog &#187; clevrlib</title>
	<atom:link href="http://www.clevr.com/blog/category/clevrlib/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clevr.com/blog</link>
	<description>Panoramic photography, virtual tours and stitching software</description>
	<lastBuildDate>Wed, 22 Jul 2009 18:24:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Resizing Actionscript images with bicubic or bilinear interpolation</title>
		<link>http://www.clevr.com/blog/2008/resize-actionscript-bicubic-bilinear-interpolation/</link>
		<comments>http://www.clevr.com/blog/2008/resize-actionscript-bicubic-bilinear-interpolation/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 08:19:03 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[CleVR]]></category>
		<category><![CDATA[clevrlib]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[image processing]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[maths]]></category>

		<guid isPermaLink="false">http://www.clevr.com/blog/2008/resize-actionscript-bicubic-bilinear-interpolation/</guid>
		<description><![CDATA[I&#8217;ve had a few people contact me to ask about how to use clevrlib to resize images with bicubic or bilinear interpolation in Flash or Flex, so I&#8217;ll give an overview of how to do this. The InterpolatedBitmapData class adds the methods getPixelBicubic and getPixelBilinear to the BitmapData class, which allows you to fetch the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a few people contact me to ask about how to use <a href="http://clevrlib.riaforge.org/">clevrlib</a> to resize images with bicubic or bilinear interpolation in Flash or Flex, so I&#8217;ll give an overview of how to do this. </p>
<p>The InterpolatedBitmapData class adds the methods <code>getPixelBicubic</code> and <code>getPixelBilinear</code> to the BitmapData class, which allows you to fetch the colour of a point that&#8217;s not on a pixel boundary. We use this when reprojecting the source images in the CleVR Stitcher, but it can work just as well for resizing an image. Bear in mind that bicubic is a lot slower than bilinear, and the quality improvement isn&#8217;t usually worthwhile. However, you&#8217;re welcome to switch to getPixelBicubic if you need to. </p>
<p>The basic method I&#8217;m using here for resizing is to loop through the pixels of the output image, getting the equivalent pixels in the source image. As these are found by multiplying by the ratio between the source and output sizes, the coordinates probably won&#8217;t be integers. Using regular getPixel would require rounding, and therefore give a jagged (aliased) output. The getPixelXxx methods let you pass them a Number, which needn&#8217;t be an integer, giving a much smoother result. </p>
<p>The sample code below shows a way of resizing an image using this method. The InterpolatedBitmapData should be created in the same way as a BitmapData, such as by <code>draw()</code>ing a loader onto it. The example I&#8217;ve shown below is an Event.COMPLETE handler for a Loader.  Code below the cut.<br />
<span id="more-65"></span></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">source</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">IBitmapDrawable</span> = event.<span style="color: #004993;">target</span>.<span style="color: #004993;">loader</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> original<span style="color: #000000; font-weight: bold;">:</span>InterpolatedBitmapData = <span style="color: #0033ff; font-weight: bold;">new</span> InterpolatedBitmapData<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>.<span style="color: #004993;">width</span>, <span style="color: #004993;">source</span>.<span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span>;
original.<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #3f5fbf;">/* The size of the output image */</span>
<span style="color: #6699cc; font-weight: bold;">var</span> newWidth<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">100</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> newHeight<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">200</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> resized<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>newWidth, newHeight<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> xFactor<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = original.<span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">/</span> newWidth;
<span style="color: #6699cc; font-weight: bold;">var</span> yFactor<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = original.<span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">/</span> newHeight;
&nbsp;
<span style="color: #3f5fbf;">/* Loop through the pixels of the output image, fetching the equivalent pixel from the input*/</span>
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span>; <span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">&lt;</span> newWidth; <span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span>; <span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">&lt;</span> newHeight; <span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        resized.<span style="color: #004993;">setPixel</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">x</span>, <span style="color: #004993;">y</span>, original.getPixelBilinear<span style="color: #000000;">&#40;</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">*</span> xFactor, <span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">*</span> yFactor<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.clevr.com/blog/2008/resize-actionscript-bicubic-bilinear-interpolation/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>CleVR Actionscript libraries now on RIAForge</title>
		<link>http://www.clevr.com/blog/2007/clevr-actionscript-libraries-now-on-riaforge/</link>
		<comments>http://www.clevr.com/blog/2007/clevr-actionscript-libraries-now-on-riaforge/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 12:27:09 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[CleVR]]></category>
		<category><![CDATA[clevrlib]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[image processing]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[maths]]></category>
		<category><![CDATA[Stitcher]]></category>

		<guid isPermaLink="false">http://www.clevr.com/blog/2007/clevr-actionscript-libraries-now-on-riaforge/</guid>
		<description><![CDATA[I&#8217;ve put up the CleVR AS3 libraries on RIAForge, where you can download them as a zip file, or use the svn repository. The library includes a number of classes that we developed as part of the CleVR Stitcher. They include a set of matrix algebra classes, ported from the Java JAMA library. These let [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve put up the CleVR AS3 libraries on <a href="http://clevrlib.riaforge.org/">RIAForge</a>, where you can download them as a zip file, or use the svn repository.</p>
<p>The library includes a number of classes that we developed as part of <a href="http://www.clevr.com/blog/air-stitcher/">the CleVR Stitcher</a>. They include a set of matrix algebra classes, ported from the Java JAMA library. These let you do standard matrix algebra stuff, and includes support for singular value decomposition and QR decomposition.</p>
<p>There&#8217;s also some graphics classes. One is a subclass of BitmapData that adds bicubic and bilinear interpolation. Another is a class for calculating the histogram of an image, with methods to do histogram stretching. This gives results similar to &#8220;Auto levels&#8221; in Photoshop, or &#8220;Enhance&#8221; in iPhoto.</p>
<p>You will find them <a href="http://clevrlib.riaforge.org/">here</a>. They&#8217;re released under the Creative Commons attribution licence, which basically lets you do anything with them, so long as you give credit somewhere. A link to clevr.com would usually suffice. Let me know if you have any comments, patches, or if you&#8217;re using it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clevr.com/blog/2007/clevr-actionscript-libraries-now-on-riaforge/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

