expectation_maximization_registration
Point Cloud Registration using Expectation-MaximizationLink
This module implements the Expectation-Maximization algorithm for point cloud registration, providing a probabilistic approach to align 3D point sets with robust handling of noise and outliers. This is an abstract base class that should be implemented by specific registration methods.
Key FeaturesLink
- Probabilistic point cloud alignment using EM algorithm
- Iterative refinement of transformation parameters
- Automatic variance estimation for noise handling
- Support for rigid and non-rigid transformations
- Convergence control through iteration limits and tolerance settings
NotesLink
This is a part of the implementation of the stochastic registration algorithm based on the following paper: Myronenko A. and Song X. (2010) Point set registration: Coherent Point drift. IEEE Transactions on Pattern Analysis and Machine Intelligence. 32 (2): 2262-2275. DOI: 10.1109/TPAMI.2010.46
The library is based on the python implementation of the paper in pycpd
package.
ExpectationMaximizationRegistration Link
ExpectationMaximizationRegistration(X, Y, sigma2=None, max_iterations=MAX_ITER, tolerance=TOL, w=0, *args, **kwargs)
Bases: object
Abstract base class for point cloud registration using Expectation-Maximization algorithm.
This class implements the core functionality of the Coherent Point Drift (CPD) algorithm for point set registration based on Myronenko and Song's paper. It uses a probabilistic approach where the alignment of two point sets is treated as a Maximum Likelihood (ML) estimation problem with a Gaussian Mixture Model (GMM) as the likelihood function.
The class serves as a base for various CPD registration methods (rigid, affine, etc.), providing common EM framework while requiring specific transformation models to be implemented in child classes.
Attributes:
Name | Type | Description |
---|---|---|
X |
ndarray
|
Reference point cloud coordinates, shape |
Y |
ndarray
|
Initial point cloud coordinates to optimize, shape |
TY |
ndarray
|
Transformed/registered version of Y after optimization, shape |
sigma2 |
float
|
Variance of the Gaussian Mixture Model (GMM), updated during registration. |
N |
int
|
Number of points in reference cloud |
M |
int
|
Number of points in source cloud |
D |
int
|
Dimensionality of the point clouds (e.g., 3 for 3D point clouds). |
tolerance |
float
|
Convergence criterion threshold. |
w |
float
|
Weight of the uniform distribution component for outlier handling. |
max_iterations |
int
|
Maximum number of iterations for the algorithm. |
iteration |
int
|
Current iteration number during registration process. |
err |
float
|
Current registration error/distance between point sets. |
P |
ndarray
|
Posterior probability matrix of point correspondences, shape |
Pt1 |
ndarray
|
Column-wise sum of posterior probability matrix, shape |
P1 |
ndarray
|
Row-wise sum of posterior probability matrix, shape |
Np |
float
|
Sum of all elements in the posterior probability matrix. |
q |
float
|
Negative log-likelihood of the current estimate. |
Notes
This is an abstract base class. Child classes must implement:
update_transform()
: Update transformation parameterstransform_point_cloud()
: Apply transformation to point cloudupdate_variance()
: Update GMM varianceget_registration_parameters()
: Return registration parameters
References
Myronenko A. and Song X. (2010) Point set registration: Coherent Point drift. IEEE Transactions on Pattern Analysis and Machine Intelligence. 32 (2): 2262-2275. DOI: 10.1109/TPAMI.2010.46
See Also
skeleton_refinement.utilities.initialize_sigma2 : Function to initialize the variance parameter
Initialize the Expectation-Maximization registration algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
ndarray
|
Reference point cloud (target), shape |
required |
Y
|
ndarray
|
Point cloud to be aligned (source), shape |
required |
sigma2
|
float or None
|
Initial variance of the Gaussian Mixture Model (GMM).
If |
None
|
max_iterations
|
int
|
Maximum number of EM iterations. Default is |
MAX_ITER
|
tolerance
|
float
|
Convergence threshold for stopping iterations.
Algorithm stops when change in error falls below this value.
Default is |
TOL
|
w
|
float
|
Weight of the uniform distribution component (0 <= w < 1).
Used to account for outliers and noise.
A value of |
0
|
Raises:
Type | Description |
---|---|
ValueError
|
If |
Source code in skeleton_refinement/expectation_maximization_registration.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
expectation Link
expectation()
Perform the Expectation step of the EM algorithm.
The expectation step estimates the posterior probability (P) that each point in the source set corresponds to each point in the reference set, based on the current transformation and GMM variance.
This step also handles outlier detection based on the uniform distribution weight parameter w.
Notes
Updates the following attributes:
- P: Posterior probability matrix of point correspondences
- Pt1: Column-wise sum of P
- P1: Row-wise sum of P
- Np: Sum of all elements in P
Source code in skeleton_refinement/expectation_maximization_registration.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
|
get_registration_parameters Link
get_registration_parameters()
Get the current registration transformation parameters.
This is an abstract method that must be implemented by child classes to return the specific transformation parameters used in the registration.
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing the transformation parameters specific to the registration method. |
Raises:
Type | Description |
---|---|
NotImplementedError
|
If called from the base class without being overridden. |
Source code in skeleton_refinement/expectation_maximization_registration.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
iterate Link
iterate()
Perform one Expectation-Maximization iteration.
This method runs a single EM iteration consisting of:
- Expectation step: compute point correspondences
- Maximization step: update transformation parameters
The iteration counter is incremented after each call.
Source code in skeleton_refinement/expectation_maximization_registration.py
284 285 286 287 288 289 290 291 292 293 294 295 296 |
|
maximization Link
maximization()
Perform the Maximization step of the EM algorithm.
The maximization step updates the transformation parameters and variance to maximize the probability that the transformed source points were drawn from the GMM centered at the reference points.
This method calls the abstract methods that should be implemented by child classes:
- update_transform()
- transform_point_cloud()
- update_variance()
Source code in skeleton_refinement/expectation_maximization_registration.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
register Link
register(callback=lambda **kwargs: None)
Perform the point set registration.
This method runs the EM algorithm to align the source point cloud (Y) to the reference point cloud (X). The algorithm iteratively estimates point correspondences and updates the transformation parameters until convergence or maximum iterations are reached.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback
|
callable
|
Function to call after each iteration with registration state information. The function should accept keyword arguments: iteration, error, X, Y. Default is a no-op function. |
lambda **kwargs: None
|
Returns:
Type | Description |
---|---|
ndarray
|
The transformed point cloud (TY). |
dict
|
Registration parameters specific to the registration method. |
Notes
The registration is considered converged when the change in error between iterations falls below the tolerance threshold or the maximum number of iterations is reached.
Source code in skeleton_refinement/expectation_maximization_registration.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
|
transform_point_cloud Link
transform_point_cloud()
Apply the current transformation to the source point cloud.
This is an abstract method that must be implemented by child classes to apply the specific transformation to the point cloud Y and update TY.
Raises:
Type | Description |
---|---|
NotImplementedError
|
If called from the base class without being overridden. |
Source code in skeleton_refinement/expectation_maximization_registration.py
176 177 178 179 180 181 182 183 184 185 186 187 |
|
update_transform Link
update_transform()
Update transformation parameters based on the current point correspondence.
This is an abstract method that must be implemented by child classes to update the specific transformation parameters (e.g., rotation matrix, scaling factor, etc.) based on the current state of the registration.
Raises:
Type | Description |
---|---|
NotImplementedError
|
If called from the base class without being overridden. |
Source code in skeleton_refinement/expectation_maximization_registration.py
162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
update_variance Link
update_variance()
Update the variance of the GMM model (sigma2).
This is an abstract method that must be implemented by child classes to update the variance parameter based on the current state of the registration process.
Raises:
Type | Description |
---|---|
NotImplementedError
|
If called from the base class without being overridden. |
Source code in skeleton_refinement/expectation_maximization_registration.py
189 190 191 192 193 194 195 196 197 198 199 200 201 |
|