MATLAB Answers


transformation parameter estimation using robusfit()

Asked by Prateek
on 27 Apr 2013

I want to use matlab function robusfit for calculating transformation parameters. I have set of matched points from sift, X = [x1,y1 ....xn,yn] and y = [x1,y1....xn,yn]. How do i use the function for it?

Thanks in advance.


I don't understand. It looks like you are saying that X and y are the same. In general, if X is a matrix of predictors (inputs) and y is a vector of responses (outputs), you would use robustfit(X,y).

Hi Tom, Thanks for your reply. I am doing image registration, i am getting matched points in image1 & image2. the point set are, say P1 = [x1, y1;...;xn,yn] & P2 = [x1, y1;..;x1, y1]. Now i want to calculate transformation parameters from these points using re-weighted least square, is there any function in matlab for this, if yes how do i use it. if not please guide me on how can i go about doing this. Please help.

Thanks in advance.

Log in to comment.


1 Answer

Answer by Tom Lane
on 30 May 2013
 Accepted Answer

I should have realized what you meant at first. I don't know much about image registration, but perhaps this will have some analogy to what you want. Let me start with a set of points in two dimensions.

>> xy1 = rand(20,2);

Now I generate another set of points from these by linear transformation plus a little bit of noise in both the x and y coordinates.

>> xy2 = xy1 * [2 -1;3 -.5];
>> xy2(:,1) = xy2(:,1)+10;
>> xy2(:,2) = xy2(:,2)-5;
>> xy2 = xy2 + randn(size(xy2))/100;

I can use backslash to recover the additive and multiplicative constants.

>> B = [ones(20,1) xy1]\xy2
B =
   10.0014   -4.9991
    1.9839   -1.0092
    3.0116   -0.4919

If my data had outliers I might prefer robust fitting. Here's how I can compute a robust estimate of the two columns of coefficients above.

>> robustfit(xy1,xy2(:,1))
ans =
>> robustfit(xy1,xy2(:,2))
ans =

Sorry if this bears no relation to what you want.


Show 1 older comment


Also take this problem as normal problem of finding transformation parameters from two set of points, image registration by itself doesn't play a major role in this scenario. :)

The robust function adds a constant term automatically, and you'll notice that I included a column of "ones" in the backslash expression. So in both cases (first row of B, first entries on robustfit) you should see that the estimates are close to the 10 and -5 I added. That's what I meant by the "additive constants."

You should see that the remaining part of B is close to the [2 -1;3 -.5] transformation matrix I used. That's what I meant by the "multiplicative constants."

You could reverse this and go backwards from xy2 to xy1 if you want.

I get it. It makes the problem clear now.

So i think i have got my answer, Let me try this out once and i'll let you know the results, which might be useful for others who are seeking a similar solution.

thanks again.

Log in to comment.

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Win prizes and improve your MATLAB skills

Play today