# image processing - How to calculate derivative with respect to time for Optical Flow

Suppose we have 2 images in motion for detecting the object in movement according to Lucas and Kanade [u, v] = inv(H)*[dxdt, dydt] where H is the Hessian for partial derivatives for image x and y direction dxdx, dxdy, dydx, dydy.

I know for partial derivatives with respect to x a y we need to just use the following formula for derivatives

dx = (img[i-1] - img[i+1]) / 2;

dy = (img[j-1] - img[j+1]) / 2;

but I also need to calculate the derivative for time t as we are given 2 frames in space time, I was thinking it might be smth. like this:

dz = (img1[i] - img1[i]) / 2;

But I am not sure exactly, can anyone suggest me an idea ?

In order to estimate the temporal derivative you can use:

• the simple differenz operater f'(x) = f(x-1) - f(x) or
• the double-sided as you did for the spatial gradiends f'(x) = (f(x-1) - f(x+1)) / 2.

The result will be dz = img1(i,j)-img2(i,j) or dz = (img1(i,j) - img3(i,j)) / 2, where img3 ,img2 and image 1 are consequtive caputred frames. However for practical reasons the simple differenz operator is often used.