The new AF routine has made some major improvements in its ability to detect donuts in central obstruction scopes, as many of the comments in this thread confirm. However it is not yet quite perfect, but I think is very close to being a world class AF routine.
I suggest the following worthy goals for a final, world class version:
(1) Give accurate and very consistent results over a very wide, out of focus range, well into donut land on obstructed scopes and very large out of focus stars for refractors.
(2) Accomplish (1) without requiring any user customization other than determining a reasonable step size for the focuser.
(3) Accomplish (1) for practically all image targets, or at least the vast majority of targets.
(4) Accomplish (1) for practically all combinations of hardware.
I firmly believe that all 4 of these goals can be readily achieved with a few more tweaks to the AF code.
Since the older version of the AF routine did wonderfully well satisfying all 4 of these for refractors (with the exception of the out of focus part of (1)), these are clearly within our grasp (or at least Kenās).
Here goes my thoughts on how to do this:
Start with the focus curve produced by version 2.5.1.6 that I gave detailed info about in the prior posts, 14 frames from 18000 out to 19040, step size 80, on my 714 mm FL refractor.
All my comments in this thread referring to the refractor are binned 1x1 because they all use my Canon 6D DSLR.
Focus position 18000 is the perfect focus position as established with several runs just prior to this long final run that all the following plots refer to.
The prior runs that confirmed 18000 as best focus were run with step size = 50, 9 total steps, so the max focuser position was 18200, and all gave excellent curves, with HFR close to 1.8 and end points around 4. Excellent results and very comparable to what the older AF routine produced for me on virtually every target I have imaged over the past 8 months (around 60) with no customization of the routine other than step size.
It is important to note that going out to 19040 is enormously out of focus. I had no intention of trying to go that far out of focus, since the initial phase of the run only goes out to 18320, not that far away from my usual range out to 18200. However the routine forced a second phase out to 19040.
It is truly a miracle that the current AF routine actually handled this entire range fairly well, using the tuned MinStarSize of 12. A great credit to Ken for improving the star detection routine to the point where it reliably finds stars so out of focus. The old routine would have croaked big time.
Focus Plot for Version 2.5.1.6 (tuning the Maximum Star Size to 12 gave the best results)
I then picked 3 specific stars to look at the detailed star images for those 3 over the entire 14 frame range.
Stars A and B are among the brighter stars in the full image and are in a small group at the very top of the full image. This star group AB is less than 1% of the entire image. In the best focus frame it contains 20 easily identified sharp focus stars. In the worst focus frame it contains 4 easily identified stars.
Star C is the brightest star in the frame, dead center, magnitude 6, which I was going to use a mask to focus on.
Star group AB at 18000 (best focus position). A and B are the 2 brightest stars toward the bottom.
Star group AB at 18400 (WAY out of focus).
Star group AB at 19040 (ENORMOUSLY out of focus).
Focus plot for just Star A (plot for Star B is essentially identical, so not shown)
Note this plot for Star A (and Star B) is the best of the three plots. Significantly better than Star C and Ver 2.5.1.6 (using 12) near best focus where they both show best focus higher than the true best focus at 18000.
Focus plot for just Star C:
Note this plot for the very brightest star is the worst of the 3 plots, but still fairly good.
Here is the data for the above plots:
Based on the above, I suggest the following tweaks to the AF routine will accomplish the above goals (1), (2), (3) and (4).
A) Concentrate on only using statistics from the fairly bright stars, but not really bright ones, and not the dimmer ones. As demonstrated above the 2 fairly bright stars all by themselves each give excellent focus results. The very bright stars (Star C) and the current version of the routine give worse results, particularly near good focus. Not using dimmer stars is very important if the routine is going to work at the out of focus positions, simply because the more out of focus, the dimmer the dim stars become so that they cannot even be detected. Only the brighter stars can be detected when out of focus.
B) Specifically, find the brightest 10 to 50 stars, eliminate the 1 to 5 very brightest, use the remainder for HFR stats in all frames. Make note of their positions in the first frame for comparison with following frames. If frame #2 has fewer of these specific stars than the frame #1, then probably frame #2 is further out of focus than frame #1. If frame #3 also has fewer than #1, then you are clearly moving farther out of focus. Moving closer to focus will always include all the initial stars selected from frame #1, since they will become brighter and easier to identify the closer we are to good focus. Use a fixed minimum star size of 4 to avoid finding hot pixel stars if the region is so star poor that at least 3 or 4 reasonably bright stars are not detected.
This scheme allows the routine to use the exact same stars in every frame for the most accurate and reliable HFR comparisons between frames. It also eliminates any need for the Minimum Star Size, other than to simply eliminate hot pixel stars with a fixed value of 4, since small stars are not being used in any way in calculating HFR. Larger, brighter stars are mandatory for calculating an HFR in the more out of focus frames.