top bar


Revision as of 10:55, 22 March 2010 by Karlh (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

AutoFocus Manual

Pakpoom (Tom) Substoontorn provided the following explanation of the various settings in the autofocus dialog:


Auto Focus Channel is the channel with which the autofocussing will be carried out. Currently, the plugin uses the configuration preset group 'Channels', and you will need to type in the exact name of the channel to be used.

StepNumber is the number of planes used in focusing above and below the current plane. For instance, if my current zdistance at the beginning of autofocus routine is 11um and I set the parameter as the following

         -1st stepsize: 1 micron 
         -1st stepNumber: 2 step
         -2nd stepsize: 0.3 micron
         -2nd stepNumber: 2 step

The program will take the image at 9,10, 11, 12, 13 um....Then, it finds the sharpest image. Suppose the sharpest image is taken at 12 um. Then, it take the image at 11.4, 11.7. 12, 12.3, 12.6 um. Again, it finds the sharpest of these image. Suppose the sharpest one is at 11.7 um. Then, the program set the microscope to 11.7 um as its best focus.

'shapness' of an image is computed by

         -applying 3x3 median filter to the image to remove noise
         -convolute image with a filter [-2 -1 0; -1 0 1; 0 1 2 ]
         -sum the square of each entry in the convoluted image.

Empirically, this 'sharpness value' is correspond to the sharpness I see by eyes (for ecoli). In other words, for the same image field, the sharpest image I see by eyes is the image with the maximum sharpness value. The plot of 'sharpness' against zdistance is a single bell-shape curve. i.e., the futher zdistance from the best focus zdistance, the lower 'sharpness value' is.

I was planning to use while loop to repeat the search for the focus (rather than just two rounds: coarse and fine). However, so far, these coarse-fine search seem to be enough.

Crop ratio

 -- tell the program what fraction of image will be used for computing sharpness.

Suppose my image is 1000x600 pixel and my crop ratio is 0.5, the program will use only the middle part of the image, size 500x300, to compute sharpness and will discard the rest. In the past, I sometime use small crop ratio (like 0.3) to make the program run faster (as it applies median filter and convolute smaller matrix). However, right now I use median filter and convolute functions implemented in imageJ, median filter and convolution is so fast that the rate limiting step of the program is no longer matrix operation, but the time of taking each snapshot.

Threshold: This value tells the program when to give up the search. Because during the best focus search the program take one snapshot and compute its sharpness at a time (and given that the sharpness-zdistance plot is a single bell-shape), the program will give up once it finds the highest sharpness. The program stop taking snapshot when the current sharpness is less than (the best image so far) X (1-Threshold) Consider the following example, the program starts taking coarse image at 9 um-13um, threshold is 0.5 at 9 um sharpNess = 36

  10 um                       59
  11  um                      21--> the program stop coarse search here as 21< 59*0.5 

I'm not quite confident about this threshold trick. sometimes the single bell-shape is not perfect. I would recommend setting high Threshold for now.

© Micro-Manager : Vale Lab, UCSF 2006-2011 | All Rights Reserved | Contact