# Saturday, 27 March 2010

So I decided to make a trip down to Putrajaya during said fiesta, mainly because I wanted to try and take some pics of the fireworks. Boy was there a LOT of people when we got there.

DSC06313

A LOT of people.

DSC06320

Seems like they were all crowding around on the path of the marching band.

DSC06331

The traders around were selling LED decorations, and also.. umbrellas since it looked like the sky was going to open up.

DSC06333

But likely it didn't actually rain... phew. And the most interesting thing I saw during the event was a pair of blimps. But as you'll see in the video below. The way they moved around I'm pretty sure they're remote controlled camera blimps.

As the time for the fireworks drew near, I could see people setting up their tripods and getting their cameras ready for their shots. I didn't bring a tripod as it'd be hard for me to setup and move around with WZ around. And I was there to test something else anyway. The Sony CX-150 I newly bought that day.

The launch started BEFORE I could set the scene mode to fireworks display, if I did, I think the autofocus would do less hunting around, and also exposure would be controlled to catch more of the fireworks color. But the results were still not too bad lar.

The funny situation was AFTER the fireworks display, everyone left AT THE SAME TIME! So the traffic situation was like everyone in Putrajaya deciding to leave at the same time. Very very chaotic.


Saturday, 27 March 2010 16:40:34 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [0]  | 
# Friday, 26 March 2010

Maybe it wasn't such a good idea leaving all these Nerf guns around the house.


Friday, 26 March 2010 23:04:53 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [0]  | 
# Wednesday, 24 March 2010

As I posted before I was looking for a bicubic resize algorithm for images to be used in Silverlight. I thought I ported the code properly from C# to VB but then yesterday when I was testing the code some more, I realized that there was a weird pattern of noise present in the picture. It looked like a square grid of sorts being overlaid onto the image. My experience told me that, that's because something screwed up when interpolating the pixel values (duh!) I didn't notice it previously because my previous test images didn't cause it to show up.

So what was I left to do? I had to port over the C# version to a lib on it's own then.

Bicubic Interpolation
/// <summary>
/// Bicubic resize algorithm suitable for use in Silverlight
/// </summary>
/// <param name="src"></param>
/// <param name="dest"></param>
/// <remarks>Original Source For This Function - http://www.codeproject.com/KB/recipes/aforge.aspx</remarks>
public static void resizeBicubic(System.Windows.Media.Imaging.WriteableBitmap src, WriteableBitmap dest)
{
    int height = src.PixelHeight;
    int width = src.PixelWidth;

    int newHeight = dest.PixelHeight;
    int newWidth = dest.PixelWidth;

    double xFactor = (double)width / newWidth;
    double yFactor = (double)height / newHeight;

    // coordinates of source points and cooefficiens
    double ox, oy, dx, dy, k1, k2;
    int ox1, oy1, ox2, oy2;
    // destination pixel values
    double r, g, b;
    // width and height decreased by 1
    int ymax = height - 1;
    int xmax = width - 1;

    int p;
    // RGB
    for (int y = 0; y < newHeight; y++)
    {
        // Y coordinates
        oy = (double)y * yFactor - 0.5f;
        oy1 = (int)oy;
        dy = oy - (double)oy1;

        for (int x = 0; x < newWidth; x++)
        {
            // X coordinates
            ox = (double)x * xFactor - 0.5f;
            ox1 = (int)ox;
            dx = ox - (double)ox1;

            // initial pixel value
            r = g = b = 0;

            for (int n = -1; n < 3; n++)
            {
                // get Y cooefficient
                k1 = BiCubicKernel(dy - (double)n);

                oy2 = oy1 + n;
                if (oy2 < 0)
                    oy2 = 0;
                if (oy2 > ymax)
                    oy2 = ymax;

                for (int m = -1; m < 3; m++)
                {
                    // get X cooefficient
                    k2 = k1 * BiCubicKernel((double)m - dx);

                    ox2 = ox1 + m;
                    if (ox2 < 0)
                        ox2 = 0;
                    if (ox2 > xmax)
                        ox2 = xmax;

                    // get pixel of original image
                   // p = src + oy2 * srcStride + ox2 * 3;
                    int srcPixel=src.Pixels[ox2+(width*oy2)];

                    r += k2 * ((srcPixel>>16) & 0xff);
                    g += k2 * ((srcPixel >>8) & 0xff);
                    b += k2 * (srcPixel & 0xff);
                }
            }

            
            dest.Pixels[x+(newWidth*y)]=(int)(0xff000000 | ((byte)r<<16) | ((byte)g<<8) |(byte) b);

        }
       
    }
}

public static double BiCubicKernel(double x)
{
    if (x > 2.0)
        return 0.0;

    double a, b, c, d;
    double xm1 = x - 1.0;
    double xp1 = x + 1.0;
    double xp2 = x + 2.0;

    a = (xp2 <= 0.0) ? 0.0 : xp2 * xp2 * xp2;
    b = (xp1 <= 0.0) ? 0.0 : xp1 * xp1 * xp1;
    c = (x <= 0.0) ? 0.0 : x * x * x;
    d = (xm1 <= 0.0) ? 0.0 : xm1 * xm1 * xm1;

    return (0.16666666666666666667 * (a - (4.0 * b) + (6.0 * c) - (4.0 * d)));
}

Pretty much a direct port of the original code since it was in C# already previously, just changed the way pixels are read and set. Same caveat applies as the previous code, no alpha premultiplication done yet.

The C# code didn't produce the weird grid like overlay pattern. So... what happened? Well my guess would have to be that I haven't properly ported the code to VB, and somewhere there's a fractional number being cast to a whole number causing some problems.

I'll have to be more careful when porting code that involves fractions in the future then.


Wednesday, 24 March 2010 10:08:14 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [0]  | 
# Monday, 22 March 2010

Additional 32GB storage, an extended battery that's HALF THE SIZE OF THE CAMERA, and a Gorillapod to be used in a manner which I don't really want to.

DSC06389

Yup... I'm all ready for the big event.

And then there's this.

DSC06390

Who would even guess that there's a hacked up mobile internet router in this thing?


Monday, 22 March 2010 00:31:05 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [0]  | 
# Sunday, 21 March 2010

The Sony CX-150 has a few nifty tricks up it's sleeve. First of all if you buy a cable from Sony, you can directly plug a HARD DISK into the camera and back up the internal memory's contents to said hard disk. Great for transfers during a vacation. Not so great since I tried using my own Mini-B to A Female cable and it didn't work, means the connection is proprietary and I don't want to pay a few hundred bucks for a simple cable.

The other trick the CX-150 can do is while you're recording a video you can just push this little button here.

DSC06365

The photo button, and it'll capture a photo while you're recording video. I'd have love to say you can capture a USABLE photo but I can't... heck I'm not even gonna justify it's existence by putting a sample photo here. It's VERY VERY BAD. It's great for people who aren't sure how to capture a frame off recorded video but other than that.. nope.. not usable at all.

The one last trick the CX-150 can do is pretty nifty... it can take high speed shots for roughly 5 seconds. It basically tries to be one of those high speed cameras. Problem is... you have to switch to this mode, and it can only take 5 seconds, and after taking the 5 seconds, it needs some processing time to make the video. Not so good for spur of the moment clips.

Great if you can setup a scene properly!

After taking the above video, I realized that the Vulcan couldn't fire fast enough (I was happy with the effect of course!) So I gave my brother the Raider to shoot with, but he wasn't experience enough to fire it fast enough. So I offered to shoot him instead, but he declined. I stared at my wife holding the camera but she scowled at me. Where would I find someone who takes delight in being shot by rapid firing Nerf darts? Oh... right... (Warning... scenes of offspring abuse follows)

I was aiming below the head! So I know I won't hit him in the face. :P


Sunday, 21 March 2010 21:51:00 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [1]  |