﻿ 斑马鱼行为学自动观测装置关键算法研究
 光电工程  2018, Vol. 45 Issue (8): 180101      DOI: 10.12086/oee.2018.180101

School of Electrical Engineering and Information, Sichuan University, Chengdu, Sichuan 610065, China
Mo Site, Liu Tianqi, He Ling
School of Electrical Engineering and Information, Sichuan University, Chengdu, Sichuan 610065, China
Abstract: Studies on the zebrafish behavior have attracted more and more attention. The algorithm of 3D coordinate calculation is the basis of zebrafish behavioral analysis. An automatic device for observing the behavior of zebrafish was designed based on binocular stereo vision technology. According to methods of p-rate threshold and pattern threshold, the image threshold algorithm was proposed. Horizontal X and Y coordinates of single zebrafish were figured out by calculating the average of pixel coordinates of image contour. If the difference of Y coordinate values among different zebrafishes is large, two groups of zebrafishes captured by two cameras will be set up separately according to the Y coordinate values, and the same serial number in two groups means the same target. If the difference of Y coordinate is small, the same target in different cameras was identified by the method of minimum distance. The formula of three-dimensional coordinates was conducted based on the refraction theorem and the structure of the observation device. Algorithm analysis shows that the running time of the algorithm proposed in the paper is saved. Validating testing to a number of fishes is designed and carried out to show that the calculated coordinates are close to the preset locations.
Keywords: zebrafish behavior    binocular stereo vision    three-dimensional coordinate

1 引言

2 斑马鱼行为学自动观测装置组成结构

 图 1 斑马鱼行为学自动观测装置组成结构 Fig. 1 Structure of the automatic device for observing the behavior of zebrafish

3 斑马鱼三维坐标计算

3.1 单条斑马鱼水平二维坐标的确定

3.1.1 图像阈值化

 图 2 图像阈值化算法流程图 Fig. 2 Flow chart of image threshold algorithm
3.1.2 斑马鱼平面坐标点计算方法

 图 3 斑马鱼平面坐标算法流程图 Fig. 3 Flow chart of zebrafish plane coordinate algorithm
3.2 两个摄像机中同一条斑马鱼的辨别

 $d = \sum\limits_{i = 1}^{2a} {\sum\limits_{j = 1}^{2a} {\left| {A(i, j) - B(i, j)} \right|} } ,$ (1)

3.3 三维坐标计算方法

 图 4 三维坐标示意图 Fig. 4 Diagram of three-dimensional coordinates

3.3.1 根据右边摄像机确定鱼所在的直线

 $\left\{ {\begin{array}{*{20}{l}} {{T_x} = \left( {{R_x} - \frac{M}{2}} \right) \times w \times \frac{h}{f}} \\ {{T_y} = \left( {{R_y} - \frac{N}{2}} \right) \times w \times \frac{h}{f}} \end{array}} \right.。$ (2)

 $\theta = \arcsin \frac{{\sqrt {T_x^2 + T_y^2} }}{{1.33 \times \sqrt {T_x^2 + T_y^2 + {h^2}} }}。$ (3)

 ${P_x} = \tan \theta \frac{{{T_x}}}{{\sqrt {T_x^2 + T_y^2} }},$ (4)
 ${P_y} = \tan \theta \frac{{{T_y}}}{{\sqrt {T_x^2 + T_y^2} }},$ (5)

 $\left\{ \begin{array}{l} x = {T_x} + c + t{P_x} \hfill \\ y = {T_y} + t{P_y} \hfill \\ z = t \hfill \\ \end{array} \right.。$ (6)
3.3.2 根据左边摄像机确定鱼所在的平面

 $\left\{ {\begin{array}{*{20}{l}} {{S_x} = \left( {{L_x} - \frac{M}{2}} \right) \times w \times \frac{h}{f}} \\ {{S_y} = \left( {{L_y} - \frac{N}{2}} \right) \times w \times \frac{h}{f}} \end{array}} \right.。$ (7)

 $\left| {\begin{array}{*{20}{l}} {\mathit{\boldsymbol{i}}}&{\mathit{\boldsymbol{j}}}&{\mathit{\boldsymbol{k}}} \\ 0&0&1 \\ {{S_x}}&{{S_y}}&0 \end{array}} \right|。$ (8)

 $- {S_y} \times (x + c - {S_x}) + {S_x}(y - {S_y}) = 0。$ (9)

 $- {S_y} \times (x + c) + {S_x} \times y = 0。$ (10)
3.3.3 确定鱼的坐标

 $\left\{ {\begin{array}{*{20}{l}} {x = \frac{{{x_1} + {x_2}}}{2}} \\ {y = \frac{{{y_1} + {y_2}}}{2}} \\ {z = \frac{{{z_1} + {z_2}}}{2}} \end{array}} \right.。$ (11)
4 算法分析

1) 阈值计算

2) 斑马鱼平面坐标点计算方法

3) 同一斑马鱼的识别

5 实验验证

 设置坐标/mm 计算坐标/mm 计算误差/mm X Y Z X Y Z X Y Z 1号鱼 84 -59 -82 96 -56 -88 12 3 -6 2号鱼 -33 -29 -44 -25 -31 -48 8 -2 -4 3号鱼 -77 64 -111 -77 70 -112 0 6 -1 4号鱼 -29 -96 -28 -31 -96 -33 -2 0 -5 5号鱼 -121 -91 -103 -123 -94 -96 -2 -3 7

 开始坐标/mm 结束坐标/mm 方向 距离/mm 速度/(mm·s-1) 行为 X0 Y0 Z0 X1 Y1 Z1 α β 第1次 -4 3 -140 100 0 -145 -2 -2 104 20.7 向右 第2次 9 -1 -155 -90 3 -155 177 0 98 19.7 向左 第3次 5 5 -145 8 101 -140 91 3 97 19.3 向前 第4次 5 -8 147 5 -106 -151 269 -3 98 19.7 向后 第5次 -1 -6 -159 2 -3 -62 51 87 103 20.7 向上
 $\alpha {\rm{ = }}\left\{ {\begin{array}{*{20}{l}} {\begin{array}{*{20}{l}} {\arctan \frac{{{y_1} - {y_0}}}{{{x_1} - {x_0}}}}&{\begin{array}{*{20}{l}} {}&{} \end{array}{x_1} - {x_0} \geqslant 0} \end{array}} \\ {\begin{array}{*{20}{l}} {{\rm{180}} - \arctan \frac{{{y_1} - {y_0}}}{{{x_1} - {x_0}}}}&{{x_1} - {x_0} < 0} \end{array}} \end{array}} \right.,$ (12)
 $\beta {\rm{ = }}\arcsin \frac{{{z_1} - {z_0}}}{{\sqrt {{{({x_1} - {x_0})}^2} + {{({y_1} - {y_0})}^2} + {{({z_1} - {z_0})}^2}} }}。$ (13)

6 结论及展望

 [1] Zon L I, Peterson R T. In vivo drug discovery in the zebrafish[J]. Nature Reviews Drug Discovery, 2005, 4(1): 35-44. DOI:10.1038/nrd1606 [2] Sun Z H, Jia S J, Meng A M. Zebrafish: swimming in life sciences[J]. Chinese Bulletin of Life Sciences, 2006, 18(5): 431-436. 孙智慧, 贾顺姬, 孟安明. 斑马鱼:在生命科学中畅游[J]. 生命科学, 2006, 18(5): 431-436. [3] Wang Y X, Zhong T, Song H Y. Advances in genetics of zebrafish development[J]. Section of Genetics Foreign Medical Sciences, 2004, 27(4): 220-223. 王跃样, 钟涛, 宋后燕. 斑马鱼发育遗传学研究进展[J]. 国外医学遗传学分册, 2004, 27(4): 220-223. [4] Linney E, Upchurch L, Donerly S. Zebrafish as a neurotoxicological model[J]. Neurotoxicology and Teratology, 2004, 26(6): 709-718. DOI:10.1016/j.ntt.2004.06.015 [5] Shin J T, Fishman M C. From zebrafish to human: modular medical models[J]. Annual Review of Genomics and Human Genetics, 2002, 3: 311-340. DOI:10.1146/annurev.genom.3.031402.131506 [6] Ma J J, He Z X, Shu L P, et al. Expression of HOXC4 gene during early development in zebrafish[J]. Journal of Sichuan University (Medical Science Edition), 2013, 44(3): 371-374. 马健娟, 何志旭, 舒莉萍, 等. HOXC4基因在斑马鱼早期胚胎发育过程中的表达[J]. 四川大学学报(医学版), 2013, 44(3): 371-374. [7] Engeszer R E, Ryan M J, Parichy D M. Learned social preference in zebrafish[J]. Current Biology, 2004, 14(10): 881-884. DOI:10.1016/j.cub.2004.04.042 [8] Vitebsky A, Reyes R, Sanderson M J, et al. Isolation and characterization of the laure olfactory behavioral mutant in the zebrafish, Danio rerio[J]. Developmental Dynamics, 2005, 234(1): 229-242. DOI:10.1002/(ISSN)1097-0177 [9] Gil Barcellosa L J, Rittera F, Kreutz L C, et al. Whole-body cortisol increases after direct and visual contact with a predator in zebrafish, Danio rerio[J]. Aquaculture, 2007, 272(1-4): 774-778. DOI:10.1016/j.aquaculture.2007.09.002 [10] Kily L J M, Cowe Y C M, Hussain O, et al. Gene expression changes in a zebrafish model of drug dependency suggest conservation of neuro-adaptation pathways[J]. Journal of Experimental Biology, 2008, 211(10): 1623-1634. DOI:10.1242/jeb.014399 [11] Fang F, Yu L Z. Zebrafish-A model organism that can be used to study biological medicine anxiolytics[J]. Pharmacology and Clinics of Chinese Materia Medica, 2011, 27(1): 104-106. 方芳, 余林中. 斑马鱼——一种可用于中药抗焦虑药研究的模式生物[J]. 中药药理与临床, 2011, 27(1): 104-106. [12] Wang Z, Pu Y Z, Chen Y J, et al. Influence of dichlorvos on zebrafish behavior[J]. Journal of International Pharmaceutical Research, 2013, 40(3): 327-330. 王卓, 蒲韵竹, 陈怡君, 等. 敌敌畏对斑马鱼运动行为的影响[J]. 国际药学研究杂志, 2013, 40(3): 327-330. [13] Huang W Y, Xu X M, Wu F Q, et al. Research of underwater binocular vision stereo positioning technology in nuclear condition[J]. Opto-Electronic Engineering, 2016, 43(12): 28-33. 黄文有, 徐向民, 吴凤岐, 等. 核环境水下双目视觉立体定位技术研究[J]. 光电工程, 2016, 43(12): 28-33. DOI:10.3969/j.issn.1003-501X.2016.12.005 [14] Liu J, Fu W P, Wang W, et al. Image matching based on improved SIFT algorithm[J]. Chinese Journal of Scientific Instrument, 2013, 34(5): 1107-1112. 刘佳, 傅卫平, 王雯, 等. 基于改进SIFT算法的图像匹配[J]. 仪器仪表学报, 2013, 34(5): 1107-1112. [15] Xu Y X, Chen F. Real-time stereo visual localization based on multi-frame sequence motion estimation[J]. Opto-Electronic Engineering, 2016, 43(2): 89-94. 许允喜, 陈方. 基于多帧序列运动估计的实时立体视觉定位[J]. 光电工程, 2016, 43(2): 89-94. DOI:10.3969/j.issn.1003-501X.2016.02.015 [16] Bai T Z, Hou X B. An improved image matching algorithm based on SIFT[J]. Transactions of Beijing Institute of Technology, 2013, 33(6): 622-627. 白廷柱, 侯喜报. 基于SIFT算子的图像匹配算法研究[J]. 北京理工大学学报, 2013, 33(6): 622-627. [17] Mo S T, Li B X. Design of analog front end circuit for ICX274 based on AD9923A[J]. Opto-Electronic Engineering, 2009, 36(10): 141-145. 莫思特, 李碧雄. 基于AD9923A的ICX274模拟前端电路设计[J]. 光电工程, 2009, 36(10): 141-145. DOI:10.3969/j.issn.1003-501X.2009.10.027 [18] Mo S T, Wu Z H. Design of 2.0 mega pixels digital video camera and key technology[J]. Opto-Electronic Engineering, 2009, 36(5): 117-121. 莫思特, 吴志红. 200万像素数字摄像机设计及关键技术研究[J]. 光电工程, 2009, 36(5): 117-121. DOI:10.3969/j.issn.1003-501X.2009.05.022