[vtkusers] How to extract vtkImageData from vtkDICOMImageReader

Prashanth Udupa prashanth.udupa at gmail.com
Sun Mar 21 09:58:20 EDT 2010


You could also do this..

vtkDICOMImageReader* reader = vtkDICOMImageReader::New();
reader->...
reader->Update();

vtkImageData* image = reader->GetOutput();
image->Register();

reader->Delete();

This way image will exist even after the reader is deleted...

/ Prashanth

2010/3/21 Xiaofeng Z <xf10036 at hotmail.com>:
> Thanks for your reply.  I also found out that if I first create a
> vtkImageData object and pass it into vtkDICOMImageReader for it to use as
> output, the vtkImageData object will retain itself when vtkDICOMImageReader
> is deleted:
>
> vtkImageData* image = vtkImageData::New();
> reader.SetOutput(image);
> ...
>
> Is this a safe way to do?
>
> Thanks!
>
> Xiaofeng
>
>
>
>
> ________________________________
> Date: Sun, 21 Mar 2010 13:11:50 +0900
> Subject: Re: [vtkusers] How to extract vtkImageData from vtkDICOMImageReader
> From: wangjunchen at gmail.com
> To: xf10036 at hotmail.com; vtkusers at vtk.org
>
> because when you delete the reader, the imagedate(reader->GetOutput()) has a
> reference count 0 , so it is also recycled.
> if you want to pertain the output of the reader, you can do either:
> 1. connect the output to the vtk pipeline
> or
> 2.  vtkImageData * img = vtkImageData::New();
>     img->DeepCopy(reader->GetOutput());
>     reader->Delete();
>     // then you can access to the img...
>
> 2010/3/21 Xiaofeng Z <xf10036 at hotmail.com>
>
> Hello,
>
> I use vtkDICOMImageReader to load a CT series:
>
> vtkDICOMImageReader* reader = vtkDICOMImageReader::New();
> reader.SetDirectoryName("...");
> reader->Update();
> vtkImageData* image = reader->GetOutput();
>
> I was able to load the CT series without issue.  The problem is as soon as I
> call reader::Delete(), the data in "image" appeared to be wiped out.  Is
> there anyway to retain the vtkImageData object without having to keep the
> vtkDICOMImageReader object?
>
> Thanks!
>
> Xiaofeng Zhao
>
>
>
> ________________________________
> Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
> Learn More.
> _______________________________________________
> 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
>
>
>
>
> --
> 人生就像一个刷牙缸,你可以认为它是杯具,也可以认为它是洗具
>
> ________________________________
> Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
> Learn More.
> _______________________________________________
> 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
>
>



-- 
Thanks and Warm Regards,
Prashanth N Udupa

prashanth.udupa at gmail.com
http://www.prashanthudupa.com
http://prashanthudupa.livejournal.com/



More information about the vtkusers mailing list