先上代码:
* This example program shows how to use optical_flow_mg to compute the optical flow in an image sequence and how to segment the optical flow. *这个示例程序显示了如何使用._flow_mg来计算图像序列中的光流,以及如何分割光流。 dev_update_off () dev_close_window () * Initialize the image sequence. 初始化图像序列 read_image (Image1, 'xing/xing000') dev_open_window_fit_image (Image1, 0, 0, -1, -1, WindowHandle) * Set the display parameters for the vector field. 设置现实的矢量场参数 dev_set_paint (['vector_field',6,1,2]) 定义灰度值输出模型, dev_set_draw ('margin') for I := 1 to 587 by 1 * Read the current image of the image sequence. 读连续的图像序列 read_image (Image2, 'xing/xing'+I$'03') * Compute the optical flow. 计算光流 optical_flow_mg (Image1, Image2, VectorField, 'fdrig', 0.8, 1, 8, 5, 'default_parameters', 'accurate') *计算两幅图片的光流场。 参数:1&2是输入的两个单色图片序列的连续图片, 3为输出的光流结果 4是求取光流三种算法的选取其中的一种 5高斯平滑初始偏差初始值 6积分滤波偏差初始值 7平滑项在数据项中的权重 8梯度恒定性相对于灰度值恒定性的权重 9多栅算法的名字 10多栅算法的变量 * Segment the optical flow vector field. 分割矢量场 threshold (VectorField, Region, 1, 10000) * Display the current image of the sequence. Note that this means that the optical flow vectors will also be displayed at the "end" of the movementof the objects in the image. 显示序列的当前图像。注意,这意味着光流矢量也将显示在图像中物体运动的“末端”。 dev_display (Image2) * Display the optical flow. dev_set_color ('yellow') dev_set_line_width (1) dev_display (VectorField) * Display the segmented optical flow. dev_set_color ('green') dev_set_line_width (3) dev_display (Region) * Copy the current image to the previous image of the sequence. *将当前图像复制到序列的前一个图像。 copy_obj (Image2, Image1, 1, 1) endfor
背景介绍
本文出自勇哥的网站《少有人走的路》wwww.skcircle.com,转载请注明出处!讨论可扫码加群:


