What am I doing wrong in Autofocus routine?

Somewhere to ask questions about the best way to use SharpCap
Forum rules


If you have a problem or question, please check the FAQ to see if it already has an answer : https://www.sharpcap.co.uk/sharpcap-faqs
Post Reply
JesusRL
Posts: 70
Joined: Wed Aug 05, 2020 4:36 pm
Location: Madrid

What am I doing wrong in Autofocus routine?

#1

Post by JesusRL »

Hi,

I am trying to setup and manage the autofocus routine (multiple fwhm) and I am absolutely unable to make it work.

After many many attemps and trying to figure out what I may be doing wrong I can only conclude the following:

* It looks that, even though I use a 16 bit camera, the autofocus routine reduces the depth to 8 bits (according to pixel readouts in the image)

* I have several stars above 25, which should be the equivalent to above minimum 10% and not saturated, equivalent to below 90% BUT they are not counted

* I have tested all the params and stars is always 0 or1 (not enough). It only raises to about 350 if I reduce star width to 2 pix. All the new ones that appear are FALSE stars

I have tested equivalent routines (in other packages) with the same exposure, gain and offset with full succes in all of them.

I want to continue in SharpCap; for all the rest I like it the very most, but I need autofocus to run.

T&R
User avatar
admin
Site Admin
Posts: 13177
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: What am I doing wrong in Autofocus routine?

#2

Post by admin »

Hi,

I think the best thing would be if you can share a FITS image that you have captured (upload to dropbox/google drive/one drive and share the link here). I can then look at that and try to work out what is going wrong.

You are correct that the focus measurements internally reduce the pixel bit depth to 8 bit, but that should not normally be an issue (stars that are lost by transferring to 8 bit are usually only just above the noise floor anyway and would not make a suitable candidate for FWHM measurement).

cheers,

Robin
JesusRL
Posts: 70
Joined: Wed Aug 05, 2020 4:36 pm
Location: Madrid

Re: What am I doing wrong in Autofocus routine?

#3

Post by JesusRL »

The rain in Spain stays mainly in the plain

Let's see if I can test it somewhen next month :?

T&R
JesusRL
Posts: 70
Joined: Wed Aug 05, 2020 4:36 pm
Location: Madrid

Re: What am I doing wrong in Autofocus routine?

#4

Post by JesusRL »

Hi Robin,

I have found a small window in the sky to take some pictiures.

All of them are 16 bit

3X Exposures of 1 ,2 and 4 seconds
3X Exposures with Gain 60, 80 and 100
3X Exposures in focus, 150 steps off and 300 steps off
Total 18 scenarios

https://drive.google.com/drive/folders/ ... 01t_6lcLfm

Visualy I can see stars in all of them, using the Multy Star FWHM Transform it could not see any in most of them, too few in the rest

T&R
User avatar
admin
Site Admin
Posts: 13177
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: What am I doing wrong in Autofocus routine?

#5

Post by admin »

Hi,

thanks for taking the time to put these together. I have had a quick look and so far I would say that the shorter exposures/gains do not have bright enough stars for the star detection routines to pick them up - if you have to use the display histogram stretch to see the stars then they are not bright enough. For instance 1s gain 60 is pure black without any stretch applied.

The 100 gain frames taken at 2s and 4s exposures (with no offset) seem to produce reasonable results - for instance 100 gain, 4s gives me 43 detected stars with reasonable star detection settings (min width 1 px, digital gain off, min brightness 10%, max 96%, black threshold 10%, noise reduction 1.5). I think these settings should work. Note that SharpCap deliberately excludes fully saturated stars from the count and from measurement as it is not possible to correctly work out FWHM for a star that is saturated.

I am surprised that the addition of offset to these images causes problems - the number of stars is much lower in the 150 and 300 offset versions - I will have to investigate that further.

cheers,

Robin
JesusRL
Posts: 70
Joined: Wed Aug 05, 2020 4:36 pm
Location: Madrid

Re: What am I doing wrong in Autofocus routine?

#6

Post by JesusRL »

Hi Robin,

I think I have to excuse for the confusion in the term. Offset in terms of focus steps 150 and 300 steps out of focus.

I have added these images because stars must be found sligtly out of focus too

T&R
JesusRL
Posts: 70
Joined: Wed Aug 05, 2020 4:36 pm
Location: Madrid

Re: What am I doing wrong in Autofocus routine?

#7

Post by JesusRL »

Hi Robin,

Sorry if this can be found somewhere, I didn't.

I think that a good starting point from my side would be to clearly understand ALL the parameters that can affect star detection because this way I can create a valid environment to make proper images for it:

Can you please correct me in the missconceptions I may show here and fill the knowledge gaps I have?

* Black Threshold: not sure of what it means

* Noise reduction: I don't know how it is achieved

* Show: the algorith will use the best or average value at that point for curve estimation

* Average over: I am not sure on how this works, particularly considering its possible interaction with Samples To Collect within Options. If it does not interact whith options ... which one is used in AutoFocus?

* Min Star Width: I was surprised with your note in the previous response about using 1. Wouldn't this include hot pixels? I guess hot pixels can only be excluded as false positives using stars of width 2 or more

* Digital Gain: not sure of what it means

* Min Brightness: I understand it as percentage of the total bit depth of the camera. In my case 16bit 10% would be 6554. If my conception is correct ... can I achieve it by simply increasing the offset?

* Max Brightness: self explained by previous

Thank you for your patiente.

T&R
User avatar
admin
Site Admin
Posts: 13177
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: What am I doing wrong in Autofocus routine?

#8

Post by admin »

Ah, offset in terms of focal position offset, not camera control offset - right, that makes more sense :)


* Black Threshold: Pixels darker than this level are considered "black" (no signal) - set this to roughly the level of the histogram peak created by the dark background in the frame

* Noise reduction: Applies a gaussian blur to the image before detecting stars. Helpful for high noise (high gain) images and to reduce the detection of hot pixels as stars

* Average over: How many frames (or seconds) are averaged together to make a single measurement of the focus score. I think that if you set this to 2 frames and then tell the scan to collect 3 samples per position, it should take 3 samples * 2 frames per sample = 6 frames at each position. More useful for high speed imaging when using the contrast based focus measurements.

* Min Star Width: Can be used to exclude hot pixels if necessary, on the other hand with a large pixel size sensor and short focal length, some real stars might be excluded if set too low.

* Digital Gain: Apply a multiplication by this amount to pixel values before star detection - can help if the stars are all faint

* Min Brightness: Stars dimmer than this % (of the maximum pixel value) will not be considered for part of the FWHM measurement - if the maximum brightness is small then estimating the radius of half maximum is error prone

* Max Brightness: Stars brighter than this % will not be considered - The maximum brightness of a saturated or nearly saturated star is not a true reading, so estimating the FWHM may give wrong values.


I have a 'to-do' list item to try to simplify and improve star detection - I'd really like to find a way for most of the parameters that you now see to be set automatically. I'm going to have a look into starting writing the code for that soon.

cheers,

Robin
JesusRL
Posts: 70
Joined: Wed Aug 05, 2020 4:36 pm
Location: Madrid

Re: What am I doing wrong in Autofocus routine?

#9

Post by JesusRL »

Thank you for your extense explanation,

Having it all clear I think that the main issue I have is concerned to a single parameter:

I am using 16 bit CMOS cameras (ASI2600C & QHY268M) having very low noise and bias values. If you check my images have:
* For 1 sec gain 60 (the less signaled image in the set): - sky is average 525 - 0,8% of 65535
- 32 stars are above 1400 - 2% of 65535 - all below 6554 (10%)
* For 1 sec gain 60 OFF 150 (the less signaled image in the set out of focus 150): - sky is average 525 - 0,8% of 65535
- 12 stars are above 1400 - 2% of 65535 - all below 6554 (10%)

If the minimum brightness coul be setup at 1% instead of 10% (minimum possible) I could have plenty of valid stars.

Maybe it affects something else in your algorithm, but if it does not .. could this min be lowered?

Another thing I don't understand is what is the minimum number of starts and if it could be lowered for poorly populated star areas

T&R
User avatar
admin
Site Admin
Posts: 13177
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: What am I doing wrong in Autofocus routine?

#10

Post by admin »

Hi,

I've now spent quite a lot of time running tests on your images (they are *very* useful!). I have a much improved idea for the star detection algorithm that will do away with the necessity to set most of the parameters - I think there will be a 'sensitivity' slider and a 'suppress hot pixels' checkbox and that might be it.

Using a prototype of this code I can detect 20-30 stars in the '300off' images (at least the high gain/exposure ones). I'm going to continue working on this, since I think it will be a big improvement. It will take a while, since I also have to build a more reliable estimate for FWHM and make sure the new code works as well as the old in other images.

Thanks for the suggestion on dropping the minimum star count - I think it is probably the right thing to do - not sure whether to have an option or just to make it smaller anyway (sometimes too many options is a bad thing...)

Robin
Post Reply