[vtkusers] Need to save vtkVolume as an 3D image

Lindeval Lima lindeval.ufrr at gmail.com
Tue Sep 3 22:50:26 EDT 2013


my code in python to write a volume as image.

   renWin = vtk.vtkRenderWindow()


    windowToImageFilter = vtk.vtkWindowToImageFilter()
    windowToImageFilter.SetInput(renWin)
    windowToImageFilter.SetMagnification(3)
    windowToImageFilter.SetInputBufferTypeToRGBA()
    windowToImageFilter.Update()

    writer = vtk.vtkJPEGWriter()    #vtkPNGWriter(),...
    writer.SetFileName("screenshot.jpg")
    writer.SetInputConnection(windowToImageFilter.GetOutputPort())
    writer.Write()



2013/9/3 Sahan Ranasinghe <sahancr at gmail.com>

> Dear Dean,
>
> Thank you for your kind response. I did it.
> Thank you very much.
>
> Regards,
> Sahan
>
>
> On Wed, Sep 4, 2013 at 1:09 AM, Dean Inglis <inglis.dl at gmail.com> wrote:
>
>> it looks to me like the image you are finally volume visualizing comes
>> from the continous erode filter.
>> I would instantiate the writer with the output format you want and then:
>> writer->SetInput(dilate->GetOutput());
>>
>>
>>
>> On Tue, Sep 3, 2013 at 2:25 PM, Sahan Ranasinghe <sahancr at gmail.com>wrote:
>>
>>> Dear Dean,
>>>
>>> This is the related part of my code. dataset is the read image series.
>>> you mean I nead to write dataset as image series. Am i right?
>>>
>>> vtkImageContinuousErode3D *dilate=vtkImageContinuousErode3D::New();
>>>  dilate->SetInput(dataset);
>>> dilate->SetKernelSize(3,3,1);
>>>
>>>
>>> vtkRenderer *renderer = vtkRenderer::New();
>>>
>>> vtkVolumeRayCastMIPFunction *mip=vtkVolumeRayCastMIPFunction::New();
>>>  vtkFixedPointVolumeRayCastMapper
>>> *mapper=vtkFixedPointVolumeRayCastMapper::New();
>>>  mapper->SetInput(dilate->GetOutput());
>>> mapper->SetSampleDistance(0.5);
>>> mapper->Update();
>>>
>>> vtkPiecewiseFunction *opacity=vtkPiecewiseFunction::New();
>>> opacity->AddPoint(0,0.0);
>>>  opacity->AddPoint(1,1.0);
>>>
>>> vtkVolumeProperty *property=vtkVolumeProperty::New();
>>> property->IndependentComponentsOff();
>>>  property->SetScalarOpacity(opacity);
>>>
>>> vtkVolume *volume=vtkVolume::New();
>>> volume->SetMapper(mapper);
>>>  volume->SetProperty(property);
>>> volume->Update();
>>>
>>> Thank you for your help.
>>>
>>> Regards,
>>> Sahan
>>>
>>>
>>> On Tue, Sep 3, 2013 at 11:48 PM, Dean Inglis <inglis.dl at gmail.com>wrote:
>>>
>>>> vtkVolume inherits from vtkProp3D: an object that is rendered.
>>>> It is not a data container (eg., vtkDataObject) and is therefore not
>>>> something you can write to disk.
>>>> As you stated, you already have your 3D image (data) in .raw file
>>>> format.
>>>> You could save it in another format (one single file or multiple files)
>>>> if needed:
>>>>
>>>> vtkNew<vtkSome_Kind_Of_Image_Writer> writer;
>>>> writer->SetInput( my_Raw_Image_Data_Reader->GetOutput() );
>>>> writer->SetFileName( a_name );
>>>> writer->Write();
>>>>
>>>> regards
>>>> Dean
>>>>
>>>>
>>>> On Tue, Sep 3, 2013 at 1:30 PM, Sahan Ranasinghe <sahancr at gmail.com>wrote:
>>>>
>>>>> I used VHP dataset (.raw) format images. first read all images and
>>>>> then use VolumeRayCastMapper, VolumeProperty and generate a vtkVolume
>>>>> object. It is visualized as i expected. Now I need to save this vtkVolume
>>>>> object as a 3D image.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Regards,
>>>>> Sahan
>>>>>
>>>>>
>>>>> On Tue, Sep 3, 2013 at 9:56 PM, Jude Pereira <jpereira at advsolinc.com>wrote:
>>>>>
>>>>>>  Do you mean like a rendering of a 3D object in png? Or output as an
>>>>>> obj solid? Or something else?****
>>>>>>
>>>>>> ** **
>>>>>>
>>>>>> Jude****
>>>>>>
>>>>>> ** **
>>>>>>
>>>>>> *From:* vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] *On
>>>>>> Behalf Of *Sahan Ranasinghe
>>>>>> *Sent:* Tuesday, September 03, 2013 11:51 AM
>>>>>> *To:* vtkusers at vtk.org
>>>>>> *Subject:* [vtkusers] Need to save vtkVolume as an 3D image****
>>>>>>
>>>>>> ** **
>>>>>>
>>>>>> ** **
>>>>>>
>>>>>> ** **
>>>>>>
>>>>>> Hi,****
>>>>>>
>>>>>> ** **
>>>>>>
>>>>>> I need to save a vtkvolume object as a 3D image. Can you please give
>>>>>> me any suggestion?****
>>>>>>
>>>>>> ** **
>>>>>>
>>>>>> Thank you.****
>>>>>>
>>>>>> ** **
>>>>>>
>>>>>> Regards,****
>>>>>>
>>>>>> Sahan****
>>>>>>
>>>>>> ** **
>>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130903/dae7eca2/attachment.htm>


More information about the vtkusers mailing list