<?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>Manuel&#039;s Coding Blog &#187; c++</title>
	<atom:link href="http://manuel.bit-fire.com/category/dev/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://manuel.bit-fire.com</link>
	<description></description>
	<lastBuildDate>Sun, 27 Jun 2010 12:35:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Edge-Preserving Decompositions for Multi-Scale Tone and Detail Manipulation</title>
		<link>http://manuel.bit-fire.com/2009/03/21/edge-preserving-decompositions-for-multi-scale-tone-and-detail-manipulation/</link>
		<comments>http://manuel.bit-fire.com/2009/03/21/edge-preserving-decompositions-for-multi-scale-tone-and-detail-manipulation/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 22:50:29 +0000</pubDate>
		<dc:creator>Manuel</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[photography]]></category>
		<category><![CDATA[computational]]></category>
		<category><![CDATA[edge]]></category>
		<category><![CDATA[Farbman]]></category>
		<category><![CDATA[Fattal]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[Lischinski]]></category>
		<category><![CDATA[multi]]></category>
		<category><![CDATA[preserving]]></category>
		<category><![CDATA[scale]]></category>
		<category><![CDATA[sharpen]]></category>
		<category><![CDATA[sharpening]]></category>
		<category><![CDATA[smoothing]]></category>
		<category><![CDATA[Szeliski]]></category>
		<category><![CDATA[wls]]></category>

		<guid isPermaLink="false">http://manuel.bit-fire.com/?p=199</guid>
		<description><![CDATA[&#8230;or more simply, sharpen on steroids. It was three weeks ago when my brother Alberto told me about a quite new paper entitled Edge-Preserving Decompositions for Multi-Scale Tone and Detail Manipulation [Lischinski et al. 2008]: in fact we had a talk or two about general photographic techniques some days before and, since i&#8217;m interested in]]></description>
			<content:encoded><![CDATA[<p>&#8230;or more simply, <em>sharpen on steroids</em>.<br />
It was three weeks ago when my brother <a href="http://pixnoize.com/">Alb</a><a href="http://flickr.com/apwizard">erto</a> told me about a quite new paper entitled <a href="http://www.cs.huji.ac.il/~danix/epd/epd.pdf">Edge-Preserving Decompositions for Multi-Scale Tone and Detail Manipulation</a> [Lischinski et al. 2008]: in fact we had a talk or two about general photographic techniques some days before and, since i&#8217;m interested in the computational side of the subject, i asked him to let me know more about it whenever he got the chance, and so he did.<br />
He was reading a <a href="http://www.bigano.com/index.php/en/consulting/40-davide-barranca/90-davide-barranca-notes-on-sharpening.html">Davide Barranca&#8217;s article</a> explaining the basics of image sharpening and exposing various different methods in order to achieve it, so that one can manage to construct his own sharpening strategy, depending on his needs: the aforementioned paper is being referred by the article due to the fact that the new technique demonstrates how it is possible to make use of a better edge-preserving operator called WLS (or <strong>w</strong>eighted <strong>l</strong>east <strong>s</strong>quares) that leads to <strong>better</strong> results with <strong>lot less artifacts</strong> and permitting detail manipulation at <strong>arbitrary scales</strong>: by looking at some sample images produced with it (and published on the <a href="http://www.cs.huji.ac.il/~danix/">Lischinski</a> project page <a href="http://www.cs.huji.ac.il/~danix/epd/">here</a>) i instantly grasped what my brother&#8217;s excitement was about and decided i needed to know more about it: i was so eager to dive into it to the point i didn&#8217;t even noticed there was an example movie right there to see more of it!</p>
<p>Anyhow, considering <em>computational photography</em> was a brand-new field to me, i&#8217;m rather satisfied with the results: the sharpen is polished and the gain in both detail and depth level are impressive, while trying to intentionally cause artifacts is somewhat difficult, in the sense one have to boost detail frequencies to rather extreme values in order to cause artifacts and chromatic aberrations: in fact, considering the way actual tools currently work, i wonder why WLS-based strategies have still to take the lead in well-known commercial applications.</p>
<p>Unfortunately, as you may already know, i don&#8217;t have much free time to dedicate to most of the things i&#8217;m interested in, so this post is sort of an introduction while the rest will follows: it could take a while for me to write more about it, but i&#8217;ll try to share the time between coding and blogging, in the meantime i&#8217;m posting some results with it, but please, don&#8217;t laugh at the GUI too badly, its still all of an experimental thing and it&#8217;s just.. well.. usable ;-P<br />
Note that the videos here don&#8217;t give justice to the real results due to the compression going on with both the Xvid codec and YouTube, so look at the HD version if you can.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_gv6Xw3hQgeQ&amp;hl=en&amp;fs=1_1801708059"
			class="flashmovie"
			width="480"
			height="221">
	<param name="movie" value="http://www.youtube.com/v/gv6Xw3hQgeQ&amp;hl=en&amp;fs=1" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.youtube.com/v/gv6Xw3hQgeQ&amp;hl=en&amp;fs=1"
			name="fm_gv6Xw3hQgeQ&amp;hl=en&amp;fs=1_1801708059"
			width="480"
			height="221">
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The following video try to demonstrate some more detail exaggeration:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_jsjtRfEQgac&amp;hl=en&amp;fs=1_755546386"
			class="flashmovie"
			width="480"
			height="221">
	<param name="movie" value="http://www.youtube.com/v/jsjtRfEQgac&amp;hl=en&amp;fs=1" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.youtube.com/v/jsjtRfEQgac&amp;hl=en&amp;fs=1"
			name="fm_jsjtRfEQgac&amp;hl=en&amp;fs=1_755546386"
			width="480"
			height="221">
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://manuel.bit-fire.com/2009/03/21/edge-preserving-decompositions-for-multi-scale-tone-and-detail-manipulation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Compiz-like wobbling windows in AS3</title>
		<link>http://manuel.bit-fire.com/2008/09/04/compiz-like-wobbling-windows-in-as3/</link>
		<comments>http://manuel.bit-fire.com/2008/09/04/compiz-like-wobbling-windows-in-as3/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 19:01:09 +0000</pubDate>
		<dc:creator>Manuel</dc:creator>
				<category><![CDATA[as3]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[hydra]]></category>
		<category><![CDATA[compiz]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[wobble]]></category>
		<category><![CDATA[wobbling]]></category>

		<guid isPermaLink="false">http://manuel.bit-fire.com/?p=128</guid>
		<description><![CDATA[This code was intended to be released back in October last year, but i never managed to do it since it needed some refactoring, some changes and had to be quite decent to present: then in November i got the chance to work with some very talented guys over at Jooce, in Paris, so i]]></description>
			<content:encoded><![CDATA[<p>This code was intended to be released back in October last year, but i never managed to do it since it needed some refactoring, some changes and had to be quite decent to present: then in November i got the chance to work with some very talented guys over at <a title="Jooce! Try it, it's seriously cool!" href="http://jooce.com/">Jooce</a>, in Paris, so i never got back to write something about it.<br />
<em> Btw, if you never tried Jooce then give it a try, it really deserves it!</em><br />
<span id="more-128"></span><br />
While there, i used portions of this code to derive something from it and while working on that for some time i realized some key points for optimizations but i&#8217;m not going to share more details with you about that, since the NDA i agreed to sign doesn&#8217;t allow me to do that: i&#8217;ve to say this version is therefore unoptimized and proof-of-concept, especially for the real window drawings: in fact, i just did some cleanup before packaging it, but since i don&#8217;t plan to put some time on it sooner, better i publish it as-is, or it will lie on my disk for the next few months for sure.</p>
<p>The idea was to build the foundation for a fancy, compositing-based windowing system: beside the actual implementation that&#8217;s basically just <em>wobbling</em> the current target, i&#8217;m sure you&#8217;ll be able to come up with other effects as well, but that&#8217;s not the real point.<br />
Setting aside the concrete animator implementation that would be better to be used as a base to derive some more abstract definitions from it, the architecture is quite open to new approaches and ideas, especially for the ultra-simple opengl-like interface i chosen for the rasterizer that let&#8217;s you prototype things quite fast:</p>
<pre>
<pre class="brush: cpp;">
package rasterizer
{
	import flash.display.Sprite;
	import flash.display.BitmapData;
	import rasterizer.data.*;

	/**
	 * OpenGL-like interface for a generic rasterizer.
	 * The triangle is the only supported polygon right now
	 *
	 * More desc for me..
	 */
	public interface IRasterizer
	{
		function glTexture( tex: BitmapData, forceRecreate: Boolean = false, smooth: Boolean = false ): void;
		function glSetTarget( aTarget: Sprite ): void;

		function glBegin( rasterMode: int ): void;
		function glEnd(): void;

		function glPresent( aTarget: Sprite = null ): void;
	}

	/**
	 * OpenGL-like interface for a generic 2D rasterizer.
	 * The triangle is the only supported polygon right now
	 *
	 * More desc for me..
	 */
	public interface IRasterizer2D extends IRasterizer
	{
		function glVertex( vertex: Vertex2, uv: Vertex2 ): void;
	}

	/**
	 * OpenGL-like interface for a generic 3D rasterizer.
	 * The triangle is the only supported polygon right now
	 *
	 * More desc for me..
	 */
	public interface IRasterizer3D extends IRasterizer
	{
		function glVertex( vertex: Vertex3, uv: Vertex2 ): void;
	}
}
</pre>
</pre>
<p>Portions of the actual wobble animator took inspiration from the previous <a href="http://manuel.bit-fire.com/2007/08/10/the-magic-carpet/">Magic Carpet</a> demo and some stuff i found on the net: if you come up with some other effects let me know, i&#8217;ll be happy to link back to them!<br />
Here you can play with a basic demo i setup to try it out or get the <a title="AS3 Wobbling windows demo" href="http://manuel.bit-fire.com/code/wobble_webdemo.zip">source code</a> to do your own experiments:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_wobble_demo_1441027946"
			class="flashmovie"
			width="100%"
			height="480">
	<param name="movie" value="http://manuel.bit-fire.com/code/wobble_demo.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://manuel.bit-fire.com/code/wobble_demo.swf"
			name="fm_wobble_demo_1441027946"
			width="100%"
			height="480">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://manuel.bit-fire.com/2008/09/04/compiz-like-wobbling-windows-in-as3/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Fixed point math in pure CPP</title>
		<link>http://manuel.bit-fire.com/2007/10/31/fixed-point-math-in-pure-cpp/</link>
		<comments>http://manuel.bit-fire.com/2007/10/31/fixed-point-math-in-pure-cpp/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 20:35:15 +0000</pubDate>
		<dc:creator>Manuel</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[fixed]]></category>
		<category><![CDATA[point.math]]></category>

		<guid isPermaLink="false">http://manuel.bit-fire.com/?p=78</guid>
		<description><![CDATA[NOTE This post has been previously published on 2007/Oct/31: due to my move to another server i&#8217;m now in the process to manually recover the comments for this article. Fixed! Some time ago i was asked to publish my implementation of fixed-point math, mainly regarding embedded architectures where IEEE floating point computations have really bad]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: line-through;"><em><strong>NOTE</strong><br />
This post has been previously published on 2007/Oct/31: due to my move to another server i&#8217;m now in the process to manually recover the comments for this article.</em></span><em> Fixed!<br />
</em></p>
<p>Some time ago i was asked to publish my implementation of fixed-point math, mainly regarding embedded architectures where IEEE floating point computations have really bad performances. What i want to give you here is a pure-c++, template-based implementation of a fixed-point datatype: this thing is more of a test in order to see how much an object-oriented implementation can perform, being in contrast to a more <a href="http://members.aol.com/form1/fixed.htm">traditional implementation</a>. As expected, operator overloading and temporary object creation overhead are the main issues with a full-oo implementation as this one, anyway, its a damn nice way to exercise yourself in writing c++ policy-based templated code ;)</p>
<p><span id="more-78"></span><br />
Big thank you goes to <a href="http://www.guntheroth.com/">Kurt</a> for having a great discussion with me on c++, math and for recommending me the most wonderful book on computer arithmetic as <a href="http://www.amazon.com/Hackers-Delight-Henry-Warren-Jr/dp/0201914654">Hacker&#8217;s Delight</a> delivers it in spades!<br />
Back to the fp stuff: usage of this code in testing environments is advised, since it could contain rounding errors and sometimes explicit casts are needed to get it to work correctly; as i said, this was some sort of test, i abandoned the O-O idea when i ack the performances&#8217; gap between OO vs. traditional implementation was remarkable (at least on embedded devices).<br />
Before showing some usage guidelines, i should say that using this datatype on a desktop machine hasn&#8217;t much sense: nowadays floating-point math is faster than the integer&#8217;s one!<br />
The class itself predefines a 24.8 and a 16.16:</p>
<pre class="brush: cpp;">
typedef AquaFixed&lt; 8, LowPrecision,  LowPrecision&gt; fixed8_t;
typedef AquaFixed&lt;16, HighPrecision, HighPrecision&gt; fixed16_t;
</pre>
<p>An usage example could be a generic, datatype-unaware Matrix implementation as this one:</p>
<pre class="brush: cpp;">
template&lt;class Number&gt;
class matrix {
private:
Number m[4][4];
public:
matrix();

// matrix indexing
inline Number&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp; operator()(const int,const int);

// matrix operations
matrix&lt;Number&gt; operator*(const matrix&lt;Number&gt;);
matrix&lt;Number&gt; operator/(const matrix&lt;Number&gt;);
};
</pre>
<p>Doing it this way, you should be able to declare a Matrix as here and perform your own tests:</p>
<pre class="brush: cpp;">
matrix&lt;float_t&gt; float_matrix;
matrix&lt;fixed16_t&gt; fixed_matrix;
</pre>
<p><em><strong>NOTE! </strong>The AquaFixed class comes out straight from my framework, so you&#8217;ll have to define basic datatypes such as <strong>int32_t</strong>/<strong>int64_t</strong> for yourself, but that shouldn&#8217;t be a problem.</em></p>
<p>Get the code <a href="http://manuel.bit-fire.com/code/aquafixed.h">here</a> and let me know of your tests!</p>
]]></content:encoded>
			<wfw:commentRss>http://manuel.bit-fire.com/2007/10/31/fixed-point-math-in-pure-cpp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
