Friedrich-Alexander-Universität
Friedrich-Alexander-Universität
Stanford Radiology

Point Cloud Visualization

Here we show a simple example that parses a volumetric representation of a segmentation mask. The result is a set of points on the surface of the segmentation. In the end, this point cloud is visualized using the point cloud viewer.

Point Generation

First we create a constructor which takes the image and saves it in a variable.

Grid3D image;
public PointsCloudMaker(Grid3D image) {
   this.image = image;
}

After having created a Constructor, we determine a method which creates a Point-Cloud from the given image.

public ArrayList<PointND> getPoints(int id)

The initial variable in this method is the Image size ([0]=x, [1]=y, [2]=z).

int [] size = image.getSize();

Then we walk over the x, y, z variables and use a mask on the i and i+1 values every single step.

for (int k=0; k <size[2]; k++){  for (int j=0; j <size[1]; j++){    for (int i=0; i <size[0]-1; i++){      float one = image.getAtIndex(i, j, k);      float two = image.getAtIndex(i+1, j, k);    }  }}

If the variables "one" and "two" have different values we have to test on what position the point supposed to be placed (i or i+1). In the case that the point is not “null” it will be saved in the ArrayList “points”.

if (one != two) {
  PointND point = null;
  if (one == id){
    point = new PointND(General.voxelToWorld(new int [] {i,j,k}, image.getSpacing(),   image.getOrigin()));
  }
  if (two == id){
    point = new PointND(General.voxelToWorld(new int [] {i+1,j,k}, image.getSpacing(), image.getOrigin()));
  }
  if (point != null) points.add(point);
}

Finally we return the Point-Cloud!

return points;

Visualization

Resulting Visualization

In the main method the "getPoints" method for the left (value 1) and right (value 2) kidney has to be invoked. Afterwards the two Point-Clouds will be displayed in one Image.

PointsCloudMaker ptsMaker = new PointsCloudMaker(image);
ArrayList<PointND> id1 = ptsMaker.getPoints(1);
ArrayList<PointND> id2 = ptsMaker.getPoints(2);
id2.addAll(id1);
PointCloudViewer pcv = new PointCloudViewer("ID 1", id2);
pcv.setVisible(true);

Code

The code of this example is founded in edu.stanford.rsl.tutorial.basics.

Authors

Rimon Saffoury, Andreas Maier