Focusing

SharpCap has a several options to help acquire focus on targets (possibly one of the most challenging aspects of astrophotography).  The tools are particularly powerful if an ASCOM focuser is configured in SharpCap (An ASCOM focuser is a device which uses a stepper motor or DC motor to move the telescope focuser and can be controlled from a computer via a USB cable).

Introduction

There are six Focus Score tools, the appropriate one must be chosen for the target.  Each tool attempts to measure the quality of focus of the image (the different tools measure the quality of focus by different methods) and displays the measurement in the work area as both figures and a graph.  The graph may look something like this:

image

Green bars always indicate better focus while red bars always indicate poorer focus. The most recent measurements are shown at the right-hand side of the graph with older measurements to the left. Note, for some tools the best focus is associated with low scores (short bars in the graph), while for others it is associated with high scores (tall bars in the graph).

It is possible to just select one of the focus tools and adjust the focuser until obtaining the best score such that the score can no longer be improved by moving the focuser in either direction, but better results can be obtained with a full understanding of how the process works and the adjustments available.

Don't try to use the focus tools if the image is a long way out of focus.  The tools are to be used to go from being close to focus to perfectly in focus.  If focus is a long way out and there are problems getting anywhere near focus, try one of the following:

 

·         Focus on a terrestrial object at least 200m away in daylight (the further the better), which will get close to the focus point for astronomical objects.

·         Use the moon, if it is visible, as it is easy to find and bright.  This helps because it can be hard to find any objects when the telescope is a long way out of focus.  However, the moon is bright enough to be hard to miss even when the focus is very bad.

If the bright object is either in or near the field of view, all or part of a bright donut (reflector/SCT) or bright disk (refractor) of light will be seen – this is the very out-of-focus view of the object, made visible by the high gain and brightness boost.  Adjust the focuser of the telescope to make the disk/donut smaller, which will bring the telescope nearer to correct focus.

The Focusing Tools

The six available focusing tools can all be found under the Calculate Focus Score icon from the Tool Bar.  Select the desired tool to begin measuring focus.

image

Which Focus Tool Should Be Used?

For a single-star (or sparse) field use either FWHM or Bahtinov Mask.

For a multi-star field use Multi-Star FWHM.

For planetary or surface targets, there are three tools to choose from:

·         Contrast (Edge) Detection

·         Contrast (Brightness Range) Detection

·         Fourier Detail Detection

When trying to focus a planetary or surface target consider the following:

·         The different focus score algorithms are attempts to find a better balance between two opposing factors – sensitivity to being in good focus and insensitivity to noise.

·         There are trade-offs involved in the various approaches.  Which to use is going to be a matter of trial and error and/or personal preference.  The Contrast (Edge) Detection tool is (probably) a good starting point in most circumstances.

 

In more detail, the focus tools available are:

Tool

Description

Best Focus

Contrast (Edge) Detection

Suitable for planetary or surface targets.  Measures the total amount of contrast in the image - better focus gives more contrast which gives higher scores.

Tall green bars (high values) are best.   Red is worst.

Contrast (Brightness Range) Detection

Suitable for planetary or surface targets (especially high noise).  Measures the range between the brightest and dimmest parts of the image - better focus should give higher scores.

Tall green bars (high values) are best.  Red is worst.

FWHM Measurement

Suitable for stars or other point sources.  Measures the width (FWHM) of a sole star –  which must be selected using the selection area tool.  Better focus gives narrower stars and a lower FWHM score

Short green bars (low values) are best.  Red is worst.

Multi-Star FWHM Measurement 

Suitable for stars and point sources.  Measures the FWM of all suitable stars in the frame, giving an average score.  Once again, lower scores mean better focus.

Short green bars (low values) are best.  Red is worst.

Fourier Detail Detection

Suitable for planetary or surface targets.  Measures focus by examining amount of detail in small scales in the image as determined by a Fourier Transform.  Good focus leads to higher scores.  May be less sensitive to noise than contrast detection options.

Tall green bars (high values) are best.  Red is worst.

Bahtinov Mask

Suitable for stars or other point sources.  Requires a Bahtinov mask to be placed over the aperture of the scope and the area around the star and lines to be selected using the selection tool.  Best focus is achieved when all three lines intersect at the same point which gives scores (positive or negative) closest to zero.

Short green bars (low values) are best – values can be positive, negative or zero.  Zero equals perfect focus.  Red is worst.

 

Notes

1.       Which is the best focusing method for planets and surfaces?  All three see noise as detail to some extent so picking the right one is a case of trial and error and personal preference.

2.       A Bahtinov mask of suitable diameter must be placed over the end of the telescope to use the Bahtinov Focus Score tool.  Negative values are possible, values nearest zero are best, so -0.1 and 0.1 are equally good, 0.0 is perfect and +3.9 and -3.9 are equally bad.

3.       Remember – tall green bars for Planets and Surfaces, short green bars for Stars.

4.       Multi-Star FWHM is usually better than single-star because it takes 10s or 100s of FWHM measurements and averages them, so there should be less noise and less systematic error in the reading.

Focusing Procedure

The table details the various steps to be followed to achieve good focus of the telescope.

Telescope (no ASCOM focuser)

Telescope (with ASCOM focuser)

Preparation Phase

·         Initial visual focus with telescope against a distant object.

 

Setup Phase

·         Check target not over exposed using Image Histogram tool.

·         Select appropriate Calculate Focus Score tool – adjust black level, target detection parameters, ROI box – to obtain best focus score.

·         Reset the graph to wipe the score history.

 

Focusing Phase

·         Adjust telescope focuser manually, watch focus scores.  Stop when best score obtained.

·         Telescope now in focus.

Focusing Phase

·         Adjust telescope focuser using the Focuser controls in the camera control panel, watch focus scores. 

·         Use the Graph tab.  Stop when best score obtained.

·         Telescope now in focus.

During the Setup Phase, the scores being shown are meaningless as they are changing because of changing the software parameters, not changing the focus of the telescope.

At the end of the Setup Phase, Reset the Graph to wipe the score history.

During the Focusing Phase, only adjust the telescope's focuser, not any of the settings within SharpCap – this is to ensure the changes seen in the focus score are only a result of the changes in focus of the telescope and are not influenced by anything else.  If any SharpCap settings are changed during the focusing stage (for instance because a planetary target has shifted in the field of view and there is a need to update the ROI), reset the graph after making the adjustment – effectively starting the focusing phase again.

Focus will need to be checked throughout a session as it could change because of one or more of the following factors:

·         Thin cloud over target.

·         Changing atmospheric conditions.

·         Change in temperature affecting telescope tube.

·         Change in temperature affecting optics.

The table below shows what would be seen in SharpCap when using the appropriate Calculate Focus Score tool for a telescope both without and with an ASCOM focuser.

Telescope (no ASCOM focuser)

Telescope (with ASCOM focuser)

image

 

image

FWHM measurement for star. In this trace, the focuser was moved from a position of reasonable focus (initial yellow/green bars) to a position of poor focus (red bars) and back to a position of good focus (dark green bars).  [Note: History tab only.]

image

 

 

image

Contrast Edge Detection for a planet. In this case, the focuser was moved from an initial poor focus to a better focus and past best focus back to a poor focus position.  [Note: History and Graph tabs.]

 

image

 

Overview of Display

When selecting one of theFocus Score tools, Contrast (Edge) Detection in this case, the following screen appears.  This screen layout is the same for all six Focus Score tools.

image

There are four distinct regions when a Contrast Focus Score tool is in use.

The Capture Display Area

image

In the Capture Display Area, a red Selection Area rectangle appears.  The rectangle can be dragged with the mouse and resized.  It would be moved over the edge of the object, completely onto the surface, or expanded to surround the complete object. 

 

·         Any area outside the red rectangle will be excluded from focus score calculations.

·         Any area within the rectangle which is not shaded (above the black level) will be included for focus score calculations.

·          Any area within the rectangle which is shaded (below the black level), will be excluded from focus score calculations.

 

The Controls Pane

image

·         The following Controls are available:

o   Black Level %, a slider

o   Reduce Noise, a checkbox

o   Averaging, see description below

·         Context sensitive Help is available.


The Graphs Pane

image

·         The graph region will display a graphic for:

Focus Score history (History tab)

Focus Score v Focus Position graph (Graph tab).  [Note: This only shows if there is an ASCOM focuser connected.]

·         The black line is used to indicate Focuser Position (explained later).

·         The blue line is Average Score – an average of the 10 previous focus scores.

·         The left hand vertical axis shows focus scores.

·         The right hand vertical axis shows focuser position.

 

The Scores Pane

image

·         The title bar of the panel can be used to drag the panel out of the main SharpCap form, for example to place it on a second monitor

·         The Pin icon can autohide the focus tool displayed in the Work Area.

·         Current score (Now) and Best score recorded so far (Best) are shown.

·         The Reset button clears the history and the best score.  If the Selection Area is enabled, disabled or moved, or the Black Level changed, the Reset button should be used.

 

Focus Tools Controls

This section describes the focus tools controls.  At first use, a set of sensible defaults is offered.  As these settings are changed, SharpCap will retain them for subsequent use.

This is a summary of the control group for all six focus score methods.  The first five are identical, with the Bahtinov mask having two additional fields.

image

image

image

image

image

 

image

 

Context sensitive help is available with all six focus score tools – click the Help link to see the help onscreen.  For example, this is the Help for Contrast (Edge) Detection:

image

The controls in the next table are common to all six focus score methods.

image

Black level – anything below that level is excluded from the calculation, avoids including dark level noise in the calculation.

image

Reduce noise – applies a weak Gaussian blur to the image to cut down on pixel noise before performing the measurement.

image

Averaging – choose either average or best score from an averaging period to be the value recorded. 

image

Average Over – the period can be specified as either number of frames or a time-period by the settings offered.

 

image

ScoresNow and Best are shown.  Understand which focus score methods need high/low values. 

The score can be Reset and should be if the Selection Area is enabled, disabled or moved, or the Black Level changed.

Angular Resolution and Line Width are controls found only in the Bahtinov focus score.

image

Angular Resolution – measured in degrees and defines how finely to scan the full 360 degrees when looking for Bahtinov lines – the default scans once per degree, but it can be made finer.  Possible values are 0.20°, 0.25°, 0.33°, 0.5°, 1.0°

Line width – measured in pixels and should be set to roughly the width of the Bahtinov spikes seen on the screen – the correct value here helps SharpCap separate the spikes from the noise.  Possible values are 1..40 in increments of 5.

 

The Graph Pane

The History tab always appears (1st diagram below).  The additional Graph tab will only appear when an ASCOM focuser is connected (2nd diagram below). 

History Tab

The History tab provides more functionality when there is an ASCOM focuser, although it is best to switch to the Graph tab when a focuser is connected.

image

No ASCOM focuser connected

 

·         Blue 'average' line appears, an average of the last 10 focus score measurements, helps to see changes when the focus value is varying from frame to frame due to noise.

·         New measurements appear on the right, older ones will disappear from the left once the chart area is filled.

 

 

 

image

ASCOM focuser connected

·         Focuser Position axis on the right appears.

·         Black Focuser Position line appears.

·         Blue average line changes to a stepped graph.

·         Each horizontal segment of the average line corresponds to a period when the ASCOM focuser was at a certain position.

·         When the focuser position moves, a new segment starts.

·         The horizontal segments indicate the average focus score value over all the samples when the focuser was at that certain position.

 

This is the range of colours that can be displayed – from red (poor focus) to green (good focus).

Red > Orange > Yellow > Light Green > Dark Green

image

Colours and heights of focus graph bars are not an absolute measure of 'good focus', they are a measure relative to the other recent focus measurements made.  The best focus score recently obtained will always get a vivid green bar and will be the highest (lowest for FWHM) one in the graph.  This doesn't mean perfect focus, it means the best focus achieved since the focus tool was opened (or since last reset).  The exception to this is the Bahtinov mask tool - there the value of zero is an absolute measure of perfect focus.

Graph Tab

This graph only appears if an ASCOM focuser has been configured in SharpCap.

The graphic shows the focuser position was stepped from -3 to +3 in the following sequence:

-3   -2   -1   0   1   2   3

image

This graph shows the focuser position along the horizontal axis and the focus score on the vertical axis.

·         The green upward pointing triangles show data points collected when the focuser was moving in the positive (outward) direction.

·         The red downward pointing triangles show data points collected while the focuser was moving in the negative (inward) direction.

·         Stronger colours indicate more recent data points.

·         Faded colours indicate older data points.

The black lines and numbers on the History graph below correspond to the focuser positions shown in the Graph above.

With an ASCOM focuser installed, work from the Graph tab rather than the Histogram tab.  To find the point of best focus using the focus score axis (at the left of the graph) look for:

·         The peak value (Contrast Detection/Fourier options).

·         Minimum value (FWHM options).

·         Zero (Bahtinov option).

Backlash in the focuser mechanism will be present in all real focusers and shows itself as the best focus point appearing in differing positions depending on which direction the focuser is moving.  So, if the peak focus score is at focuser position 20100 when the focuser is moving in the positive (+ve) direction, it could be at 19900 when moving in the negative (-ve) direction.  If trying to return the focuser to the position where the score was at its best, always approach from the same direction used when measuring the focus to avoid errors caused by backlash.

image

This functionality can be experimented with using the Focus Offset control available in Test Camera 2 (High Speed) which can be found in the Camera Control Panel.

image

History and Graph Manipulation

·         Drag with left mouse button to move around.

·         Mouse wheel to zoom.

·         Select an area with middle or right mouse button to zoom to that area.

·         Double click to return to default view if lost.

 

image

Hovering the mouse over the blue line will show focus score history of the preceding 10 samples.

 

image

Hovering the mouse over the focuser graphics will display a focuser position and score report. 

 

Setting the Correct Black Level

Before setting the black level, ensure the object is not over-exposed by viewing with the Image Histogram – avoid the Image Histogram hitting the right-hand side.

For a large planetary target, the optimum black level is when there is a thin black area between the object and the dark area.  This can be difficult to see, so use the Zoom tool from the tool bar to improve the detail.

image

Contrast (Edge) Detection focus score used.

 

Here the Zoom is 100%.  The black level happened to be 6.5% in this case.

 

The actual optimum percentage black level will vary depending on camera and settings.  The picture illustrates how the black level shading should look when the black level is set correctly.

 

When the ROI is over the planet, and everything within the ROI is part of the desired image.  The requirement is to measure the focus of all of it.  Hence in this case, the black level is set to low or zero.

For a star as target, the optimum black level is when there is a thin black area between the object and the dark area.  This can difficult to see, so use the Zoom tool from the tool bar.

image

FWHM focus score used.

 

Here the Zoom is 150%.  The black level happened to be 21% in this case.

 

The actual optimum percentage black level will vary depending on camera and settings.  The picture illustrates how the black level shading should look when the black level is set correctly.

 

This is the effect of the correct black level on the focus score, making it clear the graph should always be reset after adjusting the black level or other parameters to avoid confusing the results of these adjustments with actual changes in the quality of focus.

image 

 

Using a Bahtinov Mask

A Bahtinov mask must be fitted to the telescope for the Bahtinov mask focus score tool to work.  Here are examples of diffraction patterns obtained using a Bahtinov mask in the conventional way, where the intersection of all three diffraction spikes at a single point indicates good focus.

image

image

image

Good

Off to the left

Off to the right

 

The Bahtinov Mask is used for single stars, which must be selected with the region selection area. Good focus is indicated by short green bars.  No bars, or a score of 0, indicated perfect focus.

When using the Bahtinov mask tool, ensure the Black Level control is set to a value that excludes the background area around the diffraction spikes from the focus score calculation but includes the entire visible diffraction spike area.

SharpCap attempts to detect the diffraction lines created by the Bahtinov mask and calculate whether they all meet at a single point (in focus) or not – SharpCap will draw coloured lines over the diffraction spikes as can be seen in the diagrams below.

Check the lines really are following the diffraction spikes, as sometimes the wrong lines will be detected and if this happens (as shown in the diagram on the right) the focus score will not be accurate.  When the lines are detected incorrectly, it is usually possible to correct the problem by adjusting the black level or camera parameters such as gain or exposure.

 

image

Diffraction spikes

image

SharpCap overlay

image

Resulting graphic

Diffraction spikes overlaid by the SharpCap mask gives the aligned graphic at focus.

(Nearly) Automatic Focusing

When using an ASCOM focuser, SharpCap Pro users can activate additional features that allow many of the steps outlined above to be automated. The actions that can be automated are

·         Scanning over a range of focuser positions, measuring the focus score at each position to produce a focus quality graph automatically.

·         Returning automatically to the position at which the best focus score was measured

·         Automatically re-scanning over the same range of focus positions and stopping automatically when the highest measured focus score is reached

All of these functions can be activated using the controls which are available in the top-right corner of the Focus Graph

image

Note that the buttons in the Goto and Scan groups will appear slightly transparent until you move your mouse over them – this allows graph detail behind the buttons to be seen.

Automatic Focus Scanning

The Scan In and Scan Out buttons can be used to initiate an automatic scan over a range of focuser positions, measuring the quality of focus at each position. This is best started one side of the point of best focus so that the scan will pass through the expected position of best focus.

image

The details of the focus scan can be configured by pressing the Options… button and setting

·         Scan Step Size – this is the amount of focuser movement between each focus measurement

·         Max Step Count – this is the total number of steps of Scan Step Size to make during the focus scan

·         Samples to collect at each Step – the number of frames to use to measure the focus score at each step. Note that SharpCap will wait at least one frame to allow movement to settle at each step before starting measurement.

The scan will continue, building up data in the Focus Graph until either

·         The Stop button is pressed

·         The focuser reaches its maximum or minimum possible position or

·         The number of steps configured in the options has been completed

During the scanning process, information on progress will be shown in the notification bar.

image

Point of Best Focus Detection

SharpCap will monitor the focus data being accumulated during both automatic and manual focus movements and try to find a pattern in the data. In particular SharpCap is looking for the point of best focus, which will be indicated by a best-fit curve with either a peak (as shown below) or a valley. A valley shaped best-fit curve should be expected for focus scores where the lowest values are best (i.e. star FWHM measurements), a peak should be expected for scores where the highest values are best (i.e. contrast measurements).

image

The best-fit curve will indicate the position where best focus is expected to be found, even if it occurs between two measurement positions.

Note that the focus measurements must include at least two or three measurements each side of the point of best focus for the focus best-fit curve to be detected properly. If a focus scan stops at or before this point (i.e. the stopping point has the best score so far) then press the scan button again to continue the scan past the point of best focus.

Once the best-fit curve is shown and has a clear peak or valley, the Go To Best Position or Go to Best Score options can be used to return the focuser to the point where the best focus was achieved.

Returning to Best Focus

SharpCap can return to either the focuser position where the best focus score was obtained, or attempt to return the focuser to a position where the score matches the best score obtained so far via the two ‘Go To …’ buttons.

Each of these buttons has a dropdown to allow choice of which direction of movement to use the best data from – positive (outward) or negative (inward). The Focus Graph can show two best fit lines (green for movement in the outward direction, red for movement in the inward direction). If the focuser hardware has any significant backlash then these lines may not peak in the same position, making it important to be able to choose between them.

image

The default action of the Go To buttons (if you do not choose from the dropdown but just press the button) is to choose the direction that was scanned most recently.

Whichever direction of scan is chosen, and regardless of the choice between using Go to Best Position and Go to Best Score, SharpCap will always move the focuser so as to approach the best focus position in the same direction as the scan data being used, moving the focuser past the best focus region if necessary first to allow approach from the correct direction. This is necessary to keep the effect of any focuser mechanism backlash to a minimum

Go to Best Focus Position

The Go to Best Position button is the best option if your focuser has minimal backlash and can accurately return to a previous focus position. Focusers based on stepper motors generally fall into this category.

When this button is pressed, SharpCap will calculate the focuser position for the optimum point on the best-fit curve and then move the focuser to that position (from the same direction as the curve measurements were made to minimize backlash). This should place your telescope into best focus.

Go to Best Focus Score

The Go to Best Score button is the best option if your focuser is less accurate and has trouble returning to exactly the same physical position when the same focuser position number is selected. Focusers based on DC motors generally fall into this category.

When this button is pressed, SharpCap will attempt to find a position where the focus score matches (or is close to matching) the peak value measured in the previous focus scan. The target score that SharpCap will try to achieve is the average of the two best scores measured in the previous focus scan. This procedure will involve making a second focus scan in the same direction and stopping when the target focus value is reached, and will therefore take longer than the alternative of using the Goto Best Focus Position button.

Automatic focussing with a Bahtinov Mask

The discussions of automatic focussing above concentrate on focus score methods such as Contrast Detection and FWHM Measurement which give either a maximum value or minimum value at the point of best focus. When using the Bahtinov Mask focus tool, the best focus is at the point where the focus score is zero.

The automatic focussing routines described are capable of working with the Bahtinov mask tool and will properly return to the point where the focus score is zero.