Difference between revisions of "Team:Cambridge-JIC/Autofocus"
K.armfield.1 (Talk | contribs) |
K.armfield.1 (Talk | contribs) |
||
Line 43: | Line 43: | ||
<li><p>Focus stacking - for imaging 3-dimensional objects</p></li> | <li><p>Focus stacking - for imaging 3-dimensional objects</p></li> | ||
</ul> | </ul> | ||
− | <p>Last, but not least, autofocus simply facilitates the work of the person operating OpenScope. Manual focusing, although not very challenging, might still be fiddly, | + | <p>Last, but not least, autofocus simply facilitates the work of the person operating OpenScope. Manual focusing, although not very challenging, might still be fiddly, particularly to inexperienced users. This is where the autofocus algorithm comes in. Various methods for performing this task were tried, and the best methods were used in the final version (although the rest of the code is present in our source code).</p> |
</div></div></section> | </div></div></section> | ||
Line 50: | Line 50: | ||
<div style="width: 100%; padding: 0% 10%; margin: 30px 0px;color:#000"> | <div style="width: 100%; padding: 0% 10%; margin: 30px 0px;color:#000"> | ||
<h3>The Solution</h3> | <h3>The Solution</h3> | ||
− | <p>The strategy of the autofocus algorithm is to calculate the <b>focus score</b> for each frame imaged while gradually changing the sample-objective distance | + | <p>The strategy of the autofocus algorithm is to calculate the <b>focus score</b> for each frame imaged while gradually changing the sample-objective distance. The most sharply focused image is the result of a maximised focus score. The physics behind the process is very simple: the image of an object, viewed through a lens, is produced at a particular distance from the lens. At any shorter/longer distance from the lens, the light rays from a single point on the object do not converge into a point, causing the image to be blurred. The focus score can be simply regarded as a mathematical function with a single maximum.</p> |
<center><img src="//2015.igem.org/wiki/images/e/e5/CamJIC-Software-Autofocus-Focusing.png" style="width:40%;margin:10px"> <img src="//2015.igem.org/wiki/images/a/a8/Focusing.gif" style="width:40%;margin:10px"><p><i><b>Fig, 1:</b> The plot shows the focus score of an image as a function of the distance between the objective and the sample: it is clear that the function has a single maximum. The corresponding images recorded at these distances are also shown. Note that most of the time during the search, the sample remains significantly out-of-focus.</i></p></center> | <center><img src="//2015.igem.org/wiki/images/e/e5/CamJIC-Software-Autofocus-Focusing.png" style="width:40%;margin:10px"> <img src="//2015.igem.org/wiki/images/a/a8/Focusing.gif" style="width:40%;margin:10px"><p><i><b>Fig, 1:</b> The plot shows the focus score of an image as a function of the distance between the objective and the sample: it is clear that the function has a single maximum. The corresponding images recorded at these distances are also shown. Note that most of the time during the search, the sample remains significantly out-of-focus.</i></p></center> | ||
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 | + | <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 was empirically derived. Future work may wish to extend this to a dynamically calculated value or to characterise most-in-focus scores for many other types of samples.</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 | + | <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> | ||
Revision as of 10:10, 18 September 2015