A technique for binarization of video frames of microorganism movements

A.M. Lyakh, T.V. Rauen, V.S. Mukhanov

A.O. Kovalevsky Institute of Biology of the Southern Seas of RAS

RF, Sevastopol, Nakhimov Av., 2

E-mail: me@antonlyakh.ru

DOI: 10.33075/2220-5861-2023-2-116-122

UDC 579.087.3:004.932.4                                                                                          


   The trajectories of microorganism movements are one of the most accessible sources of data on their response to external conditions. Trajectories are studied using video records. Specialized tracking software processes the video material and builds trajectories, and we use mathematical methods to analyze trajectory characteristics and make conclusions about the dependence of microorganism movement patterns on the surrounding conditions.

   In this way, we make an attempt to identify the relationship between the movement patterns of the microscopic heterotrophic dinoflagellates Oxyrrhis marina and the presence or absence of available food. Unfortunately, video of the microorganism movements appears to be low-contrast and tracking programs are not able to correctly identify moving objects. Due to this reason, a script has been written to improve the visibility of moving objects. For that purpose, the script converts video to black and white (binary) format. With the help of FFmpeg the script cuts out video frames and, using ImageMagick, automatically processes them into binary format.

   As a result, the following sequence of ImageMagick commands produces high-quality binary frames: get source frame → extract red channel (-channel r -separate) → stretch histogram (-auto-level) → correct black and white levels and gamma (-level 70%,100%,3) → blurring (-blur 30) > negate (-negate) → use adaptive local thresholding (-lat 30×30+5%).

   The command sequence is written as an algorithm in the Windows batch file that allows any researcher to automatically improve the quality of video recordings and prepare them for subsequent extraction of the microorganism trajectories.

Keywords: digital image processing, trajectories of movement, histogram correction, local adaptive thresholding.

To quote: 

Full text in PDF(RUS)


  1. Nathan R., Getz W.M., Revilla E., et al. A movement ecology paradigm for unifying organismal movement research. PNAS, 2008, Vol. 105, No. 49, pp. 19052–19059.
  2. Holyoak M., Casagrandi R., Nathan R., Revilla E., and Spiegel O. Trends and missing parts in the study of movement ecology. PNAS, 2008, Vol. 105, No. 49, pp. 19060–19065.
  3. Wisnoski N.I. and Lennon J.T. Scaling up and down: movement ecology for microorganisms. Trends in Microbiology, 2023, Vol. 33, No. 3, pp. 242–253.
  4. Pennekamp F., Schtickzelle N., and Petchey O.L. BEMOVI, software for extracting behavior and morphology from videos, illustrated with analysis of microbes. Ecology and Evolution, 2015, Vol. 5, No. 13, pp. 2584–2595.
  5. Ershov D., Phan M.-S., Pylvanainen J.W., et al. TrackMate 7: integrating state-of-the-art segmentation algorithms into tracking pipelines. Nature Methods, 2022, Vol. 19, pp. 829–832.
  6. Pennekamp F., Clobert J., and Schtickzelle N. The interplay between movement, morphology and dispersal in Tetrahymena ciliates. PeerJ, 2019, No. 7, e8197.
  7. Bondoc-Naumovitz K.G., Laeverenz-Schlogelhofer H., Poon R.N., et al. Methods and measures for investigating microscale motility. arXiv, 2023, arXiv.2303.00068 [q-bio. CB].
  8. Kim J., Yuk B., Choi B., Yang M., Choi S., Lee K.-J., Lee S., and Heo T.-Y. New machine learning-based automatic high-throughput video tracking system for assessing water toxicity using Daphnia magna locomotory responses. Scientific Reports, 2023, Vol. 13, No. 1350, pp. 1–13.
  9. Lowe D. C., Keeling P. J., Martin L. E., et al. Who is Oxyrrhis marina? Morphological and phylogenetic studies on an unusual dinoflagellate.  Journal of  Plankton  Research,  2011,   Vol. 33,  No. 4, pp. 555–567.
  10. Montagnes D. J., Lowe C. D., Roberts E. C. et. al. An introduction to the special issue: Oxyrrhis marina, a model organism? Journal of Plankton Research, 2011, Vol. 33, No. 4, pp. 549–554.
  11. Roberts E. C., Wootton E. C., Davidson K. et al. Feeding in the dinoflagellate Oxyrrhis marina: linking behaviour with mechanisms. Journal of Plankton Research, 2011, Vol. 33, No. 4, P. 603–614.
  12. Rauen T.V., Mukhanov V.S., Baiandina Iu.S., and Lyakh A.M. Vliyanie mikroplastika na pischevuyu i dvigatelnuyu aktivnost dinoflagellyaty Oxyrrhis marina v eksperimente (Influence of microplastics on the nutritional and locomotive activity of dinoflagellate Oxyrrhis marina in the experiment). Biologiya vnutrennih vod. 2023. (In press).
  13. FFmpeg. A complete, cross-platform solution to record, convert and stream audio and video. Available at: https://ffmpeg.org/ (April 12, 2023).
  14. ImageMagick – Convert, edit, or compose digital images. Available at: https://imagemagick.org (April 12, 2023).
  15. An A-Z index of Windows CMD commands. Available at: https://ss64.com/nt/ (April 12, 2023).
  16. How to determine if image is dark? (high contrast, low brightness). Available at: https://stackoverflow.com/q/7935814/1615266 (April, 12, 2023).
  17. Skript dlya binarizatsii video dvizheniya mikroorganizmov (A script for binarising the video of microorganisms’ movement). Available at: https://antonlyakh.ru/done/mov2bin/ (April 13, 2023).