# Can I compute this integral analytically?

1. Jun 2, 2014

### pamparana

I will give a small background and explain the variables and the system first. I have two images which are observed and are constant and we can treat them as continuous functions and I will call them $r$ and $f$. In my problem, I am trying to find a continuous transform (which is very non-linear) that makes $f$ looks like $r$ according to some similarity criteria or cost function. I will call this transformation function $t$ and I am trying to estimate its parameters $w$.

So, the integral I need to compute turns out to be

$Z = \int_{-\infty}^{\infty} \exp-{\frac{\left( r(i) - f\left(t(w)\right)\right)^2}{2\sigma^2}} \, dw$

where $\sigma$ is a constant. Now, given a constant linear function $A$, $f(t(w))$ is computed as:

$f(t(i, w)) = (\lceil{Aw}\rceil - Aw) * f(\lfloor{Ax}\rfloor) + (Aw - \lfloor{Aw}\rfloor) * f(\lceil{Ax}\rceil)$

where $\lceil \rceil$ gives the ceiling function and $\lfloor \rfloor$ is the floor function. This basically means that I am using linear interpolation to make the transformation function continuous. This is because the images and the transformation are defined in the digital domain and are computed only on a uniform grid (corresponding to the pixel locations) and the transformation $t$ is telling me what the location of a pixel $i$ in image $r$ is in image $f$ through $w$.

Can someone tell me if I can compute such an integral? My first instinct was to use Taylor series to linearise $t(w)$ but it was pointed out that it is not a good idea as $t(w)$ is in the integral and we are integrating over $w$. So the higher order terms will not cancel out and I cannot justify that approximation.

My Maths and Calculus skills are not great at all. Please do let me know if I need to generate more information about $t$ to be able to do this integration.

Last edited: Jun 2, 2014
2. Jun 4, 2014

### Stephen Tashi

I don't understand the relation between $i$ and $w$. If $w$ are the parameters of the transformation then they are presumably constant, so what is the meaning of an integration with respect to $dw$ ?

3. Jun 4, 2014

### pamparana

They are transformation parameters but are treated as random variables and hence have a distribution associated with them. I am trying to compute the posterior distribution associated with the transformation parameters $w$ i.e. $P(w)$. So the integral expression comes from the bayesian normalisation as explained here: http://en.wikipedia.org/wiki/Normalizing_constant

I am basically integrating over all possible states that the random variable $w$ can take.

4. Jun 4, 2014

### Stephen Tashi

Humor me and explain this in terms of my own notation.

Assume we have 2 dimensional images and that vaiables $(x,y)$ give the location of a pixel. The images are $f(x,y)$ and $r(x,y)$.

When we speak of transforming $f$ to make it look like $r$, what variables give the domain of the transformation?

For example,

We might transform $f$ only by transforming pixel locations. Using the transformation $T(x,y) = (T_x(x,y), T_y(x,y) )$, we can form the transformed image $V(x,y) = f (T_x(x,y), f(T_y(x,y))$.

But we might mean doing a transformation where a value of the transformed image $V(x,y)$ depends on the values of $f$ at many different locations, as if $V(x,y)$ is the result of some sort of lens that merges many points of $f$ to form a single point of $V$.

5. Jun 4, 2014

### pamparana

Sorry my notation is not probably very clear. I am more of a software engineer and have not had a math class in a good 30 years!

So, let us just talk in terms of one dimensional images. So, the images are usually sampled on a uniform grid at discrete locations but I will assume that an image is a continuous function of a spatial location i.e. for the images $f$ and $r$, we have the intensity at any spatial location $i$ is given by $f(i)$ and $r(i)$

Now, a spatial transformation function can also be thought of as a continuous function (we are assuming it can be infinitely differentiated and hence it is a smooth transformation) which takes a spatial location $i$ in the domain of the image/function $r$ and maps it to the domain of the image/function $f$.

Now, the transformation is also computed at discrete locations (locations in image $r$) and these are the transformation parameters that I would like to estimate in my problem, given by $w$ but we can think of the underlying transformation as a continuous field and its value at any location can be given by some interpolating function. In my problem, I have done a simple linear interpolation (I know it is not differentiable) but in principle, I can substitute it with a reasonably smooth interpolator.

I am sorry if my decsription is not clear. please let me know and I can try to refine it further. As I explained, since maths is not my strong point, I am also having trouble formulating this integral.

6. Jun 4, 2014

### Stephen Tashi

OK, we are dealing with one dimensional images, $r(x)$ and $f(x)$. The transformation $y = t(x)$ maps the common domain of the images onto itself. (Must it be a 1-1 map?)

I assume the transformation of an image $g(x)$ is defined as $g(x) = f( t(x))$ where $f$ is the given image.

You mention both "interpolation" and also a "cost" function. "Interpolation" suggests exactly matching two sets of data at certain points. A "cost" function suggests assessing a penalty at other points where the two sets don't exactly match. My guess is that you are trying to find a $t(x)$ so that $g(x) = f(t(x))$ exactly matches the given $r(x)$ at certain points. If you are matching $r$ and $g$ at each pixel $x$, then I don't understand how you measure any discrepancy between $r$ and $g$.

We have a given set of points X on the x-axis and we want a mapping that takes each point to a given point in some other given set of points Y. How smooth must this map be? ( differentiable? - twice differentiable?) If the situation is really 2-dimensional, we could consider "conformal mapping": http://en.wikipedia.org/wiki/Conformal_map

7. Jun 4, 2014

### pamparana

The map is 1-1 i.e. bijective. The cost function is basically encapsulated in the integral as the sum of square difference, so we assume the errors in matching are normally distributed, which is what the exponential term is telling us.

The issue for me is not to do the transformation/mapping, it is to compute the integral. The mapping can be done in a variety of ways and can be formulated as a cost function, which can be solved using gradient descent based optimisation )for example) to get the most likely transformation i.e. a local mode of the distribution. However, I am trying to compute an estimate of the full posterior distribution on those transformation parameters rather than just the mean. I only described the bit of the problem in the original post that I am sort of having trouble with. It seems that I have an intractable integration problem.

8. Jun 4, 2014

### Stephen Tashi

To get good advice about the integration, you need make the notation clear. As the integration for Z is written, it appears to treat "i" as constant. Is this correct? Using "i" as a real constant is somewhat confusing due to the tradition of using "i" to mean the square root of -1.

9. Jun 5, 2014

### pamparana

Yeah, sorry I know it might be slightly confusing. In image processing, people tend to use i for an index or location. Yes, i is a constant and is a spatial location in the space of the reference image and whole corresponding location in the other image is given by t(i, w), which is the transformed location of i according to w.

10. Jun 5, 2014

### Stephen Tashi

I suggest you give a link to a paper that does something similar to your problem. Your statement of it still isn't clear.

For example,

Is "x" a constant?
Is "A" a linear function of "w" in the sense that A(w) = c w + d for constants c,d ?