Archive for the ‘Flash’ Category

Spatial convolution and bokeh

Tuesday, January 17th, 2017

On my path to gaining proficiency in ecmascript6, I am exercising with a windows bitmap decoder, spatial convolution and bokeh effect filter.


Windows Bitmap decoder

This decoder is capable only of loading 24bpp uncompressed RGB image from your local drive at current.  The source code is based on a comprehensive version written in actionscript back in August 1, 2009.  The Windows 3.x Bitmap format (BMP) is defined by four sections below.  Please consider reference text below for detail.

  1. BITMAP File-Header
  2. Bitmap Info (Bitmap Info-header)
  3. Bitmap palette (if exists)
  4. BITMAP-Picture data

Spatial Convolution

Filters, blur, laplacian and sharpen have been implemented for testing.  For blur, a RECT function of 5×5 kernel is set for default and configurable.  For laplacian, it is an isotropic derivative filter for detecting high frequencies.  It has a 3×3 kernel [-1, -1, -1, -1, 8, -1, -1, -1, -1]. For sharpening, the high frequency result from a laplacian filter is added to an identity.  Please consider reference text below for detail and mathematics.


kernel graph

At the center of the image, an identity kernel is applied.  As the convolution is applied on pixels away from center, a larger RECT function is utilized.  Illustrated in the above kernel graph on the right, black spot marks the identity kernel and lighter intensity mark larger kernels.  Source code is available on Github.

Future work

Currently working on code quality which includes ES6 modules to divide decoder from filter.  Also, large format camera, scheimpflug principle, is being implemented to simulate a plane shift image effect.


  1. Digital Image Processing by Rafael C. Gonzalez, Richard E. Woods, Addison Wesley Publishing, 1992.  ISBN 0-201-50803-6
  2. The file formats handbook by Gunter Born, International Thomson computer press, 1995.  ISBN 1-850-32128-0

MachWaves – iOS

Tuesday, January 3rd, 2017

This is a retro of MachWave mobile application written on June 26th, 2014.  The Objective-C, source code for iOS is now on Github.  However, the application is no longer available on iTune for download.  This camera application has a custom view that supports 2 lines being drawn via touch-points (below).screen-shot-2017-01-03-at-10-30-30-am

When there are four touch points, two lines are drawn.  Tt calculates the mach number base on the touch point coordinates and intersecting angle. The values are posted at the top of the photo (below).


Link for detail and references.



Thursday, June 23rd, 2016

I am implementing the ascii decoder for an earlier exercise, STL binary decoder, 26Sept2012.  The STL ascii file specification I am using is available on wiki.  A few C# 6.0 feature enhancements have been added (null propagation, string interpolation, expression-bodied members).  Files tested are available in the assets directory under the project solution.  Next step would be to add color decoding, logging and test it more thoroughly with defective STL files.  Decoder needs to be more flexible, currently normal needs to be in the first line.

Screen Shot 2016-06-23 at 11.21.25 AM

Google Cardboard

Sunday, May 8th, 2016

Few years late on this technology but I was still giddy assembling the Google Cardboard.  To my surprise, the price of this cardboard viewer varied from $5.00 – $20.00.  Then there were many other fancier headsets in the price of hundreds.


I bought the generic brand of cardboard viewer.  It arrived with two magnets, lens and perforated lines, minus the 2D barcode.  There was very little assembly required.


No instruction was necessary although I found a rubber band helpful to keep everything together.  I suppose a few stables would work as well but just in case I need to take it apart for storage.20160508_130639

Next came the Cardboard demo software on Google Play.  iPhone version was available as well.


Before attempting any exciting development project(s), my daughter and I have already found hours of entertainment with the various demos provided.  My favorite was the northern lights under the lighthouse.  It reminded me of SplitRock lighthouse, near Duluth.


Anyone has recommendation on purchasing a ‘real’ viewer ?  For development, is it better with iOS vs Android ?  Saw amazing 3D painting tools with Vocativ on facebook, so cool !!

Reading Google Cardboard and SDK documentation.



Android-Flex accelerometer sketch 2

Tuesday, September 4th, 2012

Made some minor enhancement on the year old android application, XLOsketch.  Like the first implementation, accelerometer is required.

Screen Shot 2012-09-04 at 6.56.15 PM

Correction from version 1.0, the drawing path appropriately draws downward as you would expect with gravity.  The steeper the angle, the faster it travels.

IMAG0135Also, there is a pause-continue option.  When paused, user has the control to change the stroke thickness.


Project Source code is available on GoogleSVN.  Or download from Android marketplace (Google play).

Screen Shot 2012-09-04 at 3.35.25 PM

Focus Stacking

Sunday, October 23rd, 2011

A common problem in Scanning Electronic Microscopy, photo micrography and macrography is shallow depth of field.  To compensate, a number of solutions, such as scanning-light and focus stacking have been developed.

Here is my experiment with focus stacking in actionscript.  It is written to take N number of input images and assemble a destination image by selecting the sharpest pixels from the collection.  A larger convolution kernel yield better result at the cost of performance.  Optimization maybe achieved with pixelbender filters.


Skeleton – thinning

Monday, October 17th, 2011

SkeletonThanks to a number of inputs from the Image processing group on LinkedIn, I am exploring a number of skeletonization techniques.  For my first implementation of the thinning algorithm, I have implemented a multi-iteration method defined in Digital Image processing by Gonzales and Woods-1st Edition pg 492-493.

With actionscript alone, this is a pretty slow process, taking up 3200 ms on my Lenovo T61.

Having reported the poor performance, I believe it is possible for me to rewrite this with a collection of pixelbender filters.  To my surprise, it is 3x slower with pixelbender (try out “thin pixelbender”).

To exercise this demo, simply select combo box selection, “thining”.  Draw any closed shape pattern of your liking and select “Apply”.

Skeleton, erosion

Wednesday, September 28th, 2011

distanceMapDilation and erosion are somewhat easier in vector graphics.  For most instances, the solution is accomplished by moving the anchor point along the tangent.  But how would you accomplish the same task with raster?  One solution described by Gonzalez in Digital Image process is skeleton-erosion by distance map technique.

Optimization by a quad-tree might be helpful in my distance calculation.  If you are playing with this, be sure to create a close loop object.  Next, to consider thinning and Voronoi diagram.

AM / FM Dither

Tuesday, September 20th, 2011

ditherTwo common dithering categories are presented, frequency modulation (FM) and amplitude modulation (AM).

From the link below is an exercise on Floyd Steinberg error diffusion, order dithering and super cell halftone dither.

I should point out that Ralph Hawert has a nice demo on error diffusion supporting contone (continuous-tone) error diffusion.  I am currently working on replacing the AM screens with Pixelbender filters.

Apparently there is a bug with pixelbender2 mod() and math operations.  Pixelbender 1 works fine.  Pass in = 2.0 or 1.0 for the correction.

StageWebView – MNSWF Camp 2011 Presentation app.

Saturday, April 16th, 2011

For MNSWF camp 2011, I was looking for a mechanism that allows a mixture of input, slides and html pages, flex apps for demo.  As it turned out, Adobe’s new Flex class for mobile, StageWebView did the job well.  For a demo, try installing this AIR app for Video2Panorama slide presentation, StageWebViewTest.air.  You will need  flashplayer 10.2.

Here is the source code, (build with Flash Builder 4.5 Beta using Hero SDK).

Here is the same project for mobile.  I am using Samsung Galaxy Tab. and .apk (build with Flash Builder 4.5 Beta with 4.5 SDK).

About the application, I started with the idea of PechaKucha 20×20.  In a 30 minutes presentation, I stretched each slide display time to 40 seconds.  Also, I added keyboard controls to move forward (->), previous(<-) or pause (down arrow).