Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Can I compute this integral analytically?

  1. Jun 2, 2014 #1
    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 [itex]r[/itex] and [itex]f[/itex]. In my problem, I am trying to find a continuous transform (which is very non-linear) that makes [itex]f[/itex] looks like [itex]r[/itex] according to some similarity criteria or cost function. I will call this transformation function [itex]t[/itex] and I am trying to estimate its parameters [itex]w[/itex].

    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 [itex]\sigma[/itex] is a constant. Now, given a constant linear function [itex]A[/itex], [itex]f(t(w))[/itex] is computed as:

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

    where [itex]\lceil \rceil[/itex] gives the ceiling function and [itex]\lfloor \rfloor[/itex] 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 [itex]t[/itex] is telling me what the location of a pixel [itex]i[/itex] in image [itex]r[/itex] is in image [itex]f[/itex] through [itex]w[/itex].

    Can someone tell me if I can compute such an integral? My first instinct was to use Taylor series to linearise [itex]t(w)[/itex] but it was pointed out that it is not a good idea as [itex]t(w)[/itex] is in the integral and we are integrating over [itex]w[/itex]. 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 [itex]t[/itex] to be able to do this integration.
    Last edited: Jun 2, 2014
  2. jcsd
  3. Jun 4, 2014 #2

    Stephen Tashi

    User Avatar
    Science Advisor

    I don't understand the relation between [itex] i [/itex] and [itex] w [/itex]. If [itex] w [/itex] are the parameters of the transformation then they are presumably constant, so what is the meaning of an integration with respect to [itex] dw [/itex] ?
  4. Jun 4, 2014 #3
    Thanks for the reply!

    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 [itex]w[/itex] i.e. [itex]P(w)[/itex]. 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 [itex]w[/itex] can take.
  5. Jun 4, 2014 #4

    Stephen Tashi

    User Avatar
    Science Advisor

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

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

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

    For example,

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

    But we might mean doing a transformation where a value of the transformed image [itex] V(x,y) [/itex] depends on the values of [itex] f [/itex] at many different locations, as if [itex] V(x,y) [/itex] is the result of some sort of lens that merges many points of [itex] f [/itex] to form a single point of [itex] V [/itex].
  6. Jun 4, 2014 #5
    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 [itex]f[/itex] and [itex]r[/itex], we have the intensity at any spatial location [itex]i[/itex] is given by [itex]f(i)[/itex] and [itex]r(i)[/itex]

    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 [itex]i[/itex] in the domain of the image/function [itex]r[/itex] and maps it to the domain of the image/function [itex]f[/itex].

    Now, the transformation is also computed at discrete locations (locations in image [itex]r[/itex]) and these are the transformation parameters that I would like to estimate in my problem, given by [itex]w[/itex] 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.
  7. Jun 4, 2014 #6

    Stephen Tashi

    User Avatar
    Science Advisor

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

    I assume the transformation of an image [itex] g(x) [/itex] is defined as [itex] g(x) = f( t(x)) [/itex] where [itex] f [/itex] 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 [itex] t(x) [/itex] so that [itex] g(x) = f(t(x)) [/itex] exactly matches the given [itex] r(x) [/itex] at certain points. If you are matching [itex] r [/itex] and [itex] g [/itex] at each pixel [itex] x [/itex], then I don't understand how you measure any discrepancy between [itex] r [/itex] and [itex] g [/itex].

    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
  8. Jun 4, 2014 #7
    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.
  9. Jun 4, 2014 #8

    Stephen Tashi

    User Avatar
    Science Advisor

    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.
  10. Jun 5, 2014 #9
    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.
  11. Jun 5, 2014 #10

    Stephen Tashi

    User Avatar
    Science Advisor

    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 ?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook