Difference between revisions of "Team:Cambridge-JIC/Autofocus"
KaterinaMN (Talk | contribs) |
|||
Line 64: | Line 64: | ||
<li><p><b>Delays from moving the motor to receiving an updated frame</b> - this is a common issue with feedback loops, everywhere from biological systems to adjusting the temperature of the shower. Failure to deal with this can result in <b>oscillations</b> around the set point, with the image remaining just out of focus most of the time. We dealt with this by introducing a delay between sending a "move motor" command and a "read focus score" command to attempt to match the two. Reading a focus score when the motors were no longer moving is not an issue, but reading a value before the desired position has been reached is. Thus, it is beneficial to err on the side of an increased counter-delay, though at the expense of the time for autofocus to take place.</p></li> | <li><p><b>Delays from moving the motor to receiving an updated frame</b> - this is a common issue with feedback loops, everywhere from biological systems to adjusting the temperature of the shower. Failure to deal with this can result in <b>oscillations</b> around the set point, with the image remaining just out of focus most of the time. We dealt with this by introducing a delay between sending a "move motor" command and a "read focus score" command to attempt to match the two. Reading a focus score when the motors were no longer moving is not an issue, but reading a value before the desired position has been reached is. Thus, it is beneficial to err on the side of an increased counter-delay, though at the expense of the time for autofocus to take place.</p></li> | ||
<li><p><b>Unreliability of motor positioning</b> - when moving +400 steps and then -400 steps, there is no guarantee of returning to exactly the same position.</p></li> | <li><p><b>Unreliability of motor positioning</b> - when moving +400 steps and then -400 steps, there is no guarantee of returning to exactly the same position.</p></li> | ||
− | <li><p><b>Local maxima not being the global maxima</b> - A more theoretical issue than the practical ones above. Once reaching an area of high focus value, there is little guarantee that this is the most focused plane in the image. This is in contrast to the issue above - if we "give up" an area of high focus, we may find it difficult to retrieve it. We ignored this issue in favour of the more practical ones above - attempting to account for global maxima of focus scores would require the autofocus procedure to be far longer than desirable. We also implemented a naive threshold to stop moving the z axis once the focus was "good enough", a value for which | + | <li><p><b>Local maxima not being the global maxima</b> - A more theoretical issue than the practical ones above. Once reaching an area of high focus value, there is little guarantee that this is the most focused plane in the image. This is in contrast to the issue above - if we "give up" an area of high focus, we may find it difficult to retrieve it. We ignored this issue in favour of the more practical ones above - attempting to account for global maxima of focus scores would require the autofocus procedure to be far longer than desirable. We also implemented a naive dynamic threshold to stop moving the z axis once the focus was "good enough", a value for which is empirically derived.</p></li> |
<li><p><b>We settled for a hill-climbing approach</b>. Imagining the theoretical focus score for all possible z values on a graph may look like a hill. This algorithm attempts to "climb" that hill of focus scores. This algorithm assesses the focus scores of individual frames, moving in the direction where the focus is increasing. If the focus decreases, the motors are reversed in smaller increments. This process is repeated several times until an exit condition is reached.</p></li> | <li><p><b>We settled for a hill-climbing approach</b>. Imagining the theoretical focus score for all possible z values on a graph may look like a hill. This algorithm attempts to "climb" that hill of focus scores. This algorithm assesses the focus scores of individual frames, moving in the direction where the focus is increasing. If the focus decreases, the motors are reversed in smaller increments. This process is repeated several times until an exit condition is reached.</p></li> | ||
</ul> | </ul> | ||
Line 82: | Line 82: | ||
<p>The autofocus algorithm we have implemented is open for further improvements and performance enhancement. Ideas for future development include:</p> | <p>The autofocus algorithm we have implemented is open for further improvements and performance enhancement. Ideas for future development include:</p> | ||
<ul> | <ul> | ||
− | <li><p>A | + | <li><p>A better hill climbing algorithm for finer focus after reaching the "almost focussed stage"</p></li> |
<li><p>Automatic measurement of the actual height to the CCD</p></li> | <li><p>Automatic measurement of the actual height to the CCD</p></li> | ||
<li><p>More reliable motors use to improve precision</p></li> | <li><p>More reliable motors use to improve precision</p></li> |
Revision as of 22:50, 18 September 2015