# A Low-Cost Automated Digital Microscopy Platform for Automatic Identification of Diatoms
## 2 Materials and Methods
### Automatic Slide Scanning  
In many studies where diatoms are involved, counting the number of specimens in a sample represents a very time-consuming task. For instance, the European Standard for quality assessment based on diatoms indexes requires at least counting 400 valves in a sample [20]. The counting task cannot be fully achieved by exploring a single field of view (FOV) captured from the slide; hence, a complete slide observation should be carried out. At times when the distribution of diatoms in the sample is approximately uniform, some diatomists suggest a random subsampling of the slide to reduce the time for counting. In any case, this tedious task can be alleviated by the automatic scanning of the slide to get a complete image with the interesting specimens in the sample. In order to cope with the automatic slide scanning task, several steps should be carried out:  
* Motor calibration: Stage and focus motions are achieved by controlling the stepper motors linked to the X-Y knobs in the stage and the focus Z axis. An essential aspect for the microscope's automation is to calibrate these motors to establish the rate of X-Y and Z displacement corresponding to a single turn step of each motor. * Image calibration: This establishes the relation between image pixels and the true distance (i.e., pixels/\(\upmu\)m), also known as image resolution. This calibration is carried out by using a scaled slide with a known distance between consecutive divisions. Image calibration is used later to add a ruler on the image corresponding to the scale of the displayed specimens in the slide. Table 1 shows how image spatial resolution and FOV size are affected by the objective magnification. * Scanning: Since it is impossible to observe the whole slide in a single FOV, it is imperative to look over the entire slide, taking successive captures (i.e., scanning the slide). There are several strategies to deal with the scanning of the slide depending on: (a) the position of successive captures at each FOV center and (b) the path followed to reach consecutive points for image acquisition. Figure 6 illustrates three possible strategies. In Figure 6a, the whole slide is divided into an array of FOVs covered by a snake-by-row path. Figure 6b shows a row-by-row path with image acquisition in the same direction. Finally, Figure 6c shows scanning based on regions of interest (ROIs) covered by a heuristic path driven by the closest uncovered FOV. This third strategy could be appropriate in cases with very few ROIs where their discovery is compensated by the time saved in acquiring fewer images. The design of an optimal scanning \begin{table}
\begin{tabular}{c c c} \hline
**Objective** & **Res. (pixels/\(\upmu\)m)** & **FOV Size (mm\({}^{2}\))** \\ \hline
4\(\times\) & 0.54 & 4.485 \\
20\(\times\) & 2.66 & 0.179 \\
40\(\times\) & 5.39 & 0.042 \\
60\(\times\) & 7.91 & 0.018 \\ \hline \end{tabular}
\end{table} 
Table 1: Image resolution and FOV size depending on the objective magnification—using the UI-1240 LE-C-HG camera by IDS. strategy should consider the extra time needed for the steady stop of the stage to avoid blurry images. It is important to notice the inherent difficulty in controlling the two stepper motors simultaneously--corresponding to X-Y motions--to obtain the desired trajectory. * Autofocus: Automatic scanning relies on capturing multiple images over one single slide. As the FOV changes from one capture to the other, dynamic focus adaptation is eventually needed. There are different methods to measure the focus level in an image based on calculating gradients (i.e., derivative operators) over the image. The idea underlying autofocus algorithms based on derivative operators is that focused images have fewer levels of grey variability (i.e., sharper edges) and therefore higher frequency components than unfocused images.