[vtkusers] Creating an ImageData from the bounds of a PolyData

Jérôme jerome.velut at gmail.com
Tue Dec 8 17:34:59 EST 2009


I didn't mention the image iterator... In fact, I even didn't know that it
exists! Although I am quite young, I use the ancient way of
iterating the scalar pointer:

<!!Pseudocode mode!!>

inPointer = input->GetScalarPointer( );
outPointer = output->GetScalarPointer( );
for( #number of component )
   for( #zextent )
      for( #yextent )
        for(  #xextent )
            *outPointer = ComputeSomethingWith( inPointer )
             outPointer++;
             inPointer++;

<!! End of pseudocode !! >

A useful information is given by the increments that allow easy "offsetting"
on x, y or z directly without having to triple-for-looping
as I do.

A quick look to vtkImageIterator and its UML diagram gave me the reason why
you cannot use ::New( ) for instanciation: this class is not a vtkObject.
This is a simple helper templated class. I am not of more help regarding the
linking error, sorry for that...

Jerome




2009/12/8 David Doria <daviddoria+vtk at gmail.com <daviddoria%2Bvtk at gmail.com>
>

> On Tue, Dec 8, 2009 at 4:53 PM, Jérôme <jerome.velut at gmail.com> wrote:
> >>
> >> Jerome,
> >>
> >> Have you put this anywhere? It seems like a reasonable thing to add to
> >> VTK, no?
> >>
> >
> > Mmmmm yes... Attached, with my previous mail ;)
> > I think I will put it in my soon-very-soon-ready-for-diffusion Chiron
> module
> > (http://github.com/jeromevelut/Chiron). I will advertise this medical
> > imaging ParaView plugin... soon.
> >
> >>
> >> Another thing - how do you get the coordinates of the center of a cell
> >> in an ImageData? The
> >> vtkCell* GetCell(vtkIdType cellId)
> >>
> >>
> >> seems to be linearly indexed, why does
> >>
> >> vtkCell* GetCell(int i, int j, int k)
> >>
> >> not exist?
> >>
> >
> > I don't use the vtkCell object. I use the scalar pointer for data
> traversal.
> > The point Idx is linear, but you can easily compute the image coordinate
> > from the id (and vice-versa) if you know the number of scalar components
> and
> > the extent. In the same way, David G -too much David here... I will name
> you
> > all Jerome in the futur- gave you the function that computes
> image_id[i,j,k]
> > from world_coord[x,y,z]. It is also reversible.
> >
> > I think that some helper functions exist in vtkImageData for these
> > translations, but I cannot remember which.
> >
> >>
> >> Thanks,
> >
> > You are welcome, Jerome
> >>
> >> David
> >
> >
> > Jerome
>
> Yes, I saw the files in the email, haha.
>
> Based on what David G explained, I believe I have setup the ImageData
> correctly. Of course it is reversible, but then you still have to deal
> with all the nonsense every time you write code to do something like
> this. I am suggesting that it should be included with the vtkImageData
> class. When you ask for the cell/voxel center, there is even more of a
> mess that shows up in the form of spacing/2 in all dimensions to get
> from the corner of the cell to the center of the cell. This mess
> should be dealt with/though about only once and then wrapped into
> nice, intuitive accessors for users.
>
> You mentioned the image iterator - I tried to make an example:
> http://www.vtk.org/Wiki/VTK_Examples_vtkImageIterator
>
> But it is giving me linking errors - is there a different library I
> need to link to? Or have I just used it incorrectly? Jerome, would you
> mind tweaking this example or explaining how you use it so I can fix
> it? It seems to be very different than most VTK objects as the tests
> show it being instantiated with "new vtkImageIterator" rather than the
> typical ::New() that VTK provides - why is that?
>
> Thanks,
>
> David
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091208/7d19219d/attachment.htm>


More information about the vtkusers mailing list