Autofocus seems suspect

Questions, bug reports, requests for enhancements, etc.
rumen
Posts: 133
Joined: Wed Feb 22, 2017 7:31 pm

Re: Autofocus seems suspect

Post by rumen »

iMustBcrazy wrote: Sat Aug 07, 2021 7:03 am It was a bit more complex than I was expecting. I’ll have to review it at home. But focus worked consistently tonight so that’s good!
Did you follow the procedure?
iMustBcrazy
Posts: 338
Joined: Sun Jun 02, 2019 3:52 pm

Re: Autofocus seems suspect

Post by iMustBcrazy »

rumen wrote: Sat Aug 07, 2021 10:48 am
iMustBcrazy wrote: Sat Aug 07, 2021 7:03 am It was a bit more complex than I was expecting. I’ll have to review it at home. But focus worked consistently tonight so that’s good!
Did you follow the procedure?
I gave it a read but no, I need to spend some time to get info and do calcs. Hopefully by next outing, next weekend.
iMustBcrazy
Posts: 338
Joined: Sun Jun 02, 2019 3:52 pm

Re: Autofocus seems suspect

Post by iMustBcrazy »

I went through the procedure you wrote and the numbers were very close to what I had after doing the V-curve. The only thing that I thought was maybe an issue was using 10-15 times the final step value for the initial step. It puts the focus quite far out initially, and my first try last night failed, leaving the focus not so good and probably even harder for the algorithm to start from. I manually corrected it and started again and was successful. But I’m really helping the tool.

I was wondering if the focus feature could do a V-curve at least once to calibrate the focus system and determine the step settings. This would save the user having to do a lot of preliminary work. This is kind of how PHD works for guiding, making it very easy for the user. I think it’s what customers are looking for.
rumen
Posts: 133
Joined: Wed Feb 22, 2017 7:31 pm

Re: Autofocus seems suspect

Post by rumen »

iMustBcrazy wrote: Tue Aug 10, 2021 3:59 pm I went through the procedure you wrote and the numbers were very close to what I had after doing the V-curve. The only thing that I thought was maybe an issue was using 10-15 times the final step value for the initial step. It puts the focus quite far out initially, and my first try last night failed, leaving the focus not so good and probably even harder for the algorithm to start from. I manually corrected it and started again and was successful. But I’m really helping the tool.

I was wondering if the focus feature could do a V-curve at least once to calibrate the focus system and determine the step settings. This would save the user having to do a lot of preliminary work. This is kind of how PHD works for guiding, making it very easy for the user. I think it’s what customers are looking for.
Thanks for the feedback. Well about the initial step i used 12x and it worked well for me. another user used 14x and it works well for him... this is not an exact science. but I can recommend lower value if it does not work for you.

What comes to V curve, it is not that simple you still need a step for it. If too small it may take forever to complete if too large you may overshoot the focus in very coarse steps and to end up with unusable fit. And the worse thing is that there is no reasonable recommendation for this. You should still measure some HFDs and see how to changes and determine the initial step. I looked through several manuals about the V curve and this was the best thing I found:
Auto Focus Step Size

To determine the correct Auto Focus Step Size, a user could start with the focuser slightly out of focus outwards from best focus. Then move the focuser outwards by say 10 steps. If there an obvious difference to the eye, and the star diameter has increased by around 20-30% or so, this is likely a right step size. Another method is the following: starting from a good focus position (e.g. by focusing with a Bahtinov mask) the user can progressively move the focuser inward (or outward) until N.I.N.A. is not able to determine stars HFR in the image. The total increment represents the maximum initial offset. To be on the safe side the user can take 80% of the max initial offset and divide it by the Auto Focus Initial Offset Steps (default = 4). The resulting value represents a good Auto Focus Step size. Star HFR detection and Annotate Image must be turned ON during the process.

Example: assuming a starting point of good focus of 4000 steps, we will move the focuser outward by an amount of 10 steps at the time, and take a new exposure at the end of each increment to check the measured HFR. Let's say that after 12 moves (120 focuser steps) no or just a couple of very defocused stars will still be detected by N.I.N.A. The value of 120 steps will therefore represent be the max increment. Scaling it by 80% (roughly 100) and dividing it by the Initial Offset (4) will give us an Auto Focus Step Size of 25.

Otherwise, the user should keep experimenting until they find a step size that shifts the focus by the right amount.

The above Step Size (in focuser steps) will be correct for Star HFR measurement. For contrast measurement based on Sobel or Laplace methods, this should also work fine. For Statistics-based contrast measurement, it may be appropriate to divide the Step Size by 2 or 3 and use that (as we saw in the previous example, the peak in that case is quite narrow).
So I really doubt whether we should replace what we have with something like this. we will be just replacing one user performed procedure with two. One user performed and one automatically performed.

What comes to PHD we also have guider auto-calibration which works excellent. The problem is that guiding is quite different form focusing. There are far fewer variations in pixel scales (they roughly vary from 0.5"/px to 3"/px) and guiding rates vary from 3.75'/s to 15"/s and almost 99% of the time it is 7.5"/s. What comes to focusers the gear ratios may differ with orders from one to another and HFD can be also quite different. For some systems critical focus can be 2-3 steps only and for other over 200-300 steps. For example, you can change the ratio by the factor of 10 depending on what knob of the focuser you attach your motofocuser. On top of that some motfocusers can also change this ratio internally 16 or even 32 times depending on the motor step configuration. This results in 320x difference for the same hardware depending on the configuration! That is why you can set reasonable initial params for guider auto calibration and is very complex for the focusing.

I hope you got the idea...
iMustBcrazy
Posts: 338
Joined: Sun Jun 02, 2019 3:52 pm

Re: Autofocus seems suspect

Post by iMustBcrazy »

I understand there are a lot of variables. I don’t have the answers off hand. Maybe there is a way the user can easily help the algorithm calibrate and do a better job. The NINA method to determine step size is easy and quick. Once the auto focus algorithm has some basic parameters. It could take its time the first time to optimize the settings and save them for future runs. It would be worth it to improve and speed up a normal auto focus run and it would only have to be done once for the rig.
rumen
Posts: 133
Joined: Wed Feb 22, 2017 7:31 pm

Re: Autofocus seems suspect

Post by rumen »

I will see what can be done. but it will not happen overnight. I will need some time to investigate the options and experiment a bit.
iMustBcrazy
Posts: 338
Joined: Sun Jun 02, 2019 3:52 pm

Re: Autofocus seems suspect

Post by iMustBcrazy »

rumen wrote: Wed Aug 11, 2021 8:35 am I will see what can be done. but it will not happen overnight. I will need some time to investigate the options and experiment a bit.
Sounds good!
rumen
Posts: 133
Joined: Wed Feb 22, 2017 7:31 pm

Re: Autofocus seems suspect

Post by rumen »

Guys,
As I promised, I prototyped a new focusing algorithm that works with crazily out of focus initial images and with Bad cameras full of hot pixels even with hot column. Please see the video below:
https://drive.google.com/file/d/1qycqZZ ... sp=sharing

In the video I am starting starting with image where no star can be seen at all (focus pos 70). And the algorithm figures out in which direction to go and look for focus. It is based on RMS image contrast and not on star HFD or HWFM. So we do not need to see stars at all. And as you can see it reaches perfect focus (position 0). In the video, one can start to see the stars at around poition 20. This algorithm work for all sorts of images.

However I suspect that it may not be as accurate as HFD estimation. We need to test and compare both methods, but I have an idea to make a hybrid method. Start with RMS contrast estimator until measurable stellar HFDs are reached and then switch to the HFD estimation (currently used one) to fine tune the focus.

This is still prototype and it may take some time to polish but we are getting there to be less sensitive to the initial focusing conditions...

Rumen
iMustBcrazy
Posts: 338
Joined: Sun Jun 02, 2019 3:52 pm

Re: Autofocus seems suspect

Post by iMustBcrazy »

That is awesome! Good job Rumen. This is the kind of thing that will make people switch to cloud makers.
rumen
Posts: 133
Joined: Wed Feb 22, 2017 7:31 pm

Re: Autofocus seems suspect

Post by rumen »

You mean switch to INDIGO :) This is done by the INDIGO framework, CloudMakers products use indigo framework for the Mac products. This video was made with Ain which is the INDIGO client for Linux and Windows. So in general all indigo users will benefit from it.
Post Reply