The Half Flux Diameter of a perfectly normal distributed star

Calculating the Half Flux Diameter for a perfectly normal distributed star…

… and why the answer is not 42.

The goal of this article is to “manually” calculate the Half Flux Diameter (HFD) for a perfectly normal distributed star. Initially, I decided to add perfectly normal distributed stars with different σ values as additional unit tests to my focus finder software project. A few of those star images with σ=1, 2 and 3 are illustrated in figure 1.

Previously, I examined the Half Flux diameter (HFD) for a plain image. In that article I cover some aspects in greater detail which I am reusing in this article. If something is unclear I recommend to read this article first.


A 2D image can be represented in the 3D space where the $x$- and $y$-axis are used to express the position of the pixel and the $z$-axis to visualize the intensity (pixel value) – see figure 2 below.

Figure 2: The $x$- and $y$-axis represent the pixel position on the image plane, the $z$-axis represents the intensity $I$. The blue circle is the “outer circle” with radius $R_{out}$ up to which the pixel values are considered for the $HFD$ calculation. The green circle is the actual $HFD$ circle. The total volume under the surface is 1 (normalization factor is $\frac{1}{2\pi\sigma^2}$.

Following a similar approach like for the plain image, the Half Flux Diameter (HFD) for such an image will be derived in the following sections.

Quick summary

For those who just seek for the facts – here is a quick summary:

  • The Half Flux Diameter ($HFD$) for a perfectly normal distributed star is $HFD_{norm-dist} = 2 \cdot \Gamma\left(\frac{2}{3}\right) \cdot \sqrt{2} \cdot \sigma = 2.50663 \cdot \sigma$ where $\sigma$ is the variance of the distribution.
  • The result does not depend on $R_{out}$ and also not on the normalization factor of the distribution.
  • The expression was derived by converting the $HFD$ formula into an integral and inserting the normal distribution function as intensity (pixel value). The integral was solved by using a relation between the normal distribution and the $\Gamma$-function.
  • For the volume integration the second Pappus–Guldinus theorem is used.
Continue reading →

The Half Flux Diameter (HFD) of a plain image

Why the Half Flux Diameter (HFD) is not exactly what it suggests… and why it probably does not matter in practice.

For people dealing with astronomical images the Half Flux Diameter (HFD) definitely is a well known parameter. In a few words, the HFD measures how well a star is focused. The measure is relatively robust and also works when the star is far out of focus. In another article I cover the basics of the HFD.

Strange things happening here…

HFD and I were best friends until I started to write some unit tests for the HFD calculation routine in the focus finder project. Basically, the idea was to test the calculation routine with some test images for which the expected outcome was well known. This should have proven that the implemented routine was working correctly. One of those test images was a plain image in which all pixel values had the same value (> 0). Given the definition of the HFD:

“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.”

it should be easy to predict the expected outcome. Since the flux is equally distributed across the entire image, it seems obvious that – as the name suggests – the resulting Half Flux Diameter is the diameter for which a corresponding “inner circle” contains exactly 50% of the area. The other 50% of the area should be located in between the “inner” – and the “outer” circle. This is what I assumed in my previous article about the HFD. However, it turned out to be wrong and I unfortunately have to invalidate this part.

Instead, the HFD routine gave a different result. Even for big images (to reduce the error of discretization) the result was off by a mysterious factor of 1,060660172 to the expected value. This gave reason to have a closer look to this enigma…

Quick Summary

For those who just seek for the facts – here is a quick summary

  • The Half Flux Diameter (HFD) of a plain image is $HFD_{plain-img} = \frac{4}{3} \cdot R_{out}$.
  • The corresponding HFD circle does not exactly split the area of the “outer circle” 1:1 even if the definition of the HFD suggests this – in other words $HFD_{plain-img}$ is not exactly $\sqrt{2} \cdot R_{out}$.
  • The root cause lies in the definition of the HFD itself: Pixels far away from the image center are weighted stronger than those which are very close.

For a few more details and reasoning read on…

Continue reading →

Finding perfect focus with V-Curve fitting based on a hyperbolic function

This article is about finding the best possible telescope focus by approximating a V-Curve with a hyperbolic function.

What is a V-Curve?

A V-Curve is the result of moving the focus of a telescope from an outside focus position into the focus and then further into the same direction out of focus again. This way a V-Curve comes into existence where the focus position is on the x-axis and the focus measure on the y-axis (right figure). Probably not surprising this curve is called V-Curve since it is similar to a V. There are different ways to measure the focus – for example the “Half-Flux Diameter” (HFD) and the “Full width at half maximum” (FWHM). In this case the I use the HFD measure.

Continue reading →

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 →