<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Extract shape outline points from BitmapData</title>
	<atom:link href="http://www.sakri.net/blog/2009/04/13/extract-shape-outline-points-from-bitmapdata/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sakri.net/blog/2009/04/13/extract-shape-outline-points-from-bitmapdata/</link>
	<description>I Flash und I Flex Jaaaa</description>
	<lastBuildDate>Fri, 28 Oct 2011 05:36:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Obtenir les segments du contour d’une forme &#124; Ether&#039;O&#039;Clique cité &#8211; AS Blog</title>
		<link>http://www.sakri.net/blog/2009/04/13/extract-shape-outline-points-from-bitmapdata/#comment-1666</link>
		<dc:creator>Obtenir les segments du contour d’une forme &#124; Ether&#039;O&#039;Clique cité &#8211; AS Blog</dc:creator>
		<pubDate>Mon, 12 Sep 2011 09:55:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.sakri.net/blog/?p=274#comment-1666</guid>
		<description>[...] pixels de l&#8217;image, et je met tout ça dans un tableau. Puis j&#8217;utilise un algo tiré du blog de sakri. Il propose également un autre algo sur la base d&#8217;une grille 2&#215;2, mais je n&#8217;ai [...]</description>
		<content:encoded><![CDATA[<p>[...] pixels de l&#8217;image, et je met tout ça dans un tableau. Puis j&#8217;utilise un algo tiré du blog de sakri. Il propose également un autre algo sur la base d&#8217;une grille 2&#215;2, mais je n&#8217;ai [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Box2D Flex Complex Shapes Mapping</title>
		<link>http://www.sakri.net/blog/2009/04/13/extract-shape-outline-points-from-bitmapdata/#comment-1594</link>
		<dc:creator>Box2D Flex Complex Shapes Mapping</dc:creator>
		<pubDate>Thu, 15 Jul 2010 18:20:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.sakri.net/blog/?p=274#comment-1594</guid>
		<description>[...] sakri.net for he&#8217;s shape outline algorithm [...]</description>
		<content:encoded><![CDATA[<p>[...] sakri.net for he&#8217;s shape outline algorithm [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: blog.VETTIGHEID.com &#187; Blog Archive &#187; Grid voor TileEditor</title>
		<link>http://www.sakri.net/blog/2009/04/13/extract-shape-outline-points-from-bitmapdata/#comment-1327</link>
		<dc:creator>blog.VETTIGHEID.com &#187; Blog Archive &#187; Grid voor TileEditor</dc:creator>
		<pubDate>Wed, 20 Jan 2010 16:18:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.sakri.net/blog/?p=274#comment-1327</guid>
		<description>[...] worden deze tiles omgezet naar 1 bitmap. - Van deze bitmap wordt de rand bepaalt met behulp van deze class van Sakri Rosenstrom. - Omdat de class van iedere pixel een punt maak rond ik de punten af naar de [...]</description>
		<content:encoded><![CDATA[<p>[...] worden deze tiles omgezet naar 1 bitmap. &#8211; Van deze bitmap wordt de rand bepaalt met behulp van deze class van Sakri Rosenstrom. &#8211; Omdat de class van iedere pixel een punt maak rond ik de punten af naar de [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Og2t</title>
		<link>http://www.sakri.net/blog/2009/04/13/extract-shape-outline-points-from-bitmapdata/#comment-1254</link>
		<dc:creator>Og2t</dc:creator>
		<pubDate>Thu, 17 Sep 2009 15:18:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.sakri.net/blog/?p=274#comment-1254</guid>
		<description>You could also use GlowFilter and then threshold method (for speed) but of course it wouldn&#039;t give you pixel coords, just the transparent outline BitmapData :)</description>
		<content:encoded><![CDATA[<p>You could also use GlowFilter and then threshold method (for speed) but of course it wouldn&#8217;t give you pixel coords, just the transparent outline BitmapData <img src='http://www.sakri.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: delfeld</title>
		<link>http://www.sakri.net/blog/2009/04/13/extract-shape-outline-points-from-bitmapdata/#comment-1249</link>
		<dc:creator>delfeld</dc:creator>
		<pubDate>Tue, 01 Sep 2009 17:08:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.sakri.net/blog/?p=274#comment-1249</guid>
		<description>I noticed in FlexSimpleTraceBox you are looking to find class names dynamically.  Here are some suggestions:

import flash.utils.getQualifiedClassName;

getQualifiedClassName() returns the name of a class as a String.

Creating a class dynamically:

// SomeClass could be an Object class, too, so can be pretty generic
import some.class.definition.SomeClass;
import flash.utils.getDefinitionByName;

var className:String = &quot;SomeClassName&quot;;
classRef = getDefinitionByName(className) as Class;
imgMC = (new classRef() as SomeClass);</description>
		<content:encoded><![CDATA[<p>I noticed in FlexSimpleTraceBox you are looking to find class names dynamically.  Here are some suggestions:</p>
<p>import flash.utils.getQualifiedClassName;</p>
<p>getQualifiedClassName() returns the name of a class as a String.</p>
<p>Creating a class dynamically:</p>
<p>// SomeClass could be an Object class, too, so can be pretty generic<br />
import some.class.definition.SomeClass;<br />
import flash.utils.getDefinitionByName;</p>
<p>var className:String = &#8220;SomeClassName&#8221;;<br />
classRef = getDefinitionByName(className) as Class;<br />
imgMC = (new classRef() as SomeClass);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sakri</title>
		<link>http://www.sakri.net/blog/2009/04/13/extract-shape-outline-points-from-bitmapdata/#comment-1227</link>
		<dc:creator>sakri</dc:creator>
		<pubDate>Thu, 02 Jul 2009 05:06:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.sakri.net/blog/?p=274#comment-1227</guid>
		<description>Hi Morgan,

Thanks for posting!

Did you see this post http://www.sakri.net/blog/2009/05/28/detecting-edge-pixels-with-marching-squares-algorithm/

I&#039;ve also got the four pixel version running there, however, it&#039;s not bullet proof, there are a few conditions in which a &quot;straight forward&quot; 4 pixel version fails.</description>
		<content:encoded><![CDATA[<p>Hi Morgan,</p>
<p>Thanks for posting!</p>
<p>Did you see this post <a href="http://www.sakri.net/blog/2009/05/28/detecting-edge-pixels-with-marching-squares-algorithm/" rel="nofollow">http://www.sakri.net/blog/2009/05/28/detecting-edge-pixels-with-marching-squares-algorithm/</a></p>
<p>I&#8217;ve also got the four pixel version running there, however, it&#8217;s not bullet proof, there are a few conditions in which a &#8220;straight forward&#8221; 4 pixel version fails.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Morgan Moonjob</title>
		<link>http://www.sakri.net/blog/2009/04/13/extract-shape-outline-points-from-bitmapdata/#comment-1226</link>
		<dc:creator>Morgan Moonjob</dc:creator>
		<pubDate>Wed, 01 Jul 2009 23:39:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.sakri.net/blog/?p=274#comment-1226</guid>
		<description>I took a minute to adapt your code to the 4-pixel marching squares algorithm... :D

package com.MorganMoonjob.edgeDetection{
	import __AS3__.vec.Vector;
	import flash.display.BitmapData;
	import flash.geom.Point;
	
	public class EdgeScanner{
		protected var _scanPts:Vector.=Vector.([
																new Point(0,0),
																new Point(1,0),
																new Point(0,1),
																new Point(1,1)
																	]);
		protected var _variations:Object={
								&quot;0000&quot;:new Point(1,0),
								&quot;0001&quot;:new Point(0,1),
								&quot;0010&quot;:new Point(-1,0),
								&quot;0011&quot;:new Point(-1,0),
								&quot;0100&quot;:new Point(1,0),
								&quot;0101&quot;:new Point(0,1),
								&quot;0110&quot;:new Point(-1,0),
								&quot;0111&quot;:new Point(-1,0),
								&quot;1000&quot;:new Point(0,-1),
								&quot;1001&quot;:new Point(0,-1),
								&quot;1010&quot;:new Point(0,-1),
								&quot;1011&quot;:new Point(0,-1),
								&quot;1100&quot;:new Point(1,0),
								&quot;1101&quot;:new Point(0,1),
								&quot;1110&quot;:new Point(0,-1),
								&quot;1111&quot;:new Point(1,0)
		}
		protected var _target:BitmapData;
		protected var _grid:String;
		
		public function getCurrentGrid():String{
			return _grid+&quot;&quot;;
		}
		protected var _position:Point;
		public function get position():Point{
			return _position;
		}
		
		public function EdgeScanner(target:BitmapData){
			reset(target);
		}
		
		public function reset(target:BitmapData):void{
			_grid=&quot;&quot;;
			_target=target;
		}
		
		public function moveTo(p:Point):void{
			_position=p;
			updateScanGrid();
		}
		protected function updateScanGrid():void{
			_grid=&quot;&quot;;
			var p:Point;
			for(var i:uint=0;i0x0 ? &quot;1&quot; : &quot;0&quot;);
			}
		}
		
		public function getNextEdgePoint():Point{
			var p:Point=_variations[_grid];
			if(p==null)throw new Error(&quot;BitmapEdgeScanner Error : _grid:&quot;+_grid+&quot; , not found in _variations&quot;);
			return new Point(_position.x+p.x,_position.y+p.y);
		}
	}
}</description>
		<content:encoded><![CDATA[<p>I took a minute to adapt your code to the 4-pixel marching squares algorithm&#8230; <img src='http://www.sakri.net/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>package com.MorganMoonjob.edgeDetection{<br />
	import __AS3__.vec.Vector;<br />
	import flash.display.BitmapData;<br />
	import flash.geom.Point;</p>
<p>	public class EdgeScanner{<br />
		protected var _scanPts:Vector.=Vector.([<br />
																new Point(0,0),<br />
																new Point(1,0),<br />
																new Point(0,1),<br />
																new Point(1,1)<br />
																	]);<br />
		protected var _variations:Object={<br />
								&#8220;0000&#8243;:new Point(1,0),<br />
								&#8220;0001&#8243;:new Point(0,1),<br />
								&#8220;0010&#8243;:new Point(-1,0),<br />
								&#8220;0011&#8243;:new Point(-1,0),<br />
								&#8220;0100&#8243;:new Point(1,0),<br />
								&#8220;0101&#8243;:new Point(0,1),<br />
								&#8220;0110&#8243;:new Point(-1,0),<br />
								&#8220;0111&#8243;:new Point(-1,0),<br />
								&#8220;1000&#8243;:new Point(0,-1),<br />
								&#8220;1001&#8243;:new Point(0,-1),<br />
								&#8220;1010&#8243;:new Point(0,-1),<br />
								&#8220;1011&#8243;:new Point(0,-1),<br />
								&#8220;1100&#8243;:new Point(1,0),<br />
								&#8220;1101&#8243;:new Point(0,1),<br />
								&#8220;1110&#8243;:new Point(0,-1),<br />
								&#8220;1111&#8243;:new Point(1,0)<br />
		}<br />
		protected var _target:BitmapData;<br />
		protected var _grid:String;</p>
<p>		public function getCurrentGrid():String{<br />
			return _grid+&#8221;";<br />
		}<br />
		protected var _position:Point;<br />
		public function get position():Point{<br />
			return _position;<br />
		}</p>
<p>		public function EdgeScanner(target:BitmapData){<br />
			reset(target);<br />
		}</p>
<p>		public function reset(target:BitmapData):void{<br />
			_grid=&#8221;";<br />
			_target=target;<br />
		}</p>
<p>		public function moveTo(p:Point):void{<br />
			_position=p;<br />
			updateScanGrid();<br />
		}<br />
		protected function updateScanGrid():void{<br />
			_grid=&#8221;";<br />
			var p:Point;<br />
			for(var i:uint=0;i0x0 ? &#8220;1&#8243; : &#8220;0&#8243;);<br />
			}<br />
		}</p>
<p>		public function getNextEdgePoint():Point{<br />
			var p:Point=_variations[_grid];<br />
			if(p==null)throw new Error(&#8220;BitmapEdgeScanner Error : _grid:&#8221;+_grid+&#8221; , not found in _variations&#8221;);<br />
			return new Point(_position.x+p.x,_position.y+p.y);<br />
		}<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rothrock</title>
		<link>http://www.sakri.net/blog/2009/04/13/extract-shape-outline-points-from-bitmapdata/#comment-1157</link>
		<dc:creator>Rothrock</dc:creator>
		<pubDate>Wed, 20 May 2009 06:05:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.sakri.net/blog/?p=274#comment-1157</guid>
		<description>I haven&#039;t actually made an AS3 version other than modifying what you posted here. Your example is the same idea, just not having a 4-grid. So in your class where you have BitmapEdgeScanner class you replace (or make a second version) of the _scan_points and _variations properties. Also change the loop in updateScanGrid to i&lt;4.

I think your shape extractor is a lot faster than trying to use the marching square to march over all the empty space and the interiors.

And don&#039;t forget to not double size extract the shapes! That is where the biggest time saving seems to be. I was also looking at BitmapData.lock/unlock in some places, but I couldn&#039;t find anywhere where it seemed to make a really large difference.</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t actually made an AS3 version other than modifying what you posted here. Your example is the same idea, just not having a 4-grid. So in your class where you have BitmapEdgeScanner class you replace (or make a second version) of the _scan_points and _variations properties. Also change the loop in updateScanGrid to i&lt;4.</p>
<p>I think your shape extractor is a lot faster than trying to use the marching square to march over all the empty space and the interiors.</p>
<p>And don&#8217;t forget to not double size extract the shapes! That is where the biggest time saving seems to be. I was also looking at BitmapData.lock/unlock in some places, but I couldn&#8217;t find anywhere where it seemed to make a really large difference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sakri</title>
		<link>http://www.sakri.net/blog/2009/04/13/extract-shape-outline-points-from-bitmapdata/#comment-1156</link>
		<dc:creator>sakri</dc:creator>
		<pubDate>Wed, 20 May 2009 05:14:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.sakri.net/blog/?p=274#comment-1156</guid>
		<description>Hi Rothrock,

Thanks for taking the time to post :) I had a quick look at Marching Squares on wikipedia, looks great! In retrospect, I&#039;m wondering why I went for 9 squares :D

Do you have an AS3 implementation of Marching Squares?  I&#039;d love to give it a spin myself...

Thanks again :)


Sakri</description>
		<content:encoded><![CDATA[<p>Hi Rothrock,</p>
<p>Thanks for taking the time to post <img src='http://www.sakri.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I had a quick look at Marching Squares on wikipedia, looks great! In retrospect, I&#8217;m wondering why I went for 9 squares <img src='http://www.sakri.net/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Do you have an AS3 implementation of Marching Squares?  I&#8217;d love to give it a spin myself&#8230;</p>
<p>Thanks again <img src='http://www.sakri.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Sakri</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rothrock</title>
		<link>http://www.sakri.net/blog/2009/04/13/extract-shape-outline-points-from-bitmapdata/#comment-1155</link>
		<dc:creator>Rothrock</dc:creator>
		<pubDate>Tue, 19 May 2009 21:11:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.sakri.net/blog/?p=274#comment-1155</guid>
		<description>Yeah I think Marching Squares is a good choice. I used your algorithm (not the whole example) on a 264 x 290 bitmap with 5 shapes in it. (Just doodles with the paint brush.)

Using the double sized extraction and your 9-grid search it took 137 milliseconds.
Using the double sized extraction and a 4-grid search it took 124 milliseconds

Using the single sized extraction and a 4-grid search it took 44 milliseconds

I couldn&#039;t use the 9-grid search with the single sized extraction because my shape throws an error.

But the combination of not having to double the bitmap and having to only test 4 pixel values is a lot faster than your current implementation.

Here is the scan points:

   new Point(0,-1),
   new Point(-1,-1),
   new Point(-1,0),
   new Point(0,0)


With a 4-grid there are only 16 possible combinations compared to the 512 for a nine grid. I&#039;m not sure how you are getting away with 40 combinations, but I&#039;m guessing it has to do with the center always being an on pixel and the doubling must rule out some others. Maybe? With 4 grid there are two combinations that don&#039;t occur, all on and all off so the 14 variations are:

	&quot;0001&quot; :new Point(1,0),
	&quot;0010&quot; :new Point(0,1),
	&quot;0011&quot; :new Point(1,0),
	&quot;0100&quot; :new Point(-1,0),
	&quot;0101&quot; :new Point(1,0),
	&quot;0110&quot; :new Point(0,1),
	&quot;0111&quot; :new Point(1,0),
	&quot;1000&quot; :new Point(0,-1),
	&quot;1001&quot; :new Point(0,-1),
	&quot;1010&quot; :new Point(0,1),
	&quot;1011&quot; :new Point(0,-1),
	&quot;1100&quot; :new Point(-1,0),
	&quot;1101&quot; :new Point(-1,0),
	&quot;1110&quot; :new Point(0,1)

There are two ambiguous variations 0101 and 1010. Those whould be where a shape approaches itself at an angle but doesn&#039;t touch. I haven&#039;t tried it yet to see if that can cause an &quot;infinite&quot; loop.</description>
		<content:encoded><![CDATA[<p>Yeah I think Marching Squares is a good choice. I used your algorithm (not the whole example) on a 264 x 290 bitmap with 5 shapes in it. (Just doodles with the paint brush.)</p>
<p>Using the double sized extraction and your 9-grid search it took 137 milliseconds.<br />
Using the double sized extraction and a 4-grid search it took 124 milliseconds</p>
<p>Using the single sized extraction and a 4-grid search it took 44 milliseconds</p>
<p>I couldn&#8217;t use the 9-grid search with the single sized extraction because my shape throws an error.</p>
<p>But the combination of not having to double the bitmap and having to only test 4 pixel values is a lot faster than your current implementation.</p>
<p>Here is the scan points:</p>
<p>   new Point(0,-1),<br />
   new Point(-1,-1),<br />
   new Point(-1,0),<br />
   new Point(0,0)</p>
<p>With a 4-grid there are only 16 possible combinations compared to the 512 for a nine grid. I&#8217;m not sure how you are getting away with 40 combinations, but I&#8217;m guessing it has to do with the center always being an on pixel and the doubling must rule out some others. Maybe? With 4 grid there are two combinations that don&#8217;t occur, all on and all off so the 14 variations are:</p>
<p>	&#8220;0001&#8243; :new Point(1,0),<br />
	&#8220;0010&#8243; :new Point(0,1),<br />
	&#8220;0011&#8243; :new Point(1,0),<br />
	&#8220;0100&#8243; :new Point(-1,0),<br />
	&#8220;0101&#8243; :new Point(1,0),<br />
	&#8220;0110&#8243; :new Point(0,1),<br />
	&#8220;0111&#8243; :new Point(1,0),<br />
	&#8220;1000&#8243; :new Point(0,-1),<br />
	&#8220;1001&#8243; :new Point(0,-1),<br />
	&#8220;1010&#8243; :new Point(0,1),<br />
	&#8220;1011&#8243; :new Point(0,-1),<br />
	&#8220;1100&#8243; :new Point(-1,0),<br />
	&#8220;1101&#8243; :new Point(-1,0),<br />
	&#8220;1110&#8243; :new Point(0,1)</p>
<p>There are two ambiguous variations 0101 and 1010. Those whould be where a shape approaches itself at an angle but doesn&#8217;t touch. I haven&#8217;t tried it yet to see if that can cause an &#8220;infinite&#8221; loop.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

