The snippet you have below is not going to work :<br><br>  vtkImageData* imData = importer-&gt;GetOutput();<br>  imData-&gt;SetSpacing(im-&gt;dx, im-&gt;dy, im-&gt;dz);<br>  surfaceExtractor-&gt;SetInput((vtkDataObject*)imData);<br>
<br>What&#39;s going to happen is that the downstream filter (marching cubes) is going to update the upstream filter (importer) which is going to overwrite the spacing (defaults to 1 in vtkImageImport) set on its output. You can&#39;t modify the output of a pipeline like that without disconnecting it (via ShallowCopy)..<br>
<br>Try this instead...<br><br>  importer-&gt;SetDataSpacing(im-&gt;dx, im-&gt;dy, im-&gt;dz);<br>  vtkImageData* imData = importer-&gt;GetOutput();<br>  surfaceExtractor-&gt;SetInput((vtkDataObject*)imData);<br>
<br>--<br>karthik<br><br><div class="gmail_quote">On Wed, Aug 4, 2010 at 5:29 AM, Zeike Taylor <span dir="ltr">&lt;<a href="mailto:ztaylor@itee.uq.edu.au">ztaylor@itee.uq.edu.au</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<br>
<br>
I&#39;m having trouble with vtkMarchingCubes, and I think it is to do with<br>
the anisotropic voxel sizes (0.9375x0.9375x4mm) of my images. I&#39;m using<br>
nifti images, which I import using vtkImageImport. The marching cubes<br>
algorithm extracts a surface well enough and it can be seen to be<br>
&quot;approximately&quot; correct, however the z-coords are squashed. If I<br>
multiply each z-coord by 4 and redraw, the mesh looks roughly as it<br>
should. However, this is no good as the facets are now stretched in the<br>
z-dir&#39;n, making them unsuitable for the subsequent application.<br>
<br>
My (partial) pipeline is as follows:<br>
<br>
// Load nifti img<br>
nifti_image *im = nifti_image_read(imgName,true);<br>
<br>
// Set up vtk image data<br>
vtkImageImport* importer = vtkImageImport::New();<br>
importer-&gt;SetImportVoidPointer((void*)im-&gt;data);<br>
importer-&gt;SetDataScalarTypeToFloat();<br>
importer-&gt;SetDataExtent(0, im-&gt;nx-1, 0, im-&gt;ny-1, 0, im-&gt;nz-1);<br>
importer-&gt;SetWholeExtent(0, im-&gt;nx-1, 0, im-&gt;ny-1, 0, im-&gt;nz-1);<br>
vtkImageData* imData = importer-&gt;GetOutput();<br>
imData-&gt;SetScalarTypeToFloat();<br>
imData-&gt;SetExtent(0, im-&gt;nx-1, 0, im-&gt;ny-1, 0, im-&gt;nz-1);<br>
imData-&gt;SetSpacing(im-&gt;dx, im-&gt;dy, im-&gt;dz);<br>
<br>
// Apply the Marching Cubes algorithm<br>
vtkMarchingCubes* surfaceExtractor = vtkMarchingCubes::New();<br>
surfaceExtractor-&gt;SetValue(0, isoVal);<br>
surfaceExtractor-&gt;SetInput((vtkDataObject*)imData);<br>
vtkPolyData* surface = surfaceExtractor-&gt;GetOutput();<br>
surfaceExtractor-&gt;Update();<br>
<br>
The image dimensions and spacing seem to transfer properly to imData:<br>
i.e. the vals returned by imData-&gt;GetDimensions() and<br>
imData-&gt;GetSpacing() are correct, but it&#39;s as if vtkMarchingCubes<br>
ignores them. I also tried resampling with isotropic voxels using<br>
vtkImageResample, with no luck.<br>
<br>
Any advice welcome.<br>
Thanks,<br>
Zeike<br>
_______________________________________________<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>
</blockquote></div><br>