[vtkusers] Convert vtkPointSet to vtkImageData using the scalar associated to each point as the intensity for each voxel
David E DeMarle
dave.demarle at kitware.com
Wed Apr 27 13:04:16 EDT 2011
If the topology is an exact match (same number of cells in i,j and k
dimensions), you should be able to just copy the point and cell data
across en masse.
something like:
id->GetPointData()->ShallowCopy(ps->GetPointData())
id->GetCellData()->ShallowCopy(ps->GetCellData())
ought to work
David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109
On Wed, Apr 27, 2011 at 12:13 PM, Liam Kurmos <quantum.leaf at gmail.com> wrote:
> i set the image scalars like this:
>
> for (int k = 0; k < oc->zDim; k++) {
> for (int j = 0; j < oc->yDim; j++) {
> for (int i = 0; i < oc->xDim; i++) {
> float val=getVoxelValue(i,j,k,step);//gets the value
> vtkVol->SetScalarComponentFromFloat(i, j, k, 0, val);
> //0 is the scalar field index, just use 0 if only one field
> }
> }
> }
>
> though ive just seen in the documentation it says that
> SetScalarComponentFromFloat is 'For access to data from tcl '
> so quite probably there is another way that is prefered. (maybe
> through getpointdata() )
>
> Liam
>
>
> On Wed, Apr 27, 2011 at 3:14 PM, Federico Milano <fmilano at gmail.com> wrote:
>> Yes, the points are arranged in a regular way forming an uniform grid. So I
>> should try to convert it directly to a vtkImageData? Do you have a code
>> fragment to do this?
>>
>> On Wed, Apr 27, 2011 at 10:57 AM, Liam Kurmos <quantum.leaf at gmail.com>
>> wrote:
>>>
>>> Are your points already arranged in a regular array?
>>>
>>> vtkImageData usually uses the scalar values at the points anyway and
>>> the cell value is commonly not used (this is the understanding i came
>>> to anyway).
>>>
>>> Liam
>>>
>>>
>>> On Tue, Apr 26, 2011 at 9:33 PM, Federico Milano <fmilano at gmail.com>
>>> wrote:
>>> > Hi,
>>> >
>>> > I would like to convert vtkPointSet to vtkImageData using the scalar
>>> > associated to each point as the intensity for each voxel, that is
>>> > keeping
>>> > the scalar value associated with the correct voxel in the vtkImageData.
>>> >
>>> >
>>> > Thanks in advance,
>>> >
>>> > Federico
>>> >
>>> > _______________________________________________
>>> > Powered by www.kitware.com
>>> >
>>> > Visit other Kitware open-source projects at
>>> > http://www.kitware.com/opensource/opensource.html
>>> >
>>> > Please keep messages on-topic and check the VTK FAQ at:
>>> > http://www.vtk.org/Wiki/VTK_FAQ
>>> >
>>> > Follow this link to subscribe/unsubscribe:
>>> > http://www.vtk.org/mailman/listinfo/vtkusers
>>> >
>>> >
>>
>>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list