-2

I have a few double integrals that I have to approximate that are based on getting motion parameters from a sequence of images, and I have chosen to use Riemann Sums for that purpose. These integrals are under the domain R = [-w,w]x[-h,h], where 2w and 2h are the image width and height respectively. What would be the appropriate number of subdivisions m and n that I can give so that I can use code to evaluate them in any case? I am confused as we don't have access to all values of x_ij and y_ij as m and n increases.

I was thinking of considering each of the image frames as my grid of values, but I don't know what each of the pixel width and height would be. I am not even sure if this is the correct approach to approximating the integrals, so please suggest if there are other appropriate ways.

Here is one of the integrals that I am approximating:-

∫∫((u-ur)β - (v - vr)α)(-xyβ + (y^2 + 1)α)dxdy

  • One approach would be to use the divisors of 2w and 2h for the number of width and height divisions respectively. When are those divisions small enough to give you your desired accuracy? That depends on the data and your requirements, and even then, there's no easy way to be sure what division sizes are adequate. One simple approach is to calculate the integral with increasing data points until the change from the previous result is sufficiently small. There is the chance that doingthis could return the wrong amount though. – Simon Goater May 21 '23 at 10:52
  • If you're calculating many integrals, the chance of them all giving similar to the previous iteration but incorrect results is smaller than if you were calculating just one. If the result doesn't converge on zero, you can just compare ratios and stop when abs(R_(i+1)/R_i) < epsilon (e.g. 0.0001). – Simon Goater May 21 '23 at 10:58

1 Answers1

0

If the cost of integrating is not too high, you can compute the integral exactly. Otherwise, you can decouple the problem:

  • Approximate the double integral over the continuous domain to the precision you can afford
  • Resolve location of quadrature points on the discrete domain

For the first part, there are many quadrature schemes you can use. A very simple but already better than Riemann sums is the trapezoid rule. Especially since your function is a step-function of sorts (piecewise-constant).

In practice, integrating exactly will be cheaper than generating those images, and probably even than reading them from disk (which you presumably have to do). So let's say you want to compute the integrals exactly. A function defined over the pixels writes

with chi the indicatrix function. The x_i, y_i are the coordinates of your pixel corners. What do you want to map those to? I would propose a scheme where the image size is invariant w.r.t. pixel count, such as any:

with W the width and H the height (here 2w and 2h). This is up to your problem definition, you can change it for other values as needed. Now, for all i,j,

so your integral over the entire domain is simply

This is the exact integral of a quantity defined pixel-by-pixel.

Sardine
  • 153
  • 5