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<br>iterating the scalar pointer:<br><br><!!Pseudocode mode!!><br><br>inPointer = input->GetScalarPointer( );<br>
outPointer = output->GetScalarPointer( );<br>
for( #number of component )<br> for( #zextent )<br> for( #yextent )<br>
for( #xextent )<br> *outPointer = ComputeSomethingWith( inPointer )<br> outPointer++;<br> inPointer++;<br><br><!! End of pseudocode !! ><br><br>A useful information is given by the increments that allow easy "offsetting" on x, y or z directly without having to triple-for-looping<br>
as I do.<br><br>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...<br>
<br>Jerome<br><br><br>
<br><br><div class="gmail_quote">2009/12/8 David Doria <span dir="ltr"><<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">On Tue, Dec 8, 2009 at 4:53 PM, Jérôme <<a href="mailto:jerome.velut@gmail.com">jerome.velut@gmail.com</a>> wrote:<br>
>><br>
>> Jerome,<br>
>><br>
>> Have you put this anywhere? It seems like a reasonable thing to add to<br>
>> VTK, no?<br>
>><br>
><br>
> Mmmmm yes... Attached, with my previous mail ;)<br>
> I think I will put it in my soon-very-soon-ready-for-diffusion Chiron module<br>
> (<a href="http://github.com/jeromevelut/Chiron" target="_blank">http://github.com/jeromevelut/Chiron</a>). I will advertise this medical<br>
> imaging ParaView plugin... soon.<br>
><br>
>><br>
>> Another thing - how do you get the coordinates of the center of a cell<br>
>> in an ImageData? The<br>
>> vtkCell* GetCell(vtkIdType cellId)<br>
>><br>
>><br>
>> seems to be linearly indexed, why does<br>
>><br>
>> vtkCell* GetCell(int i, int j, int k)<br>
>><br>
>> not exist?<br>
>><br>
><br>
> I don't use the vtkCell object. I use the scalar pointer for data traversal.<br>
> The point Idx is linear, but you can easily compute the image coordinate<br>
> from the id (and vice-versa) if you know the number of scalar components and<br>
> the extent. In the same way, David G -too much David here... I will name you<br>
> all Jerome in the futur- gave you the function that computes image_id[i,j,k]<br>
> from world_coord[x,y,z]. It is also reversible.<br>
><br>
> I think that some helper functions exist in vtkImageData for these<br>
> translations, but I cannot remember which.<br>
><br>
>><br>
>> Thanks,<br>
><br>
> You are welcome, Jerome<br>
>><br>
>> David<br>
><br>
><br>
> Jerome<br>
<br>
</div></div>Yes, I saw the files in the email, haha.<br>
<br>
Based on what David G explained, I believe I have setup the ImageData<br>
correctly. Of course it is reversible, but then you still have to deal<br>
with all the nonsense every time you write code to do something like<br>
this. I am suggesting that it should be included with the vtkImageData<br>
class. When you ask for the cell/voxel center, there is even more of a<br>
mess that shows up in the form of spacing/2 in all dimensions to get<br>
from the corner of the cell to the center of the cell. This mess<br>
should be dealt with/though about only once and then wrapped into<br>
nice, intuitive accessors for users.<br>
<br>
You mentioned the image iterator - I tried to make an example:<br>
<a href="http://www.vtk.org/Wiki/VTK_Examples_vtkImageIterator" target="_blank">http://www.vtk.org/Wiki/VTK_Examples_vtkImageIterator</a><br>
<br>
But it is giving me linking errors - is there a different library I<br>
need to link to? Or have I just used it incorrectly? Jerome, would you<br>
mind tweaking this example or explaining how you use it so I can fix<br>
it? It seems to be very different than most VTK objects as the tests<br>
show it being instantiated with "new vtkImageIterator" rather than the<br>
typical ::New() that VTK provides - why is that?<br>
<br>
Thanks,<br>
<font color="#888888"><br>
David<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</div></div></blockquote></div><br>