<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Actionscript 3 Bitmap Segmentor (Source Code Included)</title>
	<link>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/</link>
	<description>Your basic design blog.</description>
	<pubDate>Tue, 14 Oct 2008 13:09:39 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>

	<item>
		<title>By: kevin</title>
		<link>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-253409</link>
		<author>kevin</author>
		<pubDate>Tue, 07 Oct 2008 00:14:27 +0000</pubDate>
		<guid>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-253409</guid>
		<description>Thanks for the reply... Now I got a question still on the same topic... your saying it won't work because it was build in flex... but could your libraries be used in flash somehow? if not what is it keeping it from not being being transferable?  First and foremost I'm new with the whole flash/flex I know all the other languages by heart C++\C\JAva\etc... but on this I', really not too familiar... 

I really want to use your libraries to build a player that can do a frame by frame seek... using flash...
maybe to much to ask :P

Thanks again for your help</description>
		<content:encoded><![CDATA[<p>Thanks for the reply&#8230; Now I got a question still on the same topic&#8230; your saying it won&#8217;t work because it was build in flex&#8230; but could your libraries be used in flash somehow? if not what is it keeping it from not being being transferable?  First and foremost I&#8217;m new with the whole flash/flex I know all the other languages by heart C++\C\JAva\etc&#8230; but on this I&#8217;, really not too familiar&#8230; </p>
<p>I really want to use your libraries to build a player that can do a frame by frame seek&#8230; using flash&#8230;<br />
maybe to much to ask <img src='http://www.somerandomdude.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Thanks again for your help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Mulloy</title>
		<link>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-253385</link>
		<author>Brian Mulloy</author>
		<pubDate>Mon, 22 Sep 2008 15:07:40 +0000</pubDate>
		<guid>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-253385</guid>
		<description>cool concept and the code looks great.

if there is an analogous way to segment sound using flash?</description>
		<content:encoded><![CDATA[<p>cool concept and the code looks great.</p>
<p>if there is an analogous way to segment sound using flash?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: somerandomdude</title>
		<link>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-253349</link>
		<author>somerandomdude</author>
		<pubDate>Wed, 10 Sep 2008 22:48:30 +0000</pubDate>
		<guid>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-253349</guid>
		<description>&lt;strong&gt;kevin&lt;/strong&gt; - The example is built with Flex, it sounds like you're trying to compile it in Flash. Unfortunately, it's not going to work in Flash.</description>
		<content:encoded><![CDATA[<p><strong>kevin</strong> - The example is built with Flex, it sounds like you&#8217;re trying to compile it in Flash. Unfortunately, it&#8217;s not going to work in Flash.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kevin</title>
		<link>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-253348</link>
		<author>kevin</author>
		<pubDate>Wed, 10 Sep 2008 22:39:40 +0000</pubDate>
		<guid>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-253348</guid>
		<description>Hey man great post! I love it! 
now I'm trying to use your Segmentor.as but I get a "1017: The definition of base class UIComponent was not found" error

So I tried a fix by adding new paths to my AS3.0 preferences:
"$(AppConfig)/Component Source/ActionScript 3.0/User Interface"

No luck... any ideas? thanks</description>
		<content:encoded><![CDATA[<p>Hey man great post! I love it!<br />
now I&#8217;m trying to use your Segmentor.as but I get a &#8220;1017: The definition of base class UIComponent was not found&#8221; error</p>
<p>So I tried a fix by adding new paths to my AS3.0 preferences:<br />
&#8220;$(AppConfig)/Component Source/ActionScript 3.0/User Interface&#8221;</p>
<p>No luck&#8230; any ideas? thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flash Tutorials &#124; 7 AS3 Classes &#124; Lemlinh.com</title>
		<link>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-253268</link>
		<author>Flash Tutorials &#124; 7 AS3 Classes &#124; Lemlinh.com</author>
		<pubDate>Mon, 01 Sep 2008 14:08:53 +0000</pubDate>
		<guid>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-253268</guid>
		<description>[...] Read more [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Read more [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dan</title>
		<link>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-252909</link>
		<author>dan</author>
		<pubDate>Thu, 24 Jul 2008 23:16:05 +0000</pubDate>
		<guid>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-252909</guid>
		<description>ha ha that video was awesome</description>
		<content:encoded><![CDATA[<p>ha ha that video was awesome</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Magnus</title>
		<link>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-252564</link>
		<author>Magnus</author>
		<pubDate>Mon, 12 May 2008 05:54:19 +0000</pubDate>
		<guid>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-252564</guid>
		<description>Great example, but perhaps a silly question, could this be used in Flash CS3? I'm thinking of an application with a picture in the background.

&lt;em&gt;Magnus's last blog post..&lt;a href='http://feeds.feedburner.com/~r/drupal/IVKW/~3/288087844/5314-emug-meetings-abu-dhabi.html' rel="nofollow"&gt;EMUG Meetings in Abu Dhabi?&lt;/a&gt;&lt;/em&gt;</description>
		<content:encoded><![CDATA[<p>Great example, but perhaps a silly question, could this be used in Flash CS3? I&#8217;m thinking of an application with a picture in the background.</p>
<p><em>Magnus&#8217;s last blog post..<a href='http://feeds.feedburner.com/~r/drupal/IVKW/~3/288087844/5314-emug-meetings-abu-dhabi.html' rel="nofollow">EMUG Meetings in Abu Dhabi?</a></em></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shigil</title>
		<link>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-247837</link>
		<author>shigil</author>
		<pubDate>Fri, 04 Apr 2008 11:50:24 +0000</pubDate>
		<guid>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-247837</guid>
		<description>can we use colour matrix to transform images that are loaded in a UIloader through xml ,the images are animated using xml values(copy motion as xml).
i want to modify my xml in such a way that i could apply grey scale to it.</description>
		<content:encoded><![CDATA[<p>can we use colour matrix to transform images that are loaded in a UIloader through xml ,the images are animated using xml values(copy motion as xml).<br />
i want to modify my xml in such a way that i could apply grey scale to it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: somerandomdude</title>
		<link>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-244890</link>
		<author>somerandomdude</author>
		<pubDate>Wed, 23 Jan 2008 07:37:45 +0000</pubDate>
		<guid>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-244890</guid>
		<description>Wow Neil, thanks so much for writing such a thought-out and intelligent comment - you definitely win the best comment of the month award. ;)

Your solution for sampling color is so much more graceful and simpler than mine - I can't wait to implement it and observe the performance increases. I really do appreciate you taking the time to share this method as it definitely made this article much, much better.</description>
		<content:encoded><![CDATA[<p>Wow Neil, thanks so much for writing such a thought-out and intelligent comment - you definitely win the best comment of the month award. <img src='http://www.somerandomdude.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Your solution for sampling color is so much more graceful and simpler than mine - I can&#8217;t wait to implement it and observe the performance increases. I really do appreciate you taking the time to share this method as it definitely made this article much, much better.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: neil voss</title>
		<link>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-244856</link>
		<author>neil voss</author>
		<pubDate>Wed, 23 Jan 2008 06:28:09 +0000</pubDate>
		<guid>http://www.somerandomdude.net/blog/flash/bitmap-segmentor/#comment-244856</guid>
		<description>If you just want to process video (or any IBitmapDrawable) to arrive at a down-sampled, interpolated grid, a cheap way to do it is to just 'mosaic' the source by way of scaling it down into a bitmap, then look at the related value of the color in each mosaic tile region (bitmap pixel). This allows you to rely on sampling and manipulating a lot less info and taking advantage of whatever flash is doing behind the scenes to scale. The cost here is you don't end up with an object containing a clone of the original region's whole data to easily display and transform (although that is sort of a different problem vs. getting a 'value' for the region's average color/hue/etc. -- and you could always reverse a grid back to its source by way of some simple factory methods performed on the downsampled data vs. the original source).

For example:

(1) Play a video (or set up any bitmap data provider)

(2) 'Mosaic' it... down-sample it into a bitmap data... this can either be done by (a) using a single bitmap data as a single buffer to capture the video into, scaling to fit the buffer during capture or (b) using 2 bitmap datas as a double buffer where the initial capture is unscaled, then is copied to a second bitmap (scaling prior to or during this second step).

(2a) Duplicate the video into a bitmap data whose size maps 1 pixel to each 'region' being captured. For example a 320 x 240 video source with '10 rows' and '20 columns' would be captured into a bitmap that is 32 x 12 pixels. Use a matrix transform to scale with the draw() method to scale the source to the output resolution during capture. You can apply smoothing as desired (depending on what sort of interpolation you want).

(2b) Duplicate the video into a bitmap data whose size matches the source (using draw()). Then either:

(2b1) nest that bitmap (buffer#1) into a parent object, then draw() the parent object into a lower resolution bitmap (buffer#2). This should get around having to bother with a matrix transform of any sort during the draw() step since you are drawing from a parent's display space (so the scaled-down child data is captured in its scaled-down form vs. its unscaled form).

(2b2) copyPixels() that bitmap (buffer#1) into a lower resolution bitmap (buffer#2), using a matrix transformation to reduce the resolution during the copyPixels() operation. You can also decide whether you want to selectively mess with channels in this step.

(3) Once you essentially have a low-resolution bitmap of the original video (where flash has done the interpolation for you) you can then quickly traverse the low-resolution data to get a given sample regions average value (and in turn can look at that sample's color as RGB, HSV or whatever else).

In this scenario instead of having an object for every slice you'd basically have a buffer (a bunch of pixel data where each pixel represents a sample region's average value), and some utility methods for using the buffer's data. You could still then allocate an object acting as a view for each sample - whereby the buffer is basically the model data provided to that view. You could just set an update() method on the view that gets passed the new buffer's value when it is updated (so for each sample period you dispatch or notify the views that the buffer data has changed, passing them or referencing them their region's pixel 'value').

Maybe I only took a fast look at your code - it looked quite good, and well-written. Where when you 'sample' you are actually performing an average on each region by going through each pixel of the region (and keeping each pixel's RGB in a sample set). This step you don't need, since you can arrive at an average pretty efficiently just relying on flash to down-sample the region for you (and you can define from a few common interpolation methods -- linear = no smoothing, bilinear = smoothing). Once you have the average you can easily compute HSV/brightness/etc. using external utility methods vs. methods on the object/data itself (the rgb2hsv, hex2rgb, etc. color space methods can certainly be static, and/or external to the samples themselves).

Another advantage to this hack is that you can use common Bitmap filters and transformations that flash applies (fast) to manipulate the downsampled buffer data (increase contrast, invert values, blur it, edge contrast it, etc.).

Hope you find this useful!... 
N</description>
		<content:encoded><![CDATA[<p>If you just want to process video (or any IBitmapDrawable) to arrive at a down-sampled, interpolated grid, a cheap way to do it is to just &#8216;mosaic&#8217; the source by way of scaling it down into a bitmap, then look at the related value of the color in each mosaic tile region (bitmap pixel). This allows you to rely on sampling and manipulating a lot less info and taking advantage of whatever flash is doing behind the scenes to scale. The cost here is you don&#8217;t end up with an object containing a clone of the original region&#8217;s whole data to easily display and transform (although that is sort of a different problem vs. getting a &#8216;value&#8217; for the region&#8217;s average color/hue/etc. &#8212; and you could always reverse a grid back to its source by way of some simple factory methods performed on the downsampled data vs. the original source).</p>
<p>For example:</p>
<p>(1) Play a video (or set up any bitmap data provider)</p>
<p>(2) &#8216;Mosaic&#8217; it&#8230; down-sample it into a bitmap data&#8230; this can either be done by (a) using a single bitmap data as a single buffer to capture the video into, scaling to fit the buffer during capture or (b) using 2 bitmap datas as a double buffer where the initial capture is unscaled, then is copied to a second bitmap (scaling prior to or during this second step).</p>
<p>(2a) Duplicate the video into a bitmap data whose size maps 1 pixel to each &#8216;region&#8217; being captured. For example a 320 x 240 video source with &#8216;10 rows&#8217; and &#8216;20 columns&#8217; would be captured into a bitmap that is 32 x 12 pixels. Use a matrix transform to scale with the draw() method to scale the source to the output resolution during capture. You can apply smoothing as desired (depending on what sort of interpolation you want).</p>
<p>(2b) Duplicate the video into a bitmap data whose size matches the source (using draw()). Then either:</p>
<p>(2b1) nest that bitmap (buffer#1) into a parent object, then draw() the parent object into a lower resolution bitmap (buffer#2). This should get around having to bother with a matrix transform of any sort during the draw() step since you are drawing from a parent&#8217;s display space (so the scaled-down child data is captured in its scaled-down form vs. its unscaled form).</p>
<p>(2b2) copyPixels() that bitmap (buffer#1) into a lower resolution bitmap (buffer#2), using a matrix transformation to reduce the resolution during the copyPixels() operation. You can also decide whether you want to selectively mess with channels in this step.</p>
<p>(3) Once you essentially have a low-resolution bitmap of the original video (where flash has done the interpolation for you) you can then quickly traverse the low-resolution data to get a given sample regions average value (and in turn can look at that sample&#8217;s color as RGB, HSV or whatever else).</p>
<p>In this scenario instead of having an object for every slice you&#8217;d basically have a buffer (a bunch of pixel data where each pixel represents a sample region&#8217;s average value), and some utility methods for using the buffer&#8217;s data. You could still then allocate an object acting as a view for each sample - whereby the buffer is basically the model data provided to that view. You could just set an update() method on the view that gets passed the new buffer&#8217;s value when it is updated (so for each sample period you dispatch or notify the views that the buffer data has changed, passing them or referencing them their region&#8217;s pixel &#8216;value&#8217;).</p>
<p>Maybe I only took a fast look at your code - it looked quite good, and well-written. Where when you &#8217;sample&#8217; you are actually performing an average on each region by going through each pixel of the region (and keeping each pixel&#8217;s RGB in a sample set). This step you don&#8217;t need, since you can arrive at an average pretty efficiently just relying on flash to down-sample the region for you (and you can define from a few common interpolation methods &#8212; linear = no smoothing, bilinear = smoothing). Once you have the average you can easily compute HSV/brightness/etc. using external utility methods vs. methods on the object/data itself (the rgb2hsv, hex2rgb, etc. color space methods can certainly be static, and/or external to the samples themselves).</p>
<p>Another advantage to this hack is that you can use common Bitmap filters and transformations that flash applies (fast) to manipulate the downsampled buffer data (increase contrast, invert values, blur it, edge contrast it, etc.).</p>
<p>Hope you find this useful!&#8230;<br />
N</p>
]]></content:encoded>
	</item>
</channel>
</rss>
