UnitZeroOne

Avatar

A blog written by Ralph Hauwert, freelance front-end developer, specialized in rich internet applications, games and visualisation.

OpenSource Image Dithering for AS3. (demo+source).

Intro

As promised in my previous post, here’s a small opensource project from my side. It’s tiny, really, but I hadn’t seen an ActionScript implementation of any form of Image dithering before.

Dithering….what ?

Just a brief explanation what dithering in this context means. From wikipedia :

Dither is an intentionally applied form of noise, used to randomize quantization error, thereby preventing large-scale patterns such as contouring that are more objectionable than uncorrelated noise.”

Words to take note of in that sentence are quantization, and “intentionally applied form of noise”. In our case quantization is the removal or swapping of colors. The form of noise applied differs over the several implementations and in so called “ordered dithering” it’s hardly noise, rather a carefully chosen threshold matrix.

Dithering, why ?

Dithering imagery has been around for some time. Put a close eye to any black and white printed newspaper’s pictures and you’ll see the effect.

It’s basically been around a lot longer then I have in my 28 years of life…that’s for sure. I first learned terms like “ordered dithering” and “Floyd-Steinberg Error Diffusion” in my young and early days on the Amiga hardware. See, in those days computer hardware wasn’t capable of displaying the huge arrays of colours like now-a-days. Since you then had few colours to spare (a typical amiga workbench ran at 16 to 128 colours or so), you needed to be creative to get yourself a nicely pimped desktop image, whilst still sparing colours for your icons.

A better example of a dithering implementation for our industry is probably that checkbox when you want to save for web in Photoshop, using GIF. Or when you print something on a pure black and white printer.

Conclusion; dithering is normally used to create the illusion of tones on a device which is otherwise not capable of displaying it. So why port this to our ARGB/32Bit enabled Flash Player ? Part of the reason why I worked on this is because I just like the aesthetic of the effect. It just brings back wonderful memories of pimping my Amiga desktop.

Dithering in AS3

So, the algorithms for dithering are really quite simple. I was playing around with hydra Pixel Bender and had some ideas on converting some old algorithms to have them run in realtime. Then I thought I could make this run in realtime on Flash 9. So, first I did a version of the Algo in pure AS3. I played around with converting it to something fast enough to run at at least 20 frames per second on an average machine…and painfully failed. The remains are the AS3 version (hydra Pixel Bender version still in progress)….and I decided to clean that up a bit, and have it released as an OS project for anyone to use.

Currently it only contains so-called error-diffusion based ditherers. They make the most sense anyway, since the ordered ditherers really have nasty visual sideeffects, like Bayer’s crosshatches. Check the variants out in this little demo application using the class.

The Demo : try and use “No Dithering” first to see the effects of regular palette conversion.

The Source

Usage :

ImageDithering.dither(bitmapData, type, levels, grayscale);

Where :

BitmapData is the image to be manipulated.

Type is the form of dithering, currently supported :

  1. ImageDitheringType.FLOYD_STEINBERG
  2. ImageDitheringType.FALSE_FLOYD_STEINBERG
  3. ImageDitheringType.STUCK
  4. ImageDitheringType.NO_DITHER

Levels is the amount of colour levels to quantize to per channel.

Grayscale is a boolean indicating whether to convert the image to grayscale before the process is ran.

Right click and viewsource on the example to see how it’s implemented in Flex.

Quick update : Mario Klingemann, working on Aviary’s Peacock did a quick test with it. My effort had some use anyway!

Digg, StumbleUpon, Slash and others: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • DZone
  • StumbleUpon
  • Slashdot
  • Technorati
  • blogmarks
  • BlogMemes
  • Ma.gnolia

Mind-bending puppets, FlashPlayer 10, conferences, the past and the future…

“Pixel Bender” ? Really ?

[Fill in my excuse for not posting in such a long time]. There’s so much to tell, hence the weird title. Let’s start of with todays news; Adobe renames Hydra to Pixel Bender. They actually did it….now…it might be me…but wasn’t Hydra a way cooler name then “Pixel Bender” ? At least we’ll be able to make Bender references all the time now…adding to nerd-status. The cool thing ? Bender’s brain is a MOS6502 … the same cpu which for instance, also powered the best machine of all times.

Puppet Interview

So, moving on from that news. Over the last months I’ve done several interviews. I was reluctant to post them, but come to think of it, why ? You are reading this page so you’re at least interested in what I have to say. The best interview as of yet was with Gideon, one of the worlds best designers. In all honesty, “jet-lagged” as I was, I wasn’t at my best, so these interviews might entertain you more; Joshua Davis, Hugh Elliot, Moock&Gmunk, Seb-Lee Delisle.

FITC & rePhlex and Flash Player 10

Of course, all of this was recorded at the FITC Toronto 2008 conference. First off all, thanks to the FITC Organisation…you guys did an awesome job. The conference had an excellent vibe … (except for that annoying drunk dude at the front door on Tuesday…you know who you are), and I had a great time hanging with you all. I did a sold-out workshop on day 1, day 2 a panel, with Adobe’s Justin, Richard, Lee, Joa from Hobnox and Mr. Paperworld: Trevor.

On day 3 I did my session…I was shocked to find the room literally packed with people….and was somewhat nervous throughout some moments in my session, but as it seems by the feedback, people really enjoyed it. The reviews I found in my incoming links are at least very positive.During this session I also got to talk about rePhlex again, my new toy project. rePhlex is meant to be a lightweight, realtime image processing and syncing/eventing library for site/example and demo purposes. It’s been overgoing some heavy changes and refactoring…you’ll all just have to wait a bit more.

Another thing I really enjoyed doing in my session was that I was allowed to show some hydra Pixel Bender running inside Flash Player 10. Yes….you missed a sneak of Flash Player 10’s awesome power. ;-)

On day 4 of the conference I had a taped conversation with Keith Peters, which, next to the obligatory joke he made at my cost, to get back at me for sleeping a bit to long, we both hoped won’t bore you too much…you put to actionscript / math / graphic nerds on a couch…what do you think happens ?

I saw some sessions myself, but was really unlucky with my taste vs the schedule. Things I can quickly remember seeing; Seb-Lee Delisle, Mario Klingemann, Keith Peters, Robert Hodgin, Erik Natzke and many others. Robert’s session (the last of the conference) absolutely blew me away. And I do love Radiohead!

So, that would wrap up FITC Toronto (and Amsterdam too).

Upcoming Conferences

I’m looking forward to speak at this months Multimania. In June there’s going to be FITC Chicago…later on this year many more, amongst which for instance; Singularity 08. I’m really unlucky to have to miss out on this years FlashBelt…..hope you all have a good time there anyway.

Goodbye Earthmine ! Hello new works ?

As some of you, attending one of my sessions or workshops earlier this year might know, most of my commercially available time went to the Earthmine project. That work ended for me last week and after working on one project for such an extended period of time (7 months+) and some rest, I’m now really looking forward too and open for new jobs and work..I’m not sure what I’ll do yet and am still contemplating on what I really want to do as the “next” thing. In the mean time I’ll be working on smaller freelance jobs. And if you have something you’d like me to work on….ping me.

Playing with Hydra and image algorithms

Another post coming up today will explain some more. With my work on rePhlex and Hydra, I’m having a blast doing image manipulation algorithms….one of my experiments was image dithering and half-toning…with as a result a new open source project. More on that in my next post…which will appear on the all new and revamped AXNA / Adobe Feeds! Welcome back !

Digg, StumbleUpon, Slash and others: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • DZone
  • StumbleUpon
  • Slashdot
  • Technorati
  • blogmarks
  • BlogMemes
  • Ma.gnolia

Papervision3D + Water Simulation = Waterballs

Waterball 2

You always have projects lying around that are to be finished…but probably never have the time for…

Today Exey Panteleev posted some creative use of Papervision3D and the Shaders in 2.0. Accompanying to his post he asked if it would be possible to run water simulation with Papervision3D….

Actually, yes…
Water Ball Experiment 1 Water Ball 2(cpu burner alert!)

As one of those things I never finished and probably don’t have time to finish within the next month or so, I have two examples of Papervision3D running interactive water on top of a sphere.

Disclaimer : these things are hacked together experiments from a couple of months ago…as a result performance isn’t to good. I’m sure that given some time they can run smooth, without burning your cpu to the ground. Hope you enjoy anyway ;-)

Digg, StumbleUpon, Slash and others: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • DZone
  • StumbleUpon
  • Slashdot
  • Technorati
  • blogmarks
  • BlogMemes
  • Ma.gnolia

Next,

Search

Projects & Work

A selection of current work

Advertising