Extract point cloud from labelMap contour

Hi,

I want to Apply two filters on a binary volume (labelMap). The first one is 3D Gaussian filter to blur the boundry between inside and outside voxels , and the second one is the sobel filter at the voxel locations corresponding to the contour of the labelMap in order to calculate the gradiant . The resulting gradiants at the set of contour points are then normalized and negated to produce the normal associated with each point contour.

My question is how to transform the voxels of labelMap to 3D points? and how to extract the set of 3D points situated on the contour of the label Map in order to Apply the sobel filter and deduce the normals?
are there VTK filters to do this in c++?

Thank you in advance fro your help

No need to reimplement basic features such as labelmap to point cloud (surface mesh) conversion: in Data module, right-click on your labelmap volume to convert it to segmentation, then right-click on the segmentation to export it to model node.

Thanks for your response.

I need to re-implment the process using vtk and c++. My goal is to use MPU implicite models to reconstruct a smooth surface . So i need to know how can i do this using VTK filters.

If your goal is to implement a particular method then sure, go on, implement it. If you want to solve a clinical problem then you can sidestep the hard problem of creating smooth surface from parallel contours: create surface from the 3D labelmap directly.

If you want to extract smaller details than those that are actually visible in the image (e.g., you want to segment a thin boundary that you know is there, even if it is not visible in the image) then you can oversample the input volume: either use Crop volume module on the input volume before segmentation; or use segmentation geometry button next to master volume selector in Segment Editor module and specify an oversampling factor > 1.

In fact, my target is to implement a particular method in which i find some difficulties to start. So my question is simple. I have a labelMap as input , I need to compute the normal vectors only on points contours of the labelMap and not at the entire label Map.

I Wonder if is there a way to compute contour’s points informations from labelMap in c++ and using VTK filters (i talk about implementation aspect )?

I can use this vtkImageData ::GetPointData() -> vtkPointData ::GetScalars() -> vtkDataArray::getVoidPointer() to get the set of points but what i nedd is only the points of labelMap’s contour.
I hope my question is clear. Thank’s in advance Mr.

What do you mean by “points contours of the labelMap”?

To avoid premature optimization (and since gradient computation is so quick), I would recommend to compute the gradient for the entire image using vtkImageGradient and then use vtkProbeFilter to get the gradient at every point of a point set. If later the step proves to be a performance bottleneck then you can still revisit this.

Thank you for the response. what i mean by contours of labelMap is I need only the informations (gradiants at labelMap outlines and not at each voxel of the label Map. I found this filter, I think is what i must to use if i need only the contours:

Hi Mr;

And my last question is: in fact to compute the normal vector at each point. I applied “vtkImageGaussianSmooth” on the labelMap to get a blurred label Map like this:

 double gaussianStandardDeviation = 2.0;
 vtkSmartPointer<vtkImageGaussianSmooth> gaussian =
 vtkSmartPointer<vtkImageGaussianSmooth>::New();
 gaussian->SetStandardDeviations (gaussianStandardDeviation,
                           gaussianStandardDeviation,
                            gaussianStandardDeviation);
 
gaussian->SetInputData(labelMap);
gaussian->Update();

then to get the gradiant, I wish Apply the soble filter using " [vtkImageSobel3D]"

Now the last step is to deduce the normal vector from gradiant. I know how to recover the x,y,z components, but how to compute the norm of the vector and get the normal vector from gradiant image? are there vtk filters to do that?

To get the image gradient, do not use the Sobel operator, but vtkImageGradient filter.

OK this is a one a solution. But in the method which I try to implement uses:

3d gaussain filter to get a blurred label Map. Then it applied a 3D sobel filter to the blurred volume to compute the gradiant at each voxel location. The Sobel filter was chosen because it takes into account information on the diagonals surrounding the processed point in addition to the information
along the volume’s axes.The resulting gradient is normalized and negated to produce the normal associated with each input point. My ambiguity is when i apply the soble Filter, how can I transform the scalars to vectors in order to normalize them and obtain the normal vector which points away from the model’s interior.

The Sobel operator returns something similar to to gradient magnitude. It is not the gradient.

If you are interested in the gradient vector then use vtkImageGradient filter. If you need the gradient magnitude then use vtkImageGradientMagnitude filter.

1 Like