'Weighted Lucas Kanade - Gaussian Function MATLAB

I implemented the Basic Lucas Kanade Optical Flow algorithm in Matlab. I used the algorithm from Wikipedia.

Since I want to improve this Basic optical flow algorithm, I tried adding a weightening function which makes certain Pixels in the beighbourhood more important or less important (see also Wikipedia).

I basically calculated the following for every Pixel in the beighbourhood and the Center Pixel itself.

for: Center Pixel and every neighbourhood-pixel
sigma = 10;
weight(s) = (1/(2*pi*sigma^2)) * exp(-((first-x)^2+(second-y)^2)/(2*sigma^2))

x,y ist the Center Point pixel, it always stays the same. first,second is the current neighbourhood-pixel Since I am using a 5x5 neighbourhood, (first-x) or (second-y) will always be one of these: "0,1,-1,2,-2"


I then apply the weight-values in each part of the sum.


Problem: With Sigma = 10 I don't get a better result for the optical flow than without the weightening function. With smaller Sigmas it's not better. Afterall there is no difference between the Output vectors with or without the gaussian function

Is there a way to improve this Gaussian function to actually make the vectors more acurate than without weightening?

Thank you sooo much.



Solution 1:[1]

I'm not sure how you apply the values, but it usually should make a little difference.

For a better optical flow you could :

  • presmooth the images with a gaussian
  • use a spatiotemporal Lucas-Kanade method
  • or use a more advanced algorithm

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 General Grievance