这个示例程序展示了如何使用optical_flow_mg计算图像序列中的光流以及如何分割光流。
Optical_flow_mg计算两个图像之间的光流。光流表示单眼图像序列的两个连续图像之间的运动信息。图像中的移动可以由世界中移动的物体引起,也可以由相机(或两者)在获取两个图像之间的移动引起。这些3D运动投射到2D图像平面的过程称为光流。
optical_flow_mg (Image1, Image2, VectorField, 'fdrig', 0.8, 1, 8, 5, 'default_parameters', 'accurate')
optical_flow_mg -计算两个镜像之间的光流。
optical_flow_mg(ImageT1, ImageT2 : VectorField : Algorithm, SmoothingSigma, IntegrationSigma, FlowSmoothness, GradientConstancy, MGParamName, MGParamValue : )
ImageT1,T2:输入的两张图像
VectorField:光流
Algorithm:光流计算算法。clg、ddraw、fdrig
SmoothingSigma:初始高斯平滑标准差
IntegrationSigma:积分滤波器的标准差
FlowSmoothness:平滑项相对于数据项的权重。
GradientConstancy:梯度常数相对于灰度值常数的权重。
MGParamName:多网格算法的参数名称
MGParamValue:多网格算法的参数值
grab_image (ImageT1, AcqHandle)
while (true)
grab_image (ImageT2, AcqHandle)
optical_flow_mg (ImageT1, ImageT2, VectorField, 'fdrig', 0.8, 1, 10, \
5, 'default_parameters', 'accurate')
threshold (VectorField, Region, 1, 10000)
copy_obj (ImageT2, ImageT1, 1, 1)
endwhile