[vtkusers] How to avoid model splatting on a ImageData

Eric E. Monson emonson at cs.duke.edu
Wed Mar 11 13:44:11 EDT 2009


Hey Arturo,

I don't really know anything about the MetaImage format, except what  
I've read on one of the ITK pages, but it looks like you would have  
the same problem saving the flying donut data as a MetaImage file as  
you do with representing it in VTK as vtkImageData: These image data  
formats can only represent a regular structured grid, which is defined  
by its origin, the spacing between pixels or nodes in each direction,  
and the number of pixels or nodes in each direction. This would be a  
rectangular solid in 3D. Your flying donut is stored as a  
vtkUnstructuredGrid in VTK because that data structure can represent  
irregular solids with gaps in 3D space, and to do that, it needs more  
information than just origin, spacing and dimensions. If you really  
need to save this thing as a MetaImage file, it will need to be the  
whole original rectangular solid that you got after the  
vtkImplicitModeller filter, but processed in some way to give scalar  
values of zero outside your donut and some other value inside (i.e. no  
"empty space").

-Eric


On Mar 11, 2009, at 10:26 AM, Arturo Caissut wrote:

> Dear Eric,
>
> ok, I think it worked.
> Now my problem is to save the figure (a flyin' donut surrounded by  
> free space) as a MetaImage file. Maybe I shall use some ITK method?
>
> Arturo
>
>
> Eric E. Monson wrote:
>> Hey Arturo,
>>
>> You can do what you want, but to get "free space" around your  
>> donut, the output will need to be an Unstructured Grid rather than  
>> ImageData (which is just defined in a cube, all filled with points).
>> I think you have the right idea about the vtkImplicitModeller  
>> methods: SetSampleDimensions sets the number of grid points in each  
>> direction, while the SetModelBounds specifies the extent of the  
>> output in the coordinate space of your data. You can try setting it  
>> manually to (-5, 5, -5, 5, -1, 1) if you want. The output of  
>> vtkImplicitModeller is a vtkImageData, so I don't think you have to  
>> create that new "image", just grab the output and pipe it in to  
>> your writer.
>>
>> If you put a threshold filter after the implicit modeller, you'll  
>> get an unstructured grid with "free space" around your donut. (I  
>> just tried it in ParaView, so I don't have VTK code handy.) If you  
>> really need ImageData out, then there may be a way to "zero out"  
>> the values over a certain threshold, but there will still be points  
>> all throughout the rectangular solid space.
>>
>> If this doesn't answer your questions, you may have to clarify in  
>> what way this is "not working" and what you mean by not wanting the  
>> data splatted all over the volume (maybe the "free space" issue?).
>>
>> Talk to you later,
>> -Eric
>>
>> ------------------------------------------------------
>> Eric E Monson
>> Duke Visualization Technology Group
>>
>>
>> On Mar 9, 2009, at 5:46 PM, Arturo Caissut wrote:
>>
>>> Hi,
>>> I need to read a PolyData 3D model, pass it through two filters  
>>> (implicit modeller & image threshold) and then save the resulting  
>>> image on a ImageData.
>>> My problem is that I don't want the resulting model image to be  
>>> "splatted" all over the ImageData extension (with a deformation as  
>>> a collateral result), but I cannot avoid this.
>>> Maybe I'm making some confusion between implicit modeller  
>>> SetSampleDimensions and SetModelBounds, but I'm not sure.
>>>
>>> I'll try to explain myself with an example: let's say I have a  
>>> radius=4 circle stored into a polydata. My aim is to create a  
>>> 50x50x50 MetaImage file whit a radius 4 " donut"on the center, and  
>>> a lot of "free space" all around. I think I should procede with  
>>> something like:
>>> |
>>> vtkPolydataReader *reader = vtkPolyDataReader::New();
>>> reader->SetFileName("something.vtk");
>>>
>>> vtkImplicitModeller *implicit = vtkImplicitModeller::New();
>>> implicit->SetInput(reader->GetOutput());
>>> implicit->SetMaximumDistance(1);         //I don't want my donut  
>>> to be too large
>>> implicit->SetSampleDimensions(50, 50, 50);    //Is this correct?
>>> implicit->SetModelBounds(reader->GetOutput()->GetBounds());
>>> implicit->Update();
>>>
>>> vtkImageData *image = vtkImageData::New();
>>> image->SetDimensions(50, 50, 50);
>>> image->SetOrigin(0.0, 0.0, 0.0);
>>> image->SetSpacing(1,1,1);
>>> image = implicit->GetOutput();
>>> image->Update();
>>>
>>> vtkMetaImageWriter *miwriter = vtkMetaImageWriter::New();
>>> miwriter->SetInput(image);
>>> miwriter->SetFileName("something_else.mhd");
>>> miwriter->Write();|
>>>
>>>
>>> But this doesn't work.
>>> Can you find any error?
>>>
>>>
>>> Thank you,
>>> Arturo
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com <http://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