
Having been sick for the whole week, my fellow boss (and nonetheless friend) Aurélien MSNed me yesterday something like:
“As you’re not doing much those days (I was at home) why don’t you try to port the Hq4x algorithm?” which I interpreted as “you dumb fuck!” he then sent me a couple of links…
Hereunder are the links he sent me:
- http://www.hiend3d.com/hq2x.html
- http://www.hiend3d.com/hq3x.html
- but mostly: http://scale2x.sourceforge.net/algorithm.html
so off I went reading, and tthe more I read, the less I could get the point & technique. Until the third link (scale2x) where the guy explains clearly what it’s all about plus gives an optimized C code to perform the operation which is very nice of him.
So this class is merely a porting of the Scale2x and scale3x algorithms. I don’t got much to say other than what is said in the articles of the guys above. Well just that a scale2x will double the output image size and a scale3x will … tripe it !
here’s a couple of examples, the class is so simple ( 2 static methods ) that it’s not even worth putting a demo *.fla. it goes like:
var bmpd:BitmapData = ScalerX.scale2x( originalBitmapData );
tricky huh?!
now what does it do ?
scale2X: processes the image on a connexity 4 model, smooth but can be better
scale3x: connexity 8 scheme, smoother than the 2x version yet the best is to double or combine them
now the ’scale4x’ treaterously called so is in fact a double scale2x ^^, it starts giving pretty nice results =)
the blond guy picture comes from HiEnd3d, “original agrandi” means “stretched original” and “la vieille ruse” means “the old trick”, the word ‘trick’ being feminine in french
scale9x: “harder, faster, better, stronger” a double scale3x, you can see that from a 25*25 pix pattern, you can get a very detailed map
now here’s the class:
As far as perspectives are concerned, I’d say there’s a lot to do with it; rescaling of course it’s the basic purpose of the algorithm. But also, while testing I couldn’t help thinking of Worms 1, the terrain generator (check scaler9x result). It could be a way to store minimaps and magnify them at runtime. as it’s quite a demanding process, using it on moving pictures is suicidal, yet on a very small animation, it could give nice results ;).
indeed that script loves indexed colors, previously I did a color reducer and recently optimized it by 30% using thresholds instead of palettemaps (soon to be blogged). I guess this could be a nice preprocessing for jpg pictures :)
now that was it, I think we should all be thanksful to Aurélien for having highlighted the script and taken me to port it to AS
subblue
on Dec 2nd, 2008
@ 3:08 pm:
Very neat – such a simple process that gives surprisingly good results.
HIDIHO! » Delaunay triangulation and Voronoï diagram
on Feb 24th, 2009
@ 8:38 pm:
[...] Didier. thanks to him I am no longer afraid of porting algorithms from other languages. check the scaleX article ; the port of the C algorithm was done after I did the Delaunay [...]
davide
on Aug 20th, 2009
@ 3:07 pm:
i’m programming a little game in Xna…how can i do this ?
very spectacular!!!
Pixel Bender port of Scale2x and Scale3x | Andy Li's Blog
on Sep 27th, 2009
@ 9:35 pm:
[...] I first saw the Scale2x, scale3x AS3 I am impressed. The algorithm is from scale2x sourceforge project and the as3 port is coded as a [...]
Andy Li
on Sep 28th, 2009
@ 8:28 am:
I get it running in Pixel Bender after seeing your work :)
http://blog.onthewings.net/2009/09/28/pixel-bender-port-of-scale2x-and-scale3x/
HIDIHO! » Blog Archive » activator inhibitor
on Nov 27th, 2009
@ 8:48 pm:
[...] activator inhibitor [...]