nanophotonics / nplab

Core functions and instrument scripts for the Nanophotonics lab experimental scripts
GNU General Public License v3.0
38 stars 15 forks source link

Lab 3 Microscope Autofocus #47

Closed car72 closed 4 years ago

car72 commented 7 years ago

When using particle_scanner.py, autofocus works fine when autofocus button is pressed, but not during particle tracking itself. The program then fails to properly centre on the nanoparticle before taking spectra.

eoinell commented 4 years ago

This is often the result of bright spots on the sample confusing the merit function for focus. It uses contrast between neighbouring pixels, however when there's a saturated area, the contrast between this area and the dark background dominates. When you defocus, this saturated area (and circumference) grows, and so does the amount of 'contrast', contrary to what would happen in an unsaturated, or bright-field image. Confining the area of focus to the region just around the nanoparticle to exclude these spots however should (and seems to) alleviate this:

def thumb_autofocus(): CWL.autofocus(use_thumbnail = True)

then add thumb_autofocus to the task list instead of autofocus.

Playing with the exposure can also help.