<?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>astatic notes</title>
	<atom:link href="http://blog.inspirit.ru/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.inspirit.ru</link>
	<description>Adobe Flash experiments and stuff</description>
	<lastBuildDate>Mon, 25 Jan 2010 16:50:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Async PNG encoding and merging</title>
		<link>http://blog.inspirit.ru/?p=378</link>
		<comments>http://blog.inspirit.ru/?p=378#comments</comments>
		<pubDate>Mon, 25 Jan 2010 10:01:43 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[works]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[async]]></category>
		<category><![CDATA[encoder]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[flash10]]></category>
		<category><![CDATA[merging]]></category>
		<category><![CDATA[png]]></category>

		<guid isPermaLink="false">http://blog.inspirit.ru/?p=378</guid>
		<description><![CDATA[As you may read in my Twitter last week I was experimenting with asynchronous PNG image encoding and saving. It is very easy task until you need to save a really large/huge image file (for print purpose or whatever). As far as Flash don&#8217;t have ability to compress/deflate ByteArrays in append way or simply partly [...]]]></description>
			<content:encoded><![CDATA[<p>As you may read in my Twitter last week I was experimenting with asynchronous PNG image encoding and saving. It is very easy task until you need to save a really large/huge image file (for print purpose or whatever). As far as Flash don&#8217;t have ability to compress/deflate ByteArrays in append way or simply partly we surely will crash flash player while compressing image data for image larger then 10.000&#215;10.000 px.</p>
<p><a href="http://twitter.com/joa">Joa</a> provided a link to a <a href="http://github.com/emcmanus/flashzlib">flashzlib</a> by Ed McManus and that way the &#8220;sign&#8221; to use Alchemy to process compression via ZLIB.<br />
But what was my surprise when I found that we easily can compile original ZLIB sources in alchemy and use it in our Alchemy projects without any changes! And that was possible since December 2008! Can you believe it? <img src='http://blog.inspirit.ru/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
So I downloaded ZLIB sources and compile them in alchemy as the result I got static library I can append to any Alchemy project. All you need is to write wrapper C class to call functions in ZLIB and get the result back.</p>
<p>I also found brilliant optimized PNG class at <a href="http://wonderfl.net/code/05c93e9a9bb9ec5e4eb2eeefb37cd26be36ebdd6">wonderfl</a> that used different filters for the image data. I&#8217;ve encapsulated that filters in my PNG encoder in both synchronous and asynchronous way. Alchemy is used only for the compress of image data all other operations done in Flash. It is also possible to compile PNGLIB for the Alchemy (as easy as ZLIB) but it will result in really huge *.swc file. So it is to you to decide.</p>
<p>See small demo app where you can encode large PNG files asynchronous with compress level and filter options.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_AsyncPNG_995937743"
			class="flashmovie"
			width="620"
			height="70">
	<param name="movie" value="http://blog.inspirit.ru/wp-content/uploads/pngencode/AsyncPNG.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://blog.inspirit.ru/wp-content/uploads/pngencode/AsyncPNG.swf"
			name="fm_AsyncPNG_995937743"
			width="620"
			height="70">
	<!--<![endif]-->
		<br />
<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a><br />

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><strong><a href="http://blog.inspirit.ru/wp-content/uploads/pngencode/png_encoder.zip">You can get sources here (including *.as classes, ZLIB *.swc, C wrapper source)</a></strong><br />
note: you will need to download and compile your own ZLIB if you want to recompile provided *.swc</p>
<p>Example code of different class possibilities:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc;">var</span> png<span style="color: #000000;">:</span>PNGEncoder = <span style="color: #0033ff;">new</span> PNGEncoder<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
png.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>, onEncoded<span style="color: #000000;">&#41;</span>;
png.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">ProgressEvent</span>.<span style="color: #004993;">PROGRESS</span>, onEncodeProgress<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// filter options are available via static properties</span>
<span style="color: #009900;">// PNGEncoder.FILTER_NONE</span>
<span style="color: #009900;">// PNGEncoder.FILTER_SUB</span>
<span style="color: #009900;">// PNGEncoder.FILTER_UP</span>
<span style="color: #009900;">// PNGEncoder.FILTER_AVERAGE</span>
<span style="color: #009900;">// PNGEncoder.FILTER_PAETH</span>
&nbsp;
<span style="color: #009900;">// we can encode in various ways</span>
<span style="color: #009900;">// Simple static synch encode</span>
&nbsp;
PNGEncoder.encode<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">:</span><span style="color: #004993;">BitmapData</span>, opaque<span style="color: #000000;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff;">false</span>, comressLevel<span style="color: #000000;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000;">-</span><span style="color: #000000;">1</span>, <span style="color: #004993;">filter</span><span style="color: #000000;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">:</span><span style="color: #004993;">ByteArray</span>;
&nbsp;
<span style="color: #009900;">// Asynch encode</span>
<span style="color: #009900;">// you should provide listeners to catch encoding progress and result</span>
&nbsp;
png.encodeAsync<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">:</span><span style="color: #004993;">BitmapData</span>, opaque<span style="color: #000000;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff;">false</span>, comressLevel<span style="color: #000000;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000;">-</span><span style="color: #000000;">1</span>, <span style="color: #004993;">filter</span><span style="color: #000000;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// Asynch multiply Bitmapdata objects merging in single PNG image file</span>
<span style="color: #009900;">// you should provide listeners to catch encoding progress and result</span>
<span style="color: #009900;">// you also should provide callback function for returning Bitmapdata objects for each row</span>
&nbsp;
<span style="color: #6699cc;">var</span> currInfo<span style="color: #000000;">:</span>PNGEncoderInfo = <span style="color: #0033ff;">new</span> PNGEncoderInfo<span style="color: #000000;">&#40;</span>
						resultImageWidth<span style="color: #000000;">:</span><span style="color: #004993;">uint</span>, resultImageHeight<span style="color: #000000;">:</span><span style="color: #004993;">uint</span>,
						numberOfColumns<span style="color: #000000;">:</span><span style="color: #004993;">uint</span>, numberOfRows<span style="color: #000000;">:</span><span style="color: #004993;">uint</span>,
						getNextBitmapsRow<span style="color: #000000;">:</span><span style="color: #004993;">Function</span>, opaque<span style="color: #000000;">:</span><span style="color: #004993;">Boolean</span>,
						compressLevel<span style="color: #000000;">:</span><span style="color: #004993;">int</span>, <span style="color: #004993;">filter</span><span style="color: #000000;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span>;
png.encodeMultiToOne<span style="color: #000000;">&#40;</span>currInfo<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #339966;">function</span> getNextBitmapsRow<span style="color: #000000;">&#40;</span><span style="color: #004993;">info</span><span style="color: #000000;">:</span>PNGEncoderInfo, yi<span style="color: #000000;">:</span><span style="color: #004993;">uint</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">:</span>Vector.<span style="color: #000000;">&lt;</span>BitmapData<span style="color: #000000;">&gt;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc;">var</span> currBitmapsRow<span style="color: #000000;">:</span>Vector.<span style="color: #000000;">&lt;</span>BitmapData<span style="color: #000000;">&gt;</span> = <span style="color: #0033ff;">new</span> Vector.<span style="color: #000000;">&lt;</span>BitmapData<span style="color: #000000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #009900;">// yi argument is current row index</span>
	<span style="color: #009900;">// info.xn - is number of BitmapData objects in image row</span>
	<span style="color: #0033ff;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc;">var</span> j<span style="color: #000000;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000;">0</span>; j <span style="color: #000000;">&lt;</span> <span style="color: #004993;">info</span>.xn; <span style="color: #000000;">++</span>j<span style="color: #000000;">&#41;</span> 
	<span style="color: #000000;">&#123;</span>
		currBitmapsRow<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> = <span style="color: #0033ff;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">800</span>, <span style="color: #000000;">600</span>, <span style="color: #0033ff;">false</span>, <span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">*</span> 0xFFFFFF<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0033ff;">return</span> currBitmapsRow;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966;">function</span> onEncoded<span style="color: #000000;">&#40;</span>e<span style="color: #000000;">:</span><span style="color: #004993;">Event</span> = <span style="color: #0033ff;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">:</span><span style="color: #0033ff;">void</span> 
<span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// here is our encoded PNG file ByteArray</span>
	<span style="color: #6699cc;">var</span> <span style="color: #004993;">data</span><span style="color: #000000;">:</span><span style="color: #004993;">ByteArray</span> = PNGEncoder.encodedPNGData;
<span style="color: #000000;">&#125;</span>
<span style="color: #339966;">function</span> onEncodeProgress<span style="color: #000000;">&#40;</span>e<span style="color: #000000;">:</span><span style="color: #004993;">ProgressEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">:</span><span style="color: #0033ff;">void</span> 
<span style="color: #000000;">&#123;</span>
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'ENCODING PNG: '</span> <span style="color: #000000;">+</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">Math</span>.<span style="color: #004993;">round</span><span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">bytesLoaded</span> <span style="color: #000000;">/</span> e.<span style="color: #004993;">bytesTotal</span> <span style="color: #000000;">*</span> <span style="color: #000000;">100</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">+</span> <span style="color: #990000;">'%'</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.inspirit.ru/?feed=rss2&amp;p=378</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>FluidSolver 3D &#124; first steps</title>
		<link>http://blog.inspirit.ru/?p=373</link>
		<comments>http://blog.inspirit.ru/?p=373#comments</comments>
		<pubDate>Tue, 29 Dec 2009 10:48:39 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[fluids]]></category>
		<category><![CDATA[particles]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://blog.inspirit.ru/?p=373</guid>
		<description><![CDATA[
Well finally I got some time to finish Flash based demo application for the FluidSolver in 3D experiment project. This project is based on my previous fluid solver classes and heavily use Joa&#8217;s TDSI tool. This is my first try to implement this simulation if flash and decided to start from Alchemy based Memory usage [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: center;"><a title="FluidSolver in 3D" rel="shadowbox;width=780;height=460" href="/wp-content/uploads/fluids3d/FluidSolver3D.swf"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/fluids3d/screen.png" alt="FluidSolver in 3D" /></a></div>
<p>Well finally I got some time to finish Flash based demo application for the FluidSolver in 3D experiment project. This project is based on my previous fluid solver classes and heavily use <a href="http://blog.joa-ebert.com/2009/08/05/turbodieselsportinjection/">Joa&#8217;s TDSI tool</a>. This is my first try to implement this simulation if flash and decided to start from Alchemy based Memory usage approach. In plans to try Pixel Bender combined with Alchemy&#8230; All calculations made in Flash using ByteArray read/write with TDSI to handle data. Particle engine is based on dynamically growing/reducing LinkedList.<br />
During building this demo I&#8217;ve lots of test versions, I&#8217;ve tried to use Processing to see the performance difference (you will find links to this screencasts later) also finally discovered the great power of GLSL in Java etc. Mostly because of my Processing results I decided to try Pixel Bender/Alchemy approach in near future. I truly belive it can be done faster in Flash.</p>
<p><a href="http://code.google.com/p/in-spirit/source/browse/#svn/trunk/projects/FluidSolver3D">Sources can be found in my Google repo at FluidSolver3D branch</a> (be careful it is not well organized cause still in heavy development)</p>
<p>OK, here we have Flash demo application that supports different option changes via <strong>Right Click menu</strong>. You can choose live mode by selecting any local mp3 file to visualize or to switch to manual mode. There is also an option to turn on/off Sparkles on particles.</p>
<p><a title="FluidSolver in 3D" rel="shadowbox;width=780;height=460" href="/wp-content/uploads/fluids3d/FluidSolver3D.swf">Fluids Solver in 3D demo application</a><br />
<a href="http://vimeo.com/8435362">See screencasted video on Akira Kiteshi &#8211; Pinball composition</a></p>
<p>Here is some Processing based demos:<br />
<a href="http://vimeo.com/7937565">Fluids 3D | Processing progress</a><br />
<a href="http://vimeo.com/8174093">Cube Fluids | fully GLSL based approach</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.inspirit.ru/?feed=rss2&amp;p=373</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Super Shape in 3D</title>
		<link>http://blog.inspirit.ru/?p=364</link>
		<comments>http://blog.inspirit.ru/?p=364#comments</comments>
		<pubDate>Thu, 12 Nov 2009 14:32:17 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash10]]></category>
		<category><![CDATA[supershape]]></category>
		<category><![CDATA[supershape3d]]></category>

		<guid isPermaLink="false">http://blog.inspirit.ru/?p=364</guid>
		<description><![CDATA[
Couple of days before I stumbled upon Andre Michelle Super Ellipse example. You can think &#8211; nothing special but it is like magic how fast it performs and deforming in different 3D shapes. Next thing after Super Ellipse is Super Shape. It is a lot more complex in computation and I thought Flash would stack [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: center;"><a title="Super Shape in 3D" rel="shadowbox;width=1000;height=560" href="/wp-content/uploads/supershape3d/"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/supershape3d/screen.png" alt="Super Shape in 3D" /></a></div>
<p>Couple of days before I stumbled upon <a href="http://wonderfl.net/code/7139f357051926fe7514765e5038d252d12ba6ff">Andre Michelle Super Ellipse example</a>. You can think &#8211; nothing special but it is like magic how fast it performs and deforming in different 3D shapes. Next thing after Super Ellipse is Super Shape. It is a lot more complex in computation and I thought Flash would stack with it. But after some test it turns to be possible.<br />
You can find a lot more info on subject at <a href="http://local.wasp.uwa.edu.au/~pbourke/geometry/supershape3d/">Paul Bourke website</a>.<br />
I have created a demo application that shows basic usage of Super Shape class. <a href="http://hype.joshuadavis.com/">Hype project</a> was used for Sound Spectrum control and options adjustments upon sound change. This is a very dirty 3D rendering using built in Flash methods with very very primitive triangle Z sorting.</p>
<p><a href="/wp-content/uploads/supershape3d/super_shape_3d.zip">Here is the source for the class</a><br />
<a title="Super Shape in 3D" rel="shadowbox;width=1000;height=560" href="/wp-content/uploads/supershape3d/">Demo Application</a></p>
<p>Simple code example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900;">// create instance with resolution 24</span>
<span style="color: #6699cc;">var</span> ss3d<span style="color: #000000;">:</span>SuperShape3d = <span style="color: #0033ff;">new</span> SuperShape3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">24</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// update shape by applying 2 Super Shapes parameters</span>
ss3d.update<span style="color: #000000;">&#40;</span><span style="color: #000000;">1.0</span>, <span style="color: #000000;">1.0</span>, <span style="color: #000000;">7.0</span>, <span style="color: #000000;">0.2</span>, <span style="color: #000000;">1.7</span>, <span style="color: #000000;">1.7</span>,
			<span style="color: #000000;">1.0</span>, <span style="color: #000000;">1.0</span>, <span style="color: #000000;">7.0</span>, <span style="color: #000000;">0.2</span>, <span style="color: #000000;">1.7</span>, <span style="color: #000000;">1.7</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #6699cc;">var</span> proj<span style="color: #000000;">:</span>PerspectiveProjection = <span style="color: #0033ff;">new</span> PerspectiveProjection<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
proj.fieldOfView = <span style="color: #000000;">75</span>;
<span style="color: #6699cc;">var</span> <span style="color: #004993;">matrix</span><span style="color: #000000;">:</span>Matrix3D = <span style="color: #0033ff;">new</span> Matrix3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">matrix</span>.appendScale<span style="color: #000000;">&#40;</span><span style="color: #000000;">64</span>, <span style="color: #000000;">64</span>, <span style="color: #000000;">64</span><span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">matrix</span>.appendTranslation<span style="color: #000000;">&#40;</span> <span style="color: #000000;">0</span>, <span style="color: #000000;">0</span>, <span style="color: #000000;">128</span><span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">matrix</span>.append<span style="color: #000000;">&#40;</span>proj.toMatrix3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
Utils3D.projectVectors<span style="color: #000000;">&#40;</span><span style="color: #004993;">matrix</span>, ss3d.wVerts, ss3d.projectedVerts, ss3d.uvts<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #0033ff;">this</span>.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
ss3d.<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff;">this</span>.<span style="color: #004993;">graphics</span>, <span style="color: #000000;">1</span>, 0x333333, <span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.inspirit.ru/?feed=rss2&amp;p=364</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Steering Behaviors AS3 lib</title>
		<link>http://blog.inspirit.ru/?p=361</link>
		<comments>http://blog.inspirit.ru/?p=361#comments</comments>
		<pubDate>Mon, 09 Nov 2009 09:10:25 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[works]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[Steering Behaviors]]></category>

		<guid isPermaLink="false">http://blog.inspirit.ru/?p=361</guid>
		<description><![CDATA[
Last week I was working on project where I needed one of my not very old experiment as base. It was about creating a game using steering behaviors logic. I was playing with this stuff some time ago and now I&#8217;ve to re-factor it. So why not to create a public lib for simple usage. [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: center;"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/steer3d/steerlib.png" alt="Steering Behaviors in 3D" /></div>
<p>Last week I was working on project where I needed one of my not very old experiment as base. It was about creating a game using steering behaviors logic. I was <a href="http://blog.inspirit.ru/?tag=steering-behaviors">playing with this stuff</a> some time ago and now I&#8217;ve to re-factor it. So why not to create a public lib for simple usage. The main goal of re-factoring was to make usage as simple as possible, also giving users an ability to add their own behaviors easy. The second point is performance (all iterations done using Linked Lists). This lib doesn&#8217;t have all possible behaviors and may be you wont find smth you are looking for but as for me I think that it simple enough to add new ideas in minutes!<br />
I&#8217;ve included examples in the sources to show the basic usage. One of the examples is using <a href="http://away3d.googlecode.com/svn/trunk/fp10/Away3DLite/src">Away3DLite library</a> for 3D rendering. (you have to download lib yourself)</p>
<p><a href="http://code.google.com/p/in-spirit/source/browse/#svn/trunk/projects/SteeringBehaviors">You can get the sources here</a></p>
<p><strong>Old examples from my blog:</strong></p>
<div style="text-align: center;"><a title="Steering Behaviors in 3D | Flocking" rel="shadowbox;width=800;height=600" href="/wp-content/uploads/steer3d/Steer3D_flocking.swf"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/steer3d/fire_bird.png" alt="Steering Behaviors in 3D | Flocking" /></a></div>
<div style="text-align: center;"><a title="Steering Behaviors in 3D" rel="shadowbox;width=800;height=600" href="/wp-content/uploads/steer3d/Steer3D2.swf"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/steer3d/1st_person.png" alt="Steering Behaviors in 3D" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.inspirit.ru/?feed=rss2&amp;p=361</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Median Filtering [updated]</title>
		<link>http://blog.inspirit.ru/?p=351</link>
		<comments>http://blog.inspirit.ru/?p=351#comments</comments>
		<pubDate>Tue, 20 Oct 2009 07:07:48 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[works]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[bytearray]]></category>
		<category><![CDATA[constant time]]></category>
		<category><![CDATA[flash10]]></category>
		<category><![CDATA[image processing]]></category>
		<category><![CDATA[linked list]]></category>
		<category><![CDATA[median filter]]></category>
		<category><![CDATA[TDSI]]></category>

		<guid isPermaLink="false">http://blog.inspirit.ru/?p=351</guid>
		<description><![CDATA[
If you follow me on Twitter you know that last days Mario, Nicoptere and me were trying to discover the fastest Median Filtering solution for Flash. Our first attempts were around 7 secs per 350&#215;360 image size with small kernel 7&#215;7! You may think that this is very slow, but Median Filtering is slow in [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: center;"><a title="Median Filter" rel="shadowbox;width=700;height=400" href="/wp-content/uploads/median_filter/MedianFilter.swf"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/median_filter/mo1.png" alt="Median Filter" /></a></div>
<p>If you follow me on <a href="http://twitter.com/inspirit">Twitter</a> you know that last days <a href="http://www.quasimondo.com/">Mario</a>, <a href="http://en.nicoptere.net/">Nicoptere</a> and me were trying to discover the fastest Median Filtering solution for Flash. Our first attempts were around 7 secs per 350&#215;360 image size with small kernel 7&#215;7! You may think that this is very slow, but Median Filtering is slow in all environments cause of its architecture. Anyway there is a constant time solution described <a href="http://nomis80.org/ctmf.html">here</a> that will result in constant processing time for any radius. It is also mentioned that this is the fastest possible solution for now!<br />
So no surprise all of us tried to implement it. <img src='http://blog.inspirit.ru/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  After some unlucky results Nicoptere decided to leave the scene but this is all because of lack of time I think! <img src='http://blog.inspirit.ru/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Mario as he always do start trying to implement Linked Lists to make the process as fast as it possible. I&#8217;ve to say that Mario&#8217;s version is the fastest for now except one condition I describe later.<br />
As for me I started with the simple Vector arrays and you will see this code inside my sources. This approach wasn&#8217;t very fast but stable for different kernel sizes. And the final version created using Linked Lists as Mario recommended. As it turns out that my version runs a little bit slower then Mario&#8217;s at small radius but performs faster when we extend filter radius size (starting radius 7).</p>
<p><strong>Update:</strong><br />
I&#8217;ve merged my Histogram class with <a href="http://www.quasimondo.com/archives/000692.php">Mario&#8217;s filter applying structure</a> (it is faster and more accurate) what results in faster and a lot more stable filter results. Now the speed doesn&#8217;t grow upon radius but it performs event faster with larger radius!<br />
Added ByteArray based method using <a href="http://blog.joa-ebert.com/2009/08/05/turbodieselsportinjection/">Joa&#8217;s TDSI tool</a>. It performs faster at small radius but upon radius grow Linked List approach may become faster.<br />
I&#8217;ve also added another ByteArray based method that works amazingly fast! Unfortunately this method will have unexpected results starting radius 16 in worst cases due to a tricky operation of packing integers in to single entry. I put it in MedianFilter Class under constantTimeBALimit name. But it is not included in demo application.</p>
<p><strong>Test results:<br />
Pure coded Linked Lists: 7&#215;7 kernel: 0.8-1.17 sec; 101&#215;101 kernel: 0.7-1.14 sec<br />
ByteArray with TDSI: 7&#215;7 kernel: 0.7-0.86 sec; 101&#215;101 kernel: 1.0-1.17 sec<br />
ByteArray with TDSI (Limited): 7&#215;7 kernel: 0.43-0.51 sec; 101&#215;101 kernel: 0.6-0.74 sec<br />
</strong><br />
(all tests done using standalone non-debug Flash Player version, Mac and PC)</p>
<p><strong>Resources:</strong><br />
<a title="Median Filter" rel="shadowbox;width=700;height=400" href="/wp-content/uploads/median_filter/MedianFilter.swf">Test Application</a><br />
<a href="/wp-content/uploads/median_filter/median_src.zip">Median Filter Class</a></p>
<p><a title="Median Filter" rel="shadowbox[median]" href="/wp-content/uploads/median_filter/imac.png"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/median_filter/imac_th.png" alt="Median Filter" /></a> <a title="Median Filter" rel="shadowbox[median]" href="/wp-content/uploads/median_filter/mo2.png"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/median_filter/mo2_th.png" alt="Median Filter" /></a> <a title="Median Filter" rel="shadowbox[median]" href="/wp-content/uploads/median_filter/swiss.png"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/median_filter/swiss_th.png" alt="Median Filter" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.inspirit.ru/?feed=rss2&amp;p=351</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>FlashSURF Lib [v 1.0 released]</title>
		<link>http://blog.inspirit.ru/?p=343</link>
		<comments>http://blog.inspirit.ru/?p=343#comments</comments>
		<pubDate>Fri, 02 Oct 2009 09:55:56 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[works]]></category>
		<category><![CDATA[alchemy]]></category>
		<category><![CDATA[feature detection]]></category>
		<category><![CDATA[flash10]]></category>
		<category><![CDATA[object tracking]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[surf]]></category>

		<guid isPermaLink="false">http://blog.inspirit.ru/?p=343</guid>
		<description><![CDATA[
Finally I finished all needed preparations for the first initial release of FlashSURF Lib. You&#8217;ve already seen some videos posted in twitter. Now I&#8217;m publishing all the sources to my google repo. I think this project has a lot of opportunities and I&#8217;m really waiting for the response from Flash Community with the advices, ideas, [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: center;"><a title="Flash SURF [panorama reconstruction]" rel="shadowbox;options={handleOversize:'drag'}" href="/wp-content/uploads/flashsurf/pano2_reconstructed.jpg"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/flashsurf/pano2_reconstructed_prev.jpg" alt="Flash SURF" /></a></div>
<p>Finally I finished all needed preparations for the first initial release of FlashSURF Lib. You&#8217;ve already seen some videos posted in twitter. Now I&#8217;m publishing all the sources to my google repo. I think this project has a lot of opportunities and I&#8217;m really waiting for the response from Flash Community with the advices, ideas, etc on how to improve or what to add and so on&#8230;<br />
Currently it supports basic features extraction, matching them to provided reference image and estimating projection matrix between correspondences (Homography). This is the start point to try implement marker-less Augmented Reality or panorama building application or images searching etc. As you see there are tons of ideas in what direction to extend it and I hope you will share yours with me and others as I did. In this case we can end up with smth interesting and useful for everyone!</p>
<p>P.S.: This project is using <a href="http://blog.joa-ebert.com/2009/08/05/turbodieselsportinjection/">Joa&#8217;s TDSI Tool</a>!</p>
<p><a href="http://code.google.com/p/in-spirit/wiki/FlashSurf">Here you will find all the sources and small test application where I tried to describe the main features of the library.</a></p>
<p>And here is some videos and another reconstructed panorama:<br />
<a href="http://vimeo.com/6821344">Talking about FlashSURF at Flash2000 Event</a><br />
<a href="http://vimeo.com/6191859">My first tests of the library</a></p>
<div style="text-align: center;"><a title="Flash SURF [panorama reconstruction]" rel="shadowbox;options={handleOversize:'drag'}" href="/wp-content/uploads/flashsurf/pano1_reconstructed.jpg"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/flashsurf/pano1_reconstructed_prev.jpg" alt="Flash SURF" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.inspirit.ru/?feed=rss2&amp;p=343</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>FluidSolverHD [Alchemy version]</title>
		<link>http://blog.inspirit.ru/?p=339</link>
		<comments>http://blog.inspirit.ru/?p=339#comments</comments>
		<pubDate>Mon, 21 Sep 2009 13:23:05 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[works]]></category>
		<category><![CDATA[alchemy]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash10]]></category>
		<category><![CDATA[fluid solver]]></category>
		<category><![CDATA[msafluid]]></category>

		<guid isPermaLink="false">http://blog.inspirit.ru/?p=339</guid>
		<description><![CDATA[
It was just a question of time for me to try rewriting FluidSolver Class to Alchemy one. It wasn&#8217;t very hard and I was waiting for really speed boosted version. As the result it is faster but not as much as I wanted   I&#8217;ve tried to include Particle engine inside Alchemy code but [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: center;"><a title="FluidSolverHD [Alchemy version]" rel="shadowbox;width=960;height=580" href="/wp-content/uploads/fluidsolver/FluidSolverHD.swf"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/fluidsolver/fshd.png" alt="FluidSolverHD [Alchemy version]" /></a></div>
<p>It was just a question of time for me to try rewriting <a href="http://blog.inspirit.ru/?p=248">FluidSolver Class</a> to Alchemy one. It wasn&#8217;t very hard and I was waiting for really speed boosted version. As the result it is faster but not as much as I wanted <img src='http://blog.inspirit.ru/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  I&#8217;ve tried to include Particle engine inside Alchemy code but it turns out that rendering particles is not really easy task and costs a lot. I&#8217;ve also used <a href="http://blog.joa-ebert.com/2009/08/05/turbodieselsportinjection/">Joa&#8217;s TDSI</a> again but it is not really needed as far as we don&#8217;t have to write/read Alchemy memory a lot (you can un-comment this part in FluidSolverHD class). Anyway the main idea of the class is drawing colors of Fluids and in this part it works great. I&#8217;ve included old test application but with some rewritten methods. Without using particles (25.000) it runs 50-60 FPS using grid size 100&#215;56 for solver iterations. It could be easily changed up to 150 in width and still have 40 FPS! (All this results are in non-debug Flash Player version)</p>
<p><a title="FluidSolverHD [Alchemy version]" rel="shadowbox;width=960;height=580" href="/wp-content/uploads/fluidsolver/FluidSolverHD.swf">You can launch preview application by clicking image above or this link.</a> <strong>(please note: you will need Flash 10 to view it)</strong><br />
<a href="http://code.google.com/p/in-spirit/source/browse/#svn/trunk/projects/FluidSolverHD">Sources could be found in my google repo.</a></p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.inspirit.ru/?feed=rss2&amp;p=339</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Alchemy Canny Detector released</title>
		<link>http://blog.inspirit.ru/?p=336</link>
		<comments>http://blog.inspirit.ru/?p=336#comments</comments>
		<pubDate>Fri, 18 Sep 2009 14:01:03 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[works]]></category>
		<category><![CDATA[alchemy]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[canny edge]]></category>
		<category><![CDATA[flash10]]></category>
		<category><![CDATA[sources]]></category>

		<guid isPermaLink="false">http://blog.inspirit.ru/?p=336</guid>
		<description><![CDATA[Well finally I&#8217;ve finished all needed methods to release Alchemy based version of Canny Edge Detector.
This version is a lot faster then Pixel Bender one. And it looks like it is more accurate in detecting edges.
I&#8217;ve used Joa&#8217;s TDSI tool to speed up writing/reading processes to/from Alchemy memory. That&#8217;s why I&#8217;ve included Joa&#8217;s Memory class. [...]]]></description>
			<content:encoded><![CDATA[<p>Well finally I&#8217;ve finished all needed methods to release Alchemy based version of Canny Edge Detector.<br />
This version is a lot faster then Pixel Bender one. And it looks like it is more accurate in detecting edges.<br />
I&#8217;ve used <a href="http://blog.joa-ebert.com/2009/08/05/turbodieselsportinjection/">Joa&#8217;s TDSI tool</a> to speed up writing/reading processes to/from Alchemy memory. That&#8217;s why I&#8217;ve included <a href="http://code.google.com/p/apparat/">Joa&#8217;s Memory class</a>. Sources already configured so that after building swf file it will be processed by TDSI tool.<br />
But you also can switch it off (that will slow down application a little). In that case you have to set <em>useTDSI</em> property in <strong>CannyEdgeDetectorAlchemy</strong> class to <em>false</em> and you wont need to do post-processing with swf file.</p>
<p><a href="http://code.google.com/p/in-spirit/source/browse/#svn/trunk/projects/CannyEdgeDetectorAlchemy">All the files are available in my Google repo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.inspirit.ru/?feed=rss2&amp;p=336</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Exploring Features [pure AS3 version]</title>
		<link>http://blog.inspirit.ru/?p=334</link>
		<comments>http://blog.inspirit.ru/?p=334#comments</comments>
		<pubDate>Fri, 28 Aug 2009 09:28:13 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[features extraction]]></category>
		<category><![CDATA[flash10]]></category>
		<category><![CDATA[surf]]></category>

		<guid isPermaLink="false">http://blog.inspirit.ru/?p=334</guid>
		<description><![CDATA[
This is quite old video because I made a lot of changes since then. The project now running using Alchemy with help of Joas TDSI optimization. I am also working on more features not just features extraction.
New demos will be posted soon.
]]></description>
			<content:encoded><![CDATA[<p><object width="620" height="310"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6191859&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6191859&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="620" height="310"></embed></object></p>
<p>This is quite old video because I made a lot of changes since then. The project now running using Alchemy with help of <a href="http://blog.joa-ebert.com/2009/08/05/turbodieselsportinjection/">Joas TDSI</a> optimization. I am also working on more features not just features extraction.<br />
New demos will be posted soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.inspirit.ru/?feed=rss2&amp;p=334</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adaptive Thresholding using Integral Image [source]</title>
		<link>http://blog.inspirit.ru/?p=322</link>
		<comments>http://blog.inspirit.ru/?p=322#comments</comments>
		<pubDate>Mon, 10 Aug 2009 08:46:24 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[works]]></category>
		<category><![CDATA[adaptive thresholding]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash10]]></category>
		<category><![CDATA[integral image]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://blog.inspirit.ru/?p=322</guid>
		<description><![CDATA[
I have to admit that built in Flash methods is really fast in processing time and I cant beat the speed of blurred adaptive thresholding versions provided by Mario and Saqoosha. I still think it could perform faster&#8230;   Talking about thresholding result I cant say which one is more accurate &#8211; try it [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: center;"><a title="Compare Adaptive Thresholding Results" rel="shadowbox;options={handleOversize:'drag'}" href="/wp-content/uploads/thresholding/adapt_threshold_results.png"><img style="border: 5px solid #DDDDDD;" src="/wp-content/uploads/thresholding/adap_6.png" alt="Adaptive Thresholding" /></a></div>
<p>I have to admit that built in Flash methods is really fast in processing time and I cant beat the speed of blurred adaptive thresholding versions provided by <a href="http://www.quasimondo.com/archives/000690.php">Mario </a>and <a href="http://blog.jactionscripters.com/2009/05/18/adaptive-thresholding-experiment/">Saqoosha</a>. I still think it could perform faster&#8230; <img src='http://blog.inspirit.ru/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Talking about thresholding result I cant say which one is more accurate &#8211; try it yourself.<br />
<span id="more-322"></span><br />
<a title="Adaptive Thresholding" rel="shadowbox;width=640;height=280" href="/wp-content/uploads/thresholding/Main_adap.swf">Demo application (you will need web camera and Flash 10 installed)</a><br />
<a title="Compare Adaptive Thresholding Results" rel="shadowbox;options={handleOversize:'drag'}" href="/wp-content/uploads/thresholding/adapt_threshold_results.png">See my comparison of thresholded image results</a></p>
<p>Here is the code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc;">var</span> w<span style="color: #000000;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000;">320</span>;
<span style="color: #6699cc;">var</span> h<span style="color: #000000;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000;">240</span>;
<span style="color: #6699cc;">var</span> <span style="color: #004993;">size</span><span style="color: #000000;">:</span><span style="color: #004993;">int</span> = w <span style="color: #000000;">*</span> h;
<span style="color: #6699cc;">var</span> S<span style="color: #000000;">:</span><span style="color: #004993;">int</span> = w <span style="color: #000000;">/</span> <span style="color: #000000;">8</span>;
<span style="color: #6699cc;">var</span> S2<span style="color: #000000;">:</span><span style="color: #004993;">int</span> = S <span style="color: #000000;">&gt;&gt;</span> <span style="color: #000000;">1</span>;
<span style="color: #6699cc;">var</span> T<span style="color: #000000;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">0.15</span>;
<span style="color: #6699cc;">var</span> IT<span style="color: #000000;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">1.0</span> <span style="color: #000000;">-</span> T;
<span style="color: #6699cc;">var</span> integral<span style="color: #000000;">:</span>Vector.<span style="color: #000000;">&lt;</span>int<span style="color: #000000;">&gt;</span> = <span style="color: #0033ff;">new</span> Vector.<span style="color: #000000;">&lt;</span>int<span style="color: #000000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">size</span>, <span style="color: #0033ff;">true</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc;">var</span> <span style="color: #004993;">threshold</span><span style="color: #000000;">:</span>Vector.<span style="color: #000000;">&lt;</span>uint<span style="color: #000000;">&gt;</span> = <span style="color: #0033ff;">new</span> Vector.<span style="color: #000000;">&lt;</span>uint<span style="color: #000000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">size</span>, <span style="color: #0033ff;">true</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #3f5fbf;">/**
* @param bmp Input image (should be gray scaled)
* @param dst Result image
*/</span>
&nbsp;
<span style="color: #339966;">function</span> IntegralImageThresholding<span style="color: #000000;">&#40;</span>bmp<span style="color: #000000;">:</span><span style="color: #004993;">BitmapData</span>, dst<span style="color: #000000;">:</span><span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">:</span><span style="color: #0033ff;">void</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc;">var</span> <span style="color: #004993;">data</span><span style="color: #000000;">:</span>Vector.<span style="color: #000000;">&lt;</span>uint<span style="color: #000000;">&gt;</span> = bmp.getVector<span style="color: #000000;">&#40;</span>bmp.<span style="color: #004993;">rect</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #009900;">//data.fixed = true;</span>
	<span style="color: #6699cc;">var</span> i<span style="color: #000000;">:</span><span style="color: #004993;">int</span>, j<span style="color: #000000;">:</span><span style="color: #004993;">int</span>, diff<span style="color: #000000;">:</span><span style="color: #004993;">int</span>;
	<span style="color: #6699cc;">var</span> x1<span style="color: #000000;">:</span><span style="color: #004993;">int</span>, y1<span style="color: #000000;">:</span><span style="color: #004993;">int</span>, x2<span style="color: #000000;">:</span><span style="color: #004993;">int</span>, y2<span style="color: #000000;">:</span><span style="color: #004993;">int</span>, ind1<span style="color: #000000;">:</span><span style="color: #004993;">int</span>, ind2<span style="color: #000000;">:</span><span style="color: #004993;">int</span>, ind3<span style="color: #000000;">:</span><span style="color: #004993;">int</span>;
	<span style="color: #6699cc;">var</span> sum<span style="color: #000000;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000;">0</span>;
	<span style="color: #6699cc;">var</span> ind<span style="color: #000000;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000;">0</span>;
&nbsp;
	<span style="color: #0033ff;">while</span><span style="color: #000000;">&#40;</span> ind <span style="color: #000000;">&lt;</span> <span style="color: #004993;">size</span> <span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		sum <span style="color: #000000;">+</span>= <span style="color: #004993;">data</span><span style="color: #000000;">&#91;</span>ind<span style="color: #000000;">&#93;</span> <span style="color: #000000;">&amp;</span> 0xFF;
		integral<span style="color: #000000;">&#91;</span>ind<span style="color: #000000;">&#93;</span> = sum;
		ind <span style="color: #000000;">+</span>= w;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	x1 = <span style="color: #000000;">0</span>;
	<span style="color: #0033ff;">for</span><span style="color: #000000;">&#40;</span> i = <span style="color: #000000;">1</span>; i <span style="color: #000000;">&lt;</span> w; <span style="color: #000000;">++</span>i <span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		sum = <span style="color: #000000;">0</span>;
		ind = i;
		ind3 = ind <span style="color: #000000;">-</span> S2;
&nbsp;
		<span style="color: #0033ff;">if</span><span style="color: #000000;">&#40;</span> i <span style="color: #000000;">&gt;</span> S <span style="color: #000000;">&#41;</span> x1 = i <span style="color: #000000;">-</span> S;
		diff = i <span style="color: #000000;">-</span> x1;
		<span style="color: #0033ff;">for</span><span style="color: #000000;">&#40;</span> j = <span style="color: #000000;">0</span>; j <span style="color: #000000;">&lt;</span> h; <span style="color: #000000;">++</span>j <span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			sum <span style="color: #000000;">+</span>= <span style="color: #004993;">data</span><span style="color: #000000;">&#91;</span>ind<span style="color: #000000;">&#93;</span> <span style="color: #000000;">&amp;</span> 0xFF;
			integral<span style="color: #000000;">&#91;</span>ind<span style="color: #000000;">&#93;</span> = integral<span style="color: #000000;">&#91;</span><span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>ind<span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">+</span> sum;
			ind <span style="color: #000000;">+</span>= w;
&nbsp;
			<span style="color: #0033ff;">if</span><span style="color: #000000;">&#40;</span>i <span style="color: #000000;">&lt;</span> S2<span style="color: #000000;">&#41;</span> <span style="color: #0033ff;">continue</span>;
			<span style="color: #0033ff;">if</span><span style="color: #000000;">&#40;</span>j <span style="color: #000000;">&lt;</span> S2<span style="color: #000000;">&#41;</span> <span style="color: #0033ff;">continue</span>;
&nbsp;
			y1 = <span style="color: #000000;">&#40;</span>j <span style="color: #000000;">&lt;</span> S <span style="color: #000000;">?</span> <span style="color: #000000;">0</span> <span style="color: #000000;">:</span> j <span style="color: #000000;">-</span> S<span style="color: #000000;">&#41;</span>;
&nbsp;
			ind1 = y1 <span style="color: #000000;">*</span> w;
			ind2 = j <span style="color: #000000;">*</span> w;
&nbsp;
			<span style="color: #0033ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000000;">&#91;</span>ind3<span style="color: #000000;">&#93;</span><span style="color: #000000;">&amp;</span>0xFF<span style="color: #000000;">&#41;</span><span style="color: #000000;">*</span><span style="color: #000000;">&#40;</span>diff <span style="color: #000000;">*</span> <span style="color: #000000;">&#40;</span>j <span style="color: #000000;">-</span> y1<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&lt;</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>integral<span style="color: #000000;">&#91;</span><span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>ind2 <span style="color: #000000;">+</span> i<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">-</span> integral<span style="color: #000000;">&#91;</span><span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>ind1 <span style="color: #000000;">+</span> i<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">-</span> integral<span style="color: #000000;">&#91;</span><span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>ind2 <span style="color: #000000;">+</span> x1<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">+</span> integral<span style="color: #000000;">&#91;</span><span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>ind1 <span style="color: #000000;">+</span> x1<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">*</span>IT<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">threshold</span><span style="color: #000000;">&#91;</span>ind3<span style="color: #000000;">&#93;</span> = 0x00;
			<span style="color: #000000;">&#125;</span> <span style="color: #0033ff;">else</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">threshold</span><span style="color: #000000;">&#91;</span>ind3<span style="color: #000000;">&#93;</span> = 0xFFFFFF;
			<span style="color: #000000;">&#125;</span>
			ind3 <span style="color: #000000;">+</span>= w;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	y1 = <span style="color: #000000;">0</span>;
	<span style="color: #0033ff;">for</span><span style="color: #000000;">&#40;</span> j = <span style="color: #000000;">0</span>; j <span style="color: #000000;">&lt;</span> h; <span style="color: #000000;">++</span>j <span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		i = <span style="color: #000000;">0</span>;
		y2 = h <span style="color: #000000;">-</span> <span style="color: #000000;">1</span>;
		<span style="color: #0033ff;">if</span><span style="color: #000000;">&#40;</span> j <span style="color: #000000;">&lt;</span> h <span style="color: #000000;">-</span> S2 <span style="color: #000000;">&#41;</span> 
		<span style="color: #000000;">&#123;</span>
			i = w <span style="color: #000000;">-</span> S2;
			y2 = j <span style="color: #000000;">+</span> S2;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		ind = j <span style="color: #000000;">*</span> w <span style="color: #000000;">+</span> i;
		<span style="color: #0033ff;">if</span><span style="color: #000000;">&#40;</span> j <span style="color: #000000;">&gt;</span> S2 <span style="color: #000000;">&#41;</span> y1 = j <span style="color: #000000;">-</span> S2;
		ind1 = y1 <span style="color: #000000;">*</span> w;
		ind2 = y2 <span style="color: #000000;">*</span> w;
		diff = y2 <span style="color: #000000;">-</span> y1;
		<span style="color: #0033ff;">for</span><span style="color: #000000;">&#40;</span> ; i <span style="color: #000000;">&lt;</span> w; <span style="color: #000000;">++</span>i, <span style="color: #000000;">++</span>ind <span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
&nbsp;
			x1 = <span style="color: #000000;">&#40;</span> i <span style="color: #000000;">&lt;</span> S2 <span style="color: #000000;">?</span> <span style="color: #000000;">0</span> <span style="color: #000000;">:</span> i <span style="color: #000000;">-</span> S2<span style="color: #000000;">&#41;</span>;
			x2 = i <span style="color: #000000;">+</span> S2;
&nbsp;
			<span style="color: #009900;">// check the border</span>
			<span style="color: #0033ff;">if</span> <span style="color: #000000;">&#40;</span>x2 <span style="color: #000000;">&gt;</span>= w<span style="color: #000000;">&#41;</span> x2 = w <span style="color: #000000;">-</span> <span style="color: #000000;">1</span>;
&nbsp;
			<span style="color: #0033ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000000;">&#91;</span>ind<span style="color: #000000;">&#93;</span><span style="color: #000000;">&amp;</span>0xFF<span style="color: #000000;">&#41;</span><span style="color: #000000;">*</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>x2 <span style="color: #000000;">-</span> x1<span style="color: #000000;">&#41;</span> <span style="color: #000000;">*</span> diff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&lt;</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>integral<span style="color: #000000;">&#91;</span><span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>ind2 <span style="color: #000000;">+</span> x2<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">-</span> integral<span style="color: #000000;">&#91;</span><span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>ind1 <span style="color: #000000;">+</span> x2<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">-</span> integral<span style="color: #000000;">&#91;</span><span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>ind2 <span style="color: #000000;">+</span> x1<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">+</span> integral<span style="color: #000000;">&#91;</span><span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>ind1 <span style="color: #000000;">+</span> x1<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">*</span>IT<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">threshold</span><span style="color: #000000;">&#91;</span>ind<span style="color: #000000;">&#93;</span> = 0x00;
			<span style="color: #000000;">&#125;</span> <span style="color: #0033ff;">else</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">threshold</span><span style="color: #000000;">&#91;</span>ind<span style="color: #000000;">&#93;</span> = 0xFFFFFF;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	dst.setVector<span style="color: #000000;">&#40;</span>dst.<span style="color: #004993;">rect</span>, <span style="color: #004993;">threshold</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.inspirit.ru/?feed=rss2&amp;p=322</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
