1
$\begingroup$

I want to estimate a nonlinear mapping from two-dimensional input positions to two-dimensional output positions. (Think of this as a nonlinear distortion of an image. Once I get the estimated function, I can use ImageForwardTransformation to perform the transformation on the full image.)

Suppose I have $n$ pairs of "training points": input $(x_i, y_i)$ to corresponding output $(x_i^\prime , y_i^\prime)$ for $i = 1, \ldots n$.

As a minimum-working example, assume the following two-dimensional data with $n=5$:

input = {{0, 0}, {1, 1}, {2, 3}, {2, 4}, {3, 2}};
output = {{0, 0}, {1, 2}, {2, 2}, {3, 2.5}, {4, 3}};

The direct approach to learning the transformation function would be to use NonlinearModelFit with (say) different quadratic functions for each of the coordinates. That is, learn two functions $(x_i^\prime, y_i^\prime) = (f_1(x_i, y_i), f_2(x_i, y_i))$. The problem is that this approach doesn't adequately incorporate the fact that in the desired true mapping the coordinate mappings are not independent.

What I think we really need is to estimate a single mapping function from two-dimensional input to two-dimensional output.

Alas, I just couldn't figure out the syntax in NonlinearModelFit to achieve this (and apply it to my above sample data). I have a feeling I'm overlooking some subtlety of syntax in order to get Mathematica to learn the desired mapping.

Any suggestions?

$\endgroup$
10
  • $\begingroup$ Would that not just be FindGeometricTransform[output, input]? $\endgroup$
    – MarcoB
    Commented Feb 1, 2021 at 19:25
  • $\begingroup$ @MarcoB: Nope. That finds a linear (matrix) transformation. $\endgroup$ Commented Feb 1, 2021 at 19:39
  • 2
    $\begingroup$ Markus Van Almsick explains in this talk how he will use Radial Basis Functions to implement interpolating nonlinear image transformation. I suggest to begin to watch at time=25 seconds, mainly to see if it is relevant for you problem (I think it is). $\endgroup$
    – andre314
    Commented Feb 1, 2021 at 19:49
  • $\begingroup$ In his talk he says that the attenders of the conference will have the Notebook with the relevant code (I don't understand what he says very softly just after). I was not there, but I would be happy to have it, if possible. $\endgroup$
    – andre314
    Commented Feb 1, 2021 at 19:54
  • 2
    $\begingroup$ FYI: I contacted the author/presenter and requested the code. We'll see.... $\endgroup$ Commented Feb 1, 2021 at 20:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.