Night sky image processing – Part 6: Measuring the Half Flux Diameter (HFD) of a star – A Simple C++ implementation

In Part 5 of my “Night sky image processing” Series I wrote about measuring the FWHM value of a star using curve fitting. Another measure for the star focus is the Half Flux Diameter (HFD). It was invented by Larry Weber and Steve Brady. The main two arguments for using the HFD is robustness and less computational effort compared to the FWHM approach.

There is another article about the HFD available here. Another short definition of the HFD I found here. The original paper from Larry Weber and Steve Bradley is available here.

Definition of the HFD?

Let’s start with the definition: “The HFD is defined as the diameter of a circle that is centered on the unfocused star image in which half of the total star flux is inside the circle and half is outside.”

In a mathematical fashion this looks like this:

$$\sum\limits_{i=0}^{N} V_i \cdot (d_i – HFR) = 0 \Leftrightarrow HFR = \frac{\sum\limits_{i=0}^{N} V_i \cdot d_i}{\sum\limits_{i=0}^{N} V_i}$$


  • $V_i$ is the pixel value minus the mean background value (!)
  • $d_i$ is the distance from the centroid to each pixel
  • $N$ is the number of pixels in the outer circle
  • $HFR$ is the Half Flux Radius for which the sum becomes $0$
Continue reading →

Night sky image processing – Part 5: Measuring FWHM of a star using curve fitting – A Simple C++ implementation


In Part 4 of my “Night sky image processing” Series I wrote about star centroid determination with sub-pixel accuracy. Based on this centroid position the FWHM determination of the star takes place. The FWHM (Full Width Half Maximum) value is a measurement for the star width. In this part I write about the so called curve-fitting which is helpful to determine the FWHM value from such an image. Note that for the following calculation and implementation I do not consider the sub-pixel determination of the centroid.

Determination of the FWHM

Let’s say we want to determine the FWHM in x-direction (red line). There is of course also one in y-direction. Basically, what happens is:

  1. Extract the pixel line through the centroid in x direction (those gray-level values usually form a Gaussian distribution: $$y(t)|_{b, p, c, w} = b + p \cdot e^{-\frac{1}{2} \cdot \big(\frac{t – c}{w}\big)^2}$$ We define a “data-point” as (x,y)=(pixel x-position, pixel gray-level value).
  2. Based on those (x,y) data-points determine the 4 parameters of a Gaussian curve so that the Gaussian curve and the data-points fit “as good as possible”. As fitting algorithm we use the so called “Levenberg-Marquart” algorithm. It tries to minimize the quadratic error between the data-points and the curve.
  3. The result is a Gaussian curve i.e. a parameter set which describes the curve (c=center, p=peak, b=base and the w=mean width). One of those parameters – the mean width is the FWHM value.
Continue reading →