Morphing point clouds algorithm

In some sense, point cloud is an universal medium for representing 2D and 3D vector objects and raster images/volumes.

Namely, each 2D or 3D raster (image/volume) can be treated at least in two opposite ways:
  1. as a grid of points, where each point posess the color and opacity, without overlapping.
  2. as a set of points, where each point has pure grayscale, reg, green or blue color, and almost transparent. So many points overlapped additively and get required colors. 
Of course, there are possibilities between this polar cases.

Each 2D or 3D vector object (curve/surface) can be filled points so dense, that when viewing it on a rester display, it looks like just vector object.

Such representation of an objects from a "sand" points gives opportunities of free morphing objects.

So, consider the following problem.
Let A and B are two point clouds of size N of equal color and transparency.
It's required to create bijective mapping k_i, that {A_i}->{B_k_i} is a "best" correspondence in some sense, and so we can move this corresponding points to smoothly deform shape A into shape B.

(The more general case when A and B has different number of points and points have differenct colors and transparency, can be reduced to the considered problem by adding virtual particles).

Here we dicsuss one simple stochastical solution for this problem.
Namely, define cost function C({k_i}) as a Sum{||A_i-B_k_i||^2), and will try to minimize C over by varying {k_i}.
The quite good working algorithm for this is the following:
  1.  Initialize {k_i} by random bijection 1..N->1..N, namely, put k_i=i, i=1..N and shuffle this.
  2. For some number of steps S=S(N), for example, S=N, perform the folowing operation: 
    - randomly choose i1, i2.
    - swap k_i1 and k_i2.
    - if C({k_i}) becomes less, the accept the swapping, else doesn't accept.

Such stochastic procedure leads to decreasing C, and in our experiments works good.









Comments

Popular posts from this blog

Computing ray origin and direction from Model View Projection matrices for raymarching

Forward and backward alpha blending for raymarching

Forward, Deferred and Raytracing rendering in openFrameworks and web