Alignment and Registration

From CloudCompareWiki
Jump to: navigation, search

This section deals with alignment and registration of 3D entities (clouds or meshes).

General considerations

Did you say mesh?

(skip this part if you don't work with triangular meshes)

As often with CloudCompare, meshes will generally be considered as clouds, either by considering their vertices only or by sampling points on the mesh surface. For instance you can call the Fine registration tool (ICP) directly on a mesh. But behind the scenes CC will automatically sample points on this mesh in order to use it for ICP registration.

There's only one notable exception: the 'Point pair based' alignment tool can now be used directly on meshes (when the user clicks on a triangle, CloudCompare will determine the actual intersection point on the triangle surface).

So instead of letting CloudCompare chose, you can of course do this conversion yourself:

  • instead of selecting the mesh entity, you can simply select its 'vertices' (a point cloud named 'vertices' - generally a child of the mesh entity in the DB tree). In this case you can 'hide' the mesh entity (uncheck the 'visible' checkbox in the mesh properties) and instead display its vertices (check the equivalent 'visible' checkbox in the 'vertices' cloud properties). As mesh vertices are generally quite sparse, you can also increase the points size (the -/+ interactors that appear when you hover the mouse in the top-left corner of a 3D view).
  • you can alternatively sample points on the mesh (this way you'll have more control on this process) and use the sampled cloud in place of the mesh. In the particular case of registration, if you want to apply the resulting transformation to the original mesh afterwards, refer to the next section.

Rigid transformation matrices

(skip this part if you really hate maths - otherwise it might give you some interesting hints ;)

Almost all methods presented below are in fact various ways to produce a rigid transformation (matrix) to make an entity move relatively to another one (see Apply Transformation). Whatever the registration tool you use, CloudCompare will always issue the resulting transformation matrix in the console. This allows the user to apply it - or its inverse - to any other entity.

To do so:

  • first copy the matrix from the Console (typically with the shortcut CTRL+C on Windows)
  • then select the entity you wish to move
  • call the 'Edit > Apply Transformation' tool
  • paste the 4x4 matrix in the first tab. You can use the dedicated shortcut (e.g. CTRL+V on Windows) or the 'clipboard' button (CloudCompare should automatically get rid of the block prefix - [time between brackets])
  • you can even apply the inverse transformation by checking the corresponding checkbox (e.g. to go back to the previous position of the entity)
'Apply transformation' dialog

This trick can be very useful to perform registration on a small portion of a cloud (which you would have segmented beforehand - typically with the ' scissors' tool). Then you can apply the same transformation to the whole cloud afterwards or to another entity (mesh, etc.). See the ' Alternative method for registering partially overlapping clouds' section.

Alignment

CloudCompare offers various ways to roughly or finely align point clouds or meshes.

Match bounding-box centers

The easiest one is the bounding-box centers matching method. Simply select two (or more) entities, then call 'Tools > Register > Match bounding-box centers' (immediate effect, no dialog). It will center all the selected entities on their respective center of gravity.

It's clearly a very simple approach (it can only translate entities, and not rotate them). However it can save you a few clicks.

Manual transformation

It is possible to interactively displace with the mouse one or several entities (relatively to other entities). See the Rotate/Translate tool CCMoveIcon.png.

"Rotate/Translate" tool in action

Picking (equivalent) point pairs

Another powerful yet simple tool to align two entities is the Align (point pairs picking) tool Cc pointPairAlignIcon.png. It lets the user pick several pairs of equivalent points in each cloud in order to register them. While the process is manual it can be relatively fast and quite accurate (especially if registration spheres are present in both clouds as this tool is now able to detect their center automatically).

Standard alignment procedure (no spheres)

Auto-align (I'm lucky)

A research tool is accessible via the 'Tools > Sand box (research) > Auto align clouds' menu entry. It's an implementation of the Four Points Congruent Sets (4PCS) registration algorithm (by Dror Aiger, Niloy J. Mitra and Daniel Cohen-Or).

Sadly it's still very buggy and not well documented so you're likely to lose more time by using this method (even if it's 'automatic') than directly using one of the above. Maybe in the future if someone dares to dig in the code and fix it...

Automatic registration

Fine registration with ICP

For now, the only automatic method to very finely register two entities is the well-known Iterative Closest Point (ICP) algorithm. See the Fine registration (ICP) section.

Fine registration (ICP) dialog

Alternative method for registering partially overlapping clouds

Here is an old way of registering two partially overlapping clouds (i.e. prior to version 2.6.1 and its Final overlap parameter).

Preparation

Note: if you don't already know which cloud will be the data cloud (the one that will move) and which one will be the model cloud (the one that won't move) then you should select the densest one as model (reference)

Creating a subset of the data cloud

  • clone the data cloud and hide the original one
  • select the new version of the data cloud and use the manual segmentation tool to keep only the points clearly overlapping with the model cloud

Register the 'data' cloud (subset) with the model cloud

  • apply the Fine registration (ICP) algorithm to the data cloud subset and the 'model' cloud
  • once done, CloudCompare will output the resulting transformation matrix in the Console
  • copy this transformation (CTRL+C on Windows)

Apply the rigid transformation to the original data cloud

  • make the original data cloud visible again and select it
  • launch the ' Edit > Apply Transformation' tool
  • paste the transformation (CTRL+V on Windows) in the first tab
  • click on the 'OK' button

That's it!