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.

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 = 10.0024 1.9831 3.0106 >> robustfit(xy1,xy2(:,2)) ans = -4.9992 -1.0083 -0.4932

Sorry if this bears no relation to what you want.

Show 1 older comment

Tom Lane
on 30 May 2013

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.

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 2 Comments

## Tom Lane (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/73750#comment_146476

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).

## Prateek (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/73750#comment_151949

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.