Code covered by the BSD License  

Highlights from
Iterative Closest Point

4.625

4.6 | 9 ratings Rate this file 216 Downloads (last 30 days) File Size: 8.41 KB File ID: #27804
image thumbnail

Iterative Closest Point

by Jakob Wilm

 

30 May 2010 (Updated 24 May 2012)

An implementation of various ICP (iterative closest point) features.

| Watch this File

File Information
Description

The ICP algorithm takes two point clouds as an input and return the rigid transformation (rotation matrix R and translation vector T), that best aligns the point clouds.

Example:
[R,T] = icp(q,p,10);

Aligns the points of p to the points q with 10 iterations of the algorithm.
The transformation is then applied using
R*p + repmat(T,1,length(p));

The file has implemented both point to point and point to plane as well as a couple of other features such as weighting functions, edge point rejection, winsorising, etc.

For an introductory text on the ICP algorithm and the implemented variants, see http://www.scribd.com/doc/58495347/Evaluation-of-Surface-Registration-Algorithms-for-PET-Motion-Correction

Hans Martin Kjer & Jakob Wilm -- Evaluation of surface registration algorithms for PET motion correction

Required Products Statistics Toolbox
MATLAB release MATLAB 7.10 (2010a)
Other requirements For kDtree matching, the Statistics Toolbox v. 7.3 is needed. Alternatively one can use GLTree, submission #24607
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (23)
30 Jul 2010 Michael H

Looks very good, but I can't get icp.m to run as I think it is missing the rms_error function. Am I doing something wrong?

07 Aug 2010 Harivinod N

I am also getting the similar error as mention by Michel(30 Jul 2010). It will be helpful, if this is fixed.

12 Aug 2010 Jakob Wilm

Thank you for your interest. The missing function (rms_error.m) has now been added.

15 Sep 2010 Dengwen Zhou

Hi, Jakob Wilm
 
The code package is very good! but misses KDTreeSearcher.m.

Can you update it?

12 Oct 2010 Jakob Wilm

For kDtree matching, the Statistics Toolbox v. 7.3 is needed.

16 Mar 2011 Sebastian

Hello Jakob,
I've looked at different Matlab ICP-packages and yours is the fastest and most flexible so far. I just wanted to point out a little typo.

In the documentation [line 50] you write: Minimize {point} | plane | lmaPoint
But in the code [line 123] you check for: validMinimize = {'point','plane','lma_point'};

Thanks for the great package.

11 Jul 2011 Harivinod N  
29 Jul 2011 wb fan

Hi,Jakob,
Demo.m is very helpful, but it doesn't tell me how to use the other setting( Normals, Weight, Triangulation...).Could you please show me some more sample code.
Thanks for the great work.

19 Oct 2011 Ben

Can it be used for 2D point sets registration? It raised error message asking for 3D data.

18 Nov 2011 Axel

There seems to exist a little bug in your function arguments parsing. The line:
inp.addParamValue('Normals', [], @(x)isreal(x) && size(x,1) == 3);
seems to check dimensions differently from what the help states.
Shouldn't instead read:
inp.addParamValue('Normals', [], @(x)isreal(x) && size(x,2) == 3;

18 Nov 2011 Axel

Posted the comment to quickly. The argument checking seems to be fine. It is coherent with the rest of the code.

Sorry for the confusion

18 Nov 2011 Huang Chun-Hsiang  
18 Nov 2011 ucd puri

Hi Jakob
I am getting the following error when I run demo file. Any suggestions. many thanks.
------------------------------
??? Error: File: icp.m Line: 226 Column: 11
Expression or statement is incorrect--possibly unbalanced (, {, or [.

Error in ==> demo at 57
[Ricp Ticp ER t] = icp(M, D, 15);
-------------------------------------

18 Nov 2011 Jakob Wilm

Hello ucd puri,

in your case, Matlab complaints about the following line (226 in icp.m):
[~, idx] = sort(mindist);
This is probably due to the fact that older versions of Matlab don't understand the tilde (~) as a way of discarding a certain output variable. You can either update to a newer version of Matlab or use a dummy output (you will have to do this at several places inside the code), e.g.:
[dummy, idx] = sort(mindist);

Regards,
Jakob

18 Nov 2011 ucd puri

Many Thanks- this was very helpful. Kind Regards.

20 Feb 2012 Joachim

Hello Jakob,
very nice work. Thx a lot for it.
I have some special boundary conditions here which i am not sure how to implement and fit to your code.

I need to fix certain degrees of freedom during the ICP. As an example I would like to allow the result to be a translation only in X/Y direction and a rotation around Z-Axis.

Do you or anybody else know how to easily integrate such a feature into the code?

Thx in advance!
All the best,
joachim

25 Feb 2012 Kevin Matzen  
26 Mar 2012 Mithun

Does this algorithm include the scaling ICP?

28 Mar 2012 Jakob Wilm

Hello Mithun,
scaling is not solved for, only translation and rotation (6 d.o.f. rigid transform).
Regards

23 May 2012 Sebastian

Hello Jakob,
Because your ICP implementation was featured in the recent MATLAB Digest - Mai 2012 newsletter, I revisited it to see if updates are available. I noticed in your new version that you forgot to include the 'rmat2quat' function in your icp.m file. You can reproduce the error if you enable Extrapolation in your demo.m file, e.g. line 57.

For my current work I would like to integrate some additional constraints like the ones mentioned in Joachims comment from 20 Feb 2012. Do you think this is possible with your framework?

Greetings from Germany
Sebastian

P.S. The link to the introductory text in the description is broken (page not found by DTU).

23 May 2012 Jakob Wilm

Hi Sebastian,
thank you for letting me know. I have corrected the link, and will re-add the rmat2quat function ASAP. It will go through Mathworks review and should be available tomorrow.
To constrain the ICP to certain DOF, I do not believe there is a closed form solution for that kind of Procrustes problem, but you should check the literature.
My idea would be that you either modify eq_point() or eq_plane() and remove the 'unwanted' DOF from R and T after estimation (this is somewhat hackish). Or you could use eq_lmaPoint() which performs non-linear optimization on the parameters, so you can basically model anything there (this might be slow).
Alternatively you could pose the whole fitting procedure a non-linear optimization problem, which can actually be competitive with ICP. See: Andrew W. Fitzgibbon. Robust registration of 2d and 3d point sets. Image and Vision Computing, 21(13-14):1145–1153, 2003.
Regards,
Jakob

25 May 2012 Walter

Hi Jacob your code is very helpful.
BTW I noticed two memory leaks.
One is in the implementation of GlTree, I will post in that FileExchange. The other is in the usage of inputParser. You should clear the object inp.

25 May 2012 Jakob Wilm

Walter: inp, DT, kdOBJ, etc. are all scope managed, so there is no memory leak.

Please login to add a comment or rating.
Updates
05 Jun 2010

Added link to thesis.

11 Aug 2010

Added rms_error and added a screenshot.

24 Jun 2011

Corrected a typo in icp.m (as pointed out in the comments, thanks!)

24 Jul 2011

Combined functions in one file and added a demo script.

23 May 2012

Corrected link to thesis.

24 May 2012

Updated icp.m with a missing sub function.

Tag Activity for this File
Tag Applied By Date/Time
icp Jakob Wilm 01 Jun 2010 10:41:00
iterative closest point Jakob Wilm 01 Jun 2010 10:41:00
iterative closest point Harivinod N 07 Aug 2010 02:29:05
icp Alessandro Mannini 07 Dec 2010 09:04:47
icp Zoltan 15 Apr 2011 12:09:50
iterative closest point Zoltan 15 Apr 2011 12:09:55
bestfit Zoltan 15 Apr 2011 12:10:01
bestfit Neal 25 May 2011 05:27:44
icp Neal 25 May 2011 05:27:55
icp wb fan 29 Jul 2011 09:36:48
bestfit Mike 16 Nov 2011 03:17:34
icp Mike 16 Nov 2011 03:17:38
iterative closest point Mike 16 Nov 2011 03:17:43
iterative closest point Joel 21 May 2012 00:40:00

Contact us at files@mathworks.com