top bar

Difference between revisions of "SimpleAutofocus"

m (New page: == AutoFocus Manual == Pakpoom (Tom) Substoontorn provided the following explanation of the various settings in the autofocus dialog: Image:AutoFocusDialog.gif Auto Focus Channel is...)
 
(SimpleAutofocus Manual)
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== AutoFocus Manual ==
+
== SimpleAutofocus Manual ==
  
Pakpoom (Tom) Substoontorn provided the following explanation of the various settings in the autofocus dialog:
+
{{Note|The SimpleAutofocus device adapter is deprecated. Please use the modern [[Autofocus manual|autofocus]] interface instead.}}
  
[[Image:AutoFocusDialog.gif]]
+
The C++ SimpleAutofocus Device Adapter, written by Karl Hoover, is a higher-performance version of the image-based autofocus function. It builds on the search and sharpness measures in the Java image-based autofocus kindly provided by Pakpoom Subsoontorn & Hernan Garcia. It provides some additional conveniences, for example, the user can over-ride the current acquisition binning and exposure. Multiple search algorithms can be selected. Multiple sharpness metrics are computed.
  
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.
+
Refer to Pakpoom Subsoontorn's write-up for an explanation of the Threshold and Crop Ratio parameters, as those function exactly as described there.
  
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
+
[[Image:SimpleAutofocusPropertyBrowser.png]]
  
          -1st stepsize: 1 micron
+
Binning: If this value is not 0, Simple Autofocus will acquire images binned (down-sampled) per the specified setting.
          -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.
+
Channel: If this is not blank this is the channel with which the autofocussing will be carried outYou could conceivably wish to switch to, one acquisition channel whilst in the middle of acquiring another channel. If this is blank, the autofocus will use the current instrument settings.
  
'shapness' of an image is computed by
+
CoarseStepSize: In the BruteForce search method, this is the distance stepped in Z in the first pass search.
          -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).
+
CoarseSteps: In the BruteForce Search method, this is the number of steps taken above and also below the current position. Thus, your entire search range is specified to be [CurrentZ - CoarseStepSize*CoarseSteps, CurrentZ + CoarseStepSize*CoarseSteps] The total coarse steps in the BruteForce search is 2*CoarseSteps+1
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
+
FineStepSize: In the BruteForce method, the is the Z step size in the second pass
rounds: coarse and fine). However, so far, these coarse-fine search seem to be enough.
+
  
Crop ratio
+
FineSteps: In the BruteForce method, this is the number steps taken above and also the best focus position found in the first (coarse) pass.
  -- 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:
+
Exposure: If this value is not 0, SimpleAutofocus uses this exposure for image acquisition, it is 0, the current acquisition Exposure time is used.
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)
+
EnableAutoshutter: If this is 1, the shutter is closed between Autofocus image acquisitions, this setting is independent of the on-going acquisition sequence setting.
Consider the following example,
+
 
the program starts taking coarse image at 9 um-13um, threshold is 0.5
+
Mean: This displays the mean image value in the crop region.
at 9 um  sharpNess = 36
+
 
  10 um                      59
+
Re-acquire&EvaluateSharpness: Set this to 1 to trigger the adapter to acquire a fresh image and calculate the sharpness score at the current position and acquisition settings.
  11  um                      21--> the program stop coarse search here as 21< 59*0.5
+
 
   
+
SearchAlgorithm: Select the algorithm for finding the best sharpness measure. Thus far there are BruteForce and Brent. For BruteForce, use a two pass linear search with parameters described as above. For Brent, use Brent's derivative-less optimization algorithm on the same search range that BruteForce is configured to use, [CurrentZ - CoarseStepSize*CoarseSteps, CurrentZ + CoarseStepSize*CoarseSteps]
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.
+
 
 +
StandardDeviation/Mean: This is another popular measure of ImageSharpness which is much cheaper to calculate than the SharpnessScore. Usually SharpnessScore and StandardDeviation/Mean agree very well.
 +
 
 +
SharpnessScore: This is calculated per image-based autofocus described by Pakpoom Subsoontorn & Hernan Garcia, however, the image is first normalized by the mean. This greatly reduces effects of photo-bleaching on the focus score.
 +
 
 +
If debug log is ON, you can also see the dynamic range of the normalized image. This is also very strongly dependent on the focus.
 +
 
 +
{{Documentation_Sidebar}}

Latest revision as of 13:31, 17 June 2015

SimpleAutofocus Manual

Note
The SimpleAutofocus device adapter is deprecated. Please use the modern autofocus interface instead.

The C++ SimpleAutofocus Device Adapter, written by Karl Hoover, is a higher-performance version of the image-based autofocus function. It builds on the search and sharpness measures in the Java image-based autofocus kindly provided by Pakpoom Subsoontorn & Hernan Garcia. It provides some additional conveniences, for example, the user can over-ride the current acquisition binning and exposure. Multiple search algorithms can be selected. Multiple sharpness metrics are computed.

Refer to Pakpoom Subsoontorn's write-up for an explanation of the Threshold and Crop Ratio parameters, as those function exactly as described there.

SimpleAutofocusPropertyBrowser.png

Binning: If this value is not 0, Simple Autofocus will acquire images binned (down-sampled) per the specified setting.

Channel: If this is not blank this is the channel with which the autofocussing will be carried out. You could conceivably wish to switch to, one acquisition channel whilst in the middle of acquiring another channel. If this is blank, the autofocus will use the current instrument settings.

CoarseStepSize: In the BruteForce search method, this is the distance stepped in Z in the first pass search.

CoarseSteps: In the BruteForce Search method, this is the number of steps taken above and also below the current position. Thus, your entire search range is specified to be [CurrentZ - CoarseStepSize*CoarseSteps, CurrentZ + CoarseStepSize*CoarseSteps] The total coarse steps in the BruteForce search is 2*CoarseSteps+1

FineStepSize: In the BruteForce method, the is the Z step size in the second pass

FineSteps: In the BruteForce method, this is the number steps taken above and also the best focus position found in the first (coarse) pass.

Exposure: If this value is not 0, SimpleAutofocus uses this exposure for image acquisition, it is 0, the current acquisition Exposure time is used.

EnableAutoshutter: If this is 1, the shutter is closed between Autofocus image acquisitions, this setting is independent of the on-going acquisition sequence setting.

Mean: This displays the mean image value in the crop region.

Re-acquire&EvaluateSharpness: Set this to 1 to trigger the adapter to acquire a fresh image and calculate the sharpness score at the current position and acquisition settings.

SearchAlgorithm: Select the algorithm for finding the best sharpness measure. Thus far there are BruteForce and Brent. For BruteForce, use a two pass linear search with parameters described as above. For Brent, use Brent's derivative-less optimization algorithm on the same search range that BruteForce is configured to use, [CurrentZ - CoarseStepSize*CoarseSteps, CurrentZ + CoarseStepSize*CoarseSteps]

StandardDeviation/Mean: This is another popular measure of ImageSharpness which is much cheaper to calculate than the SharpnessScore. Usually SharpnessScore and StandardDeviation/Mean agree very well.

SharpnessScore: This is calculated per image-based autofocus described by Pakpoom Subsoontorn & Hernan Garcia, however, the image is first normalized by the mean. This greatly reduces effects of photo-bleaching on the focus score.

If debug log is ON, you can also see the dynamic range of the normalized image. This is also very strongly dependent on the focus.

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