# Resample to Image on point cloud?

**URL:** https://discourse.paraview.org/t/resample-to-image-on-point-cloud/10979
**Category:** ParaView Support
**Created:** [December 14, 2022, 9:51pm UTC](https://discourse.paraview.org/t/resample-to-image-on-point-cloud/10979 "2022-12-14T21:51:33Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Devin\_Richard\_Bayly](https://discourse.paraview.org/user_avatar/discourse.paraview.org/devin_richard_bayly/32/5533_2.png) [@Devin\_Richard\_Bayly](https://discourse.paraview.org/u/Devin_Richard_Bayly)
#### Post date: [December 14, 2022, 9:51pm UTC](https://discourse.paraview.org/t/resample-to-image-on-point-cloud/10979/1 "2022-12-14T21:51:33Z")

</div>

I’m trying to use volumetric rendering with data that comes in as a collection of 24million 3d points. I searched through the documentation and it seems like [resample to image](https://docs.paraview.org/en/latest/UsersGuide/filteringData.html#resample-to-image) is a way to do it if I had a mesh that had attribute data on it, but I only have points.

Is there a method that essentially samples a set of points and turns it into voxel data where the data in a cell is the number of points within that voxel? Is this an option I’m missing in the resample to image filter?

 ![image](https://discourse.paraview.org/uploads/default/original/2X/6/6a821df0f3e63a5ce1b560f4c6392f83595970b3.jpeg)

Thanks!

---

<div class="post-metadata">

### Author: ![jfavre](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jfavre](https://discourse.paraview.org/u/jfavre)
#### Post date: [December 15, 2022, 8:58am UTC](https://discourse.paraview.org/t/resample-to-image-on-point-cloud/10979/2 "2022-12-15T08:58:36Z")

</div>

[https://vtk.org/doc/nightly/html/classvtkPointDensityFilter.html](https://vtk.org/doc/nightly/html/classvtkPointDensityFilter.html) is exactly what you need. The challenge is that it is not directly available in ParaView. Fortunately, you can easily integrate that into a ProgrammableFilter. Here is the code, tested with v5.11.

```auto
PointDensity = ProgrammableFilter(registrationName='PointDensity', Input=mergeBlocks1)
PointDensity.OutputDataSetType = 'vtkImageData'
PointDensity.Script = """from vtk.vtkFiltersPoints import vtkPointDensityFilter

bounds = inputs[0].GetBounds()
hBin = vtkPointDensityFilter()
hBin.SetInputData(inputs[0].VTKObject)
hBin.SetModelBounds(bounds)
hBin.SetSampleDimensions(self.dims)
hBin.Update()
output.ShallowCopy(hBin.GetOutput())
"""
PointDensity.RequestInformationScript = """
executive = self.GetExecutive ()
outInfo = executive.GetOutputInformation(0)

self.dims = [512]*3
outInfo.Set(executive.WHOLE_EXTENT(), 0, self.dims[0]-1 , 0, self.dims[1]-1 , 0, self.dims[2]-1)
"""
PointDensity.RequestUpdateExtentScript = ''
PointDensity.PythonPath = ''
PointDensity.CopyArrays = 0

```

Adding more options to the PointDensityFilter is left as an exercise for the reader.  
N.B. This filter has been threaded with vtkSMPTools. It can execute pretty quickly.

---

<div class="post-metadata">

### Author: ![Devin\_Richard\_Bayly](https://discourse.paraview.org/user_avatar/discourse.paraview.org/devin_richard_bayly/32/5533_2.png) [@Devin\_Richard\_Bayly](https://discourse.paraview.org/u/Devin_Richard_Bayly)
#### Post date: [December 15, 2022, 4:45pm UTC](https://discourse.paraview.org/t/resample-to-image-on-point-cloud/10979/3 "2022-12-15T16:45:42Z")

</div>

Incredible! I’ll get right to checking this out, and I’m excited to learn more in the underlying vtk space. Thank you so much.

---

<div class="post-metadata">

### Author: ![Devin\_Richard\_Bayly](https://discourse.paraview.org/user_avatar/discourse.paraview.org/devin_richard_bayly/32/5533_2.png) [@Devin\_Richard\_Bayly](https://discourse.paraview.org/u/Devin_Richard_Bayly)
#### Post date: [December 15, 2022, 4:50pm UTC](https://discourse.paraview.org/t/resample-to-image-on-point-cloud/10979/4 "2022-12-15T16:50:52Z")

</div>

Oh this is totally a one stop shop for everything I wanted

 ![image](https://discourse.paraview.org/uploads/default/original/2X/4/4e3221f3b7500195067c2e5561438ef52b67ae19.jpeg)

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [December 15, 2022, 8:08pm UTC](https://discourse.paraview.org/t/resample-to-image-on-point-cloud/10979/5 "2022-12-15T20:08:44Z")

</div>

There is also the `Point Volume Interpolator`, which is available in ParaView now.

---

<div class="post-metadata">

### Author: ![Devin\_Richard\_Bayly](https://discourse.paraview.org/user_avatar/discourse.paraview.org/devin_richard_bayly/32/5533_2.png) [@Devin\_Richard\_Bayly](https://discourse.paraview.org/u/Devin_Richard_Bayly)
#### Post date: [December 15, 2022, 8:11pm UTC](https://discourse.paraview.org/t/resample-to-image-on-point-cloud/10979/6 "2022-12-15T20:11:36Z")

</div>

I gave the `Point Volume Interpolator` a try, but since my points didn’t come with attribute data on them it was greyed out?

---

<div class="post-metadata">

### Author: ![Joachim\_P](https://discourse.paraview.org/user_avatar/discourse.paraview.org/joachim_p/32/9596_2.png) [@Joachim\_P](https://discourse.paraview.org/u/Joachim_P)
#### Post date: [December 20, 2022, 2:40am UTC](https://discourse.paraview.org/t/resample-to-image-on-point-cloud/10979/7 "2022-12-20T02:40:28Z")

</div>

As an extended exercise, instead of a Python Programmable filter, you can simply describe the filter in XML and load it as a Plugin.  
The solution is attached 😉

[PointDensityFilter.xml](https://discourse.paraview.org/uploads/short-url/wxLFhdubpZZuIJW9AsKO1VBa5Vs.xml) (7.7 KB)

---

<div class="post-metadata">

### Author: ![jfavre](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jfavre](https://discourse.paraview.org/u/jfavre)
#### Post date: [December 20, 2022, 11:47am UTC](https://discourse.paraview.org/t/resample-to-image-on-point-cloud/10979/8 "2022-12-20T11:47:21Z")

</div>

Well done @Joachim_P 👏

---

<div class="post-metadata">

### Author: ![Devin\_Richard\_Bayly](https://discourse.paraview.org/user_avatar/discourse.paraview.org/devin_richard_bayly/32/5533_2.png) [@Devin\_Richard\_Bayly](https://discourse.paraview.org/u/Devin_Richard_Bayly)
#### Post date: [December 20, 2022, 3:55pm UTC](https://discourse.paraview.org/t/resample-to-image-on-point-cloud/10979/9 "2022-12-20T15:55:22Z")

</div>

So fun, I appreciate all the addon growth options from everyone!

Devin
