views:

57

answers:

2

Okay, I am looking for something akin to integral images (summed area tables) as used in the acceleration of integral calculations over a window.

I have an image I and its gradient image G. I want to calculate the straight line integral from two arbitrary points a and b in the image of the absolute value of G. Obviously I can step over the line (1-t)a + t*b, t in [0, 1] and sum up given the right t step size. I want, however, to do this several million times so I would like some acceleration structure that preferably doesn't require me to run a loop for every pair (a, b).

Does anyone know of an existing algorithm to accomplish this sort of thing?

A: 

I think the answer is no. If you were to integrate the gradient and not its absolute value, it would be trivial though.

I would have another concern though: How do you interpolate on G ? You'll have pixel values, and the sampling points you'll use to compute the integral won't generally fall exactly on pixels. Either "pick the closest pixel value" or "interpolate between the four neighbors" will do. The latter is more precise, the former is faster.

Since |G| is likely not to be smooth, you'll have no choice but (expensive) trapezoidal rule for integration.

EDIT: Look at Bresenham's algorithm. Since you won't be interpolating, it should provide useful optimization.

Alexandre C.
Yeah, that is what I was afraid of. Thanks Alexandre, I'll leave it unanswered for a day or two just in case someone knows some crazy algorithmic technique. As to your question about interpolating on G, this doesn't need to be a very exact calculation so I am planning to just rasterize the line between the points and sum the values of all line pixels.
quadelirus
@quadelirius: see my edit since you won't interpolate.
Alexandre C.
The trapezoidal rule doesn't have to be expensive. See my post for a good optimization.
Stargazer712
@Stargazer: it will be more expensive than Gauss-Legendre, Simpson or Romberg, even if done properly (eg. adaptively), since there is a lack of regularity. That is what I meant by "expensive".
Alexandre C.
+1  A: 

You seem to know your math, so I'll suggest the adaptive quadrature algorithm.

It is most commonly used for calculating simple 2D integrals efficiently, but you can probably put it to good use for what you are working on.

Stargazer712