Archive for January, 2008

On Camera Flash Techniques

Found a very useful guide detailing how to shoot using on-camera flash. Don’t let that put you off though, the pictures taken looks really great. The guy’s a pro wedding photographer and a really good one too. 2 or 3 Speedlights would allow more room for creativity and better control of exposure, but I it’s hard to justify such a purchase. Not to mention having to carry so much equipment really takes the fun out of a hobby. Working with limited equipment seems to have always been more fun for me, much like problem solving given various limitations. Having gone through the guide (at freaking 2 am!), I’ve now understand better why the need to shoot almost exclusively in Manual mode, especially when it comes to the control of exposure (ultimately, your flash is used to ‘fix’ exposure).

By the way, if out of the blue your Speedlight suddenly refuses to do TTL-BL, even after cycling through various modes, check that your camera is set to matrix or center-weighted metering. Spot metering will disable TTL-BL. You’ll most probably want to use TTL-BL to properly expose the background of your subject. Some websites recommend going the easy way to expose background (via rear-sync or slow-sync flash) but I found playing around with shutter speed, ISO and aperture, in combination with TTL-BL is much more effective in getting consistent and correct exposure. You’ll also be able to eliminate blurriness due to slow shutter under certain conditions.

Rather than risk diluting the guide, I’ll just point you straight to it - planet neil - tangents » flash photography techniques. A must read for a flash user. The guide applies for both Canon and Nikon cameras.

OS (Optical Stabilization) on the Sigma 18-200mm

A few facts:

  1. It counters only camera shake. Subjects that are stationery can be steadied even at 1/3 second. Because shutter speed is low, if the subject moves, you will still get blurry images
  2. It takes roughly 1 second for OS to kick in after focusing (half-shutter). This does NOT mean shutter lag because you can still shoot before the OS kicks in, but this will essentially mean you would not benefit from OS. When it does take effect, you will notice that the image will be mostly steady in your view finder
  3. When OS is turned on, there’s a continuous revving sound coming from the lens. This is different from the click-clack sound from the HSM which comes on only when the lens is focusing
  4. OS will drain battery faster than if a non-OS lens is used. OS kicks in as long as there is light on your camera’s sensor. So to save battery, kill OS via the switch or turn off your camera in between long shoots.
  5. It does not seem to work well when a timer is used. My usual technique of using timed shots to remove camera shake due to pressing the shutter seems to make things worse than just hitting the shutter More tests revealed that OS is not affected by timer release.

Hope this clears up some of the misconceptions about optical stabilization. I am interested in experiences of VR/II of Nikkor and IS of Canon lenses so if you own one of these other lenses, do leave a comment.

New MyJUG Website

A new Confluence site for Malaysian Java Users Group is up. Hope this means more activity for the group from now on. The mailing list is pretty active by the way.

Sigma 18-200mm f3.5-6.3 and Nikkor 50mm f1.8

Decided to take get a few better lenses.

Nikkor 50mm f1.8
For low light and sharp portraits, I got myself a 50mm 1.8. And boy is this lens just great. Even in very dimly lit rooms, I can take sharp and bright pictures while keeping ISO at 400. The depth of field is shallow when the aperture is wide open but the photos that come out really blows me away. Can’t wait to test shooting on people. My test subjects so far have been stationary ones. Nothing much can be said about this lens except that it’s quite a bargain. One caveat though - it doesn’t auto-focus with a D40. So far, it is not a problem. But let’s reserve judgment till I’ve shot a human being. Bought a used one for RM 360, with a filter.

Sigma 18-200mm f3.5-6.3 OS
This will be my permanent lens from now on (anyone wants a D40 kit lens?). Having a zoom of 11.1x is really cool. At full zoom, the lens needs a lot of light - shutter speed can go pretty low. Luckily, Sigma has optical stabilization on this model, so I should be able to take clear pictures at 2-3 stops lower than usual. However, OS doesn’t help if the subject keeps moving - you’ll still get blurry shots if that happens due to the low shutter speed. At 18mm, the lens is decent enough to get sharp shots at less than ideal lighting. Overall I’m pretty satisfied with the lens, no doubt there are compromises made here and there to achieve its 18-200mm zoom, but it’s a great one-size-fits-all lens. It’s also much cheaper than the 18-200mm Nikkor. I’d love to get that but it’s just out of my budget for now. Bought mine brand new at RM 1750.

So I guess I’m pretty happy with my gear right now. Coupled with the SB600 I recently bought, I think I’m ready to shoot for real now. One thing though - with the SB600 and 18-200mm, the D40 weighs a ton!

Note: I got my 18-200mm from J-One of AmCorp Mall. I don’t know why but the shop seems real cozy, perhaps it’s the display of vintage cameras or the sheer number of lenses around or maybe it’s the wall of camera bags. Nah, actually, I think it’s because of Jason - the owner (guessing here). He’s the older chap which seems very knowledgeable in his trade - a rarity these days. Friendly and helpful too. Needless to say, I whole heartedly recommend this shop, even if you have to travel a bit further than usual, do it. I can’t really explain it but there’s this warmth to his shop :)

Speedlighting

Bit the bullet and now I’m RM 800 poorer. Got myself a Nikon Speedlight SB600. I’ve always found the built-in flash to be useless for anything except as a fill-flash during outdoor shots. Even then it can sometime cause the subject to be washed out. The problem is when I need to shoot in a poorly lit indoor and I can’t use the built-in flash. With the slow kit lens (f3.5-f5.6), it’s hopeless to shoot in such conditions (which is more frequent than you’d expect). With a SB600, lighting is now a trivial issue as I can bounce off almost anything. Bouncing is using your flash to light a nearby surface (usually wall or ceiling) to create a diffused, more natural light. I chose the SB600 over the SB400 due to the addition of bouncing sideways as well as some other flash functions.

What disappoints me most is that the Nikon D40 needs a SB800 to participate in Nikon’s wireless lighting. The D40 won’t function as a ‘commander’ with the SB600. With the D80 and above, all you need is a couple of SB600 and you got a pretty powerful setup for lighting. The SB800 costs almost as much as 2 SB600s by the way and I just couldn’t justify one. It’s great and all but I really don’t need the extra flash power, I just want the commander mode! By the way, the wireless lighting thingy is part of Nikon’s Creative Lighting System - see here for what that stands for.

Overall, I find that owning a D40 might not really save cost. It has the potential to incur extra cost compared to the more expensive bodies by forcing users to buy expensive gear - the SB800 is an example. Another potential wallet-splitting buy soon would be a fast prime lens. The sweet 50mm f1.8 doesn’t auto focus on the D40! Nevertheless, I’m getting one tomorrow and will make do with manual focusing.

Static Initializers in Java

Static initializers is simply a piece of code that performs initialization for a class. OK, that was a pretty useless explanation lol :)

Let’s try that again - they perform some sort of work (usually initialization) when a class is loaded by the class loader. That’s the best I can do, sorry! OK, the bigger question is of course, why would you need this? You need it when there’s a situation that warrants a very early initialization, say a class that absolutely under all circumstances *must* have itself initialized before ever accessed. Let me illustrate via an example.

Scenario
You need a code that caches small tables from frequently read tables. Do this in a singleton class. These tables are seldom changed and needs to be refreshed after some intervals.

Solution 1

public class Singleton {

    private static HashMap cache = null;

    private static Singleton instance = null;

    private static SomeDAO dao = null;

    public static void setDao(SomeDAO dao) {
        Singleton.dao = dao;
    }

    private Singleton() {

    }

    public static Singleton getInstance() {

        if (instance == null) { //danger!!!
            instance = new Singleton();
            Data data = dao.getAll(); //db read
            cache.put(data.getKey, data.getValue);
        }

        return instance;
    }

}

What’s the problem with Solution 1 then? Well, it could be trouble free provided:

  1. data retrieval from the DAO is very fast
  2. single threaded access

When you have a combination of slow data retrieval and multi-threaded reads, you have a potential issue. Think about it, if there is multi-threaded access, the check for null has the potential of returning different result for different threads. Thread 1 could be in the midst of reading from the DB when more threads access this class and decides cache is still null, and proceed to read from the database. Disaster.

Solution 2

public static synchonized Singleton getInstance() {

        if (instance == null) { // no more danger!
            instance = new Singleton();
            Data data = dao.getAll(); //db read
            cache.put(data.getKey, data.getValue);
        }

        return instance;
    }

Now what about solution 2? It certainly takes care of multi-threaded access, but it has another problem - a potential performance bottleneck. Not good when I’ve already decided I need fast multithreaded access to the cache. Let’s see solution 3 then:

Solution 3

public class Singleton {

    private static Map cache = new HashMap();

    private static Singleton instance = null;

    private static SomeDAO dao = new SomeDAO();

    //code updated - setter injection won’t work because
    //Spring would not have been initialized

    //public static void setDao(SomeDAO dao) {
    //    Singleton.dao = dao;
    //}

    private Singleton() {

    }

    //initialized before ever read
    static {

        if (instance == null) { 
            instance = new Singleton();
            Data data = dao.getAll(); 
            cache.put(data.getKey, data.getValue);
        }

     
    }

    public static Singleton getInstance() {
             return instance;
    }

}

How about that? Now you made sure the unreliable getInstance() method is not used for initialization and is not synchronized. Note that because the class is always initalized during class loading, some will argue that it is a waste of resource if the class is not immediately used, and I agree. Do static intialization only when

  1. the class is certain to be used
  2. very early initialization is needed