[Insight-users] How to show dicoms with vtk (ImageToVTKImageFilter)

Dženan Zukić dzenanz at gmail.com
Tue Jul 19 03:55:54 EDT 2011


Check out this example:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/VolumeRendering/itkVtkImageConvert
You can also check out the other examples too:
http://www.vtk.org/Wiki/VTK/Examples/Cxx#Volume_Rendering

HTH,
Dženan

On Tue, Jul 19, 2011 at 04:02, John Drozd <john.drozd at gmail.com> wrote:

> Hi,
>
> When I am unsure about the pixel type, I load the dicom image into 3D
> Slicer (freely available at www.slicer.org), and click the Display and
> Info Tab which shows the pixel type.  Then when I code in ITK, I use that
> pixel type.  I hope this helps you.  Slicer will display the dicom image
> using the correct pixel type and tell you what the pixel type is.
>
> Take care,
> John
>
> On Sun, Jul 17, 2011 at 10:25 PM, soheilghafurian <
> soheilghafurian at yahoo.com> wrote:
>
>> My problem is I load a dicom file and I try to show it through vtk by
>> ImageToVTKImageFilter. But the result is kind of distorted. I think the
>> problem is because the pixeltype is not good, but when I use another type,
>> I
>> get this message when the program is running:
>>
>> ERROR: In ..\..\Rendering\vtkImageActor.cxx, line 267
>> vtkOpenGLImageActor (058C5340): This filter requires unsigned char scalars
>> as input
>>
>> Could anyone help me on how I should solve this problem? here is the code:
>>
>> int main()
>> {
>>        char *fName = fl_file_chooser("Pick the fixed dicom Image",
>> "*.dcm", ".");
>>      if(fName == NULL) return 0;
>>
>>          typedef itk::Image< unsigned char, 2> ImageType;
>>  typedef itk::ImageFileReader<ImageType>             ReaderType;
>>  typedef itk::ImageToVTKImageFilter<ImageType>       ConnectorType;
>>
>>  ReaderType::Pointer reader = ReaderType::New();
>>  ConnectorType::Pointer connector = ConnectorType::New();
>>
>>  reader->SetFileName(fName);
>>  reader->Update();
>>  connector->SetInput(reader->GetOutput());
>>
>>
>>
>>  vtkSmartPointer<vtkImageActor> actor =
>>    vtkSmartPointer<vtkImageActor>::New();
>> //  actor->SetInput(connector->GetOutput());
>>  actor->SetInput(connector->GetOutput());
>>
>>  vtkSmartPointer<vtkRenderer> renderer =
>>    vtkSmartPointer<vtkRenderer>::New();
>>  renderer->AddActor(actor);
>>  renderer->ResetCamera();
>>
>>  vtkSmartPointer<vtkRenderWindow> renderWindow =
>>    vtkSmartPointer<vtkRenderWindow>::New();
>>  renderWindow->AddRenderer(renderer);
>>
>>  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
>>    vtkSmartPointer<vtkRenderWindowInteractor>::New();
>>  vtkSmartPointer<vtkInteractorStyleImage> style =
>>    vtkSmartPointer<vtkInteractorStyleImage>::New();
>>
>>  renderWindowInteractor->SetInteractorStyle(style);
>>
>>  renderWindowInteractor->SetRenderWindow(renderWindow);
>>  renderWindowInteractor->Initialize();
>>
>>  renderWindowInteractor->Start();
>>
>>  return EXIT_SUCCESS;
>> }
>>
>>
>>
>> --
>> View this message in context:
>> http://itk-insight-users.2283740.n2.nabble.com/How-to-show-dicoms-with-vtk-ImageToVTKImageFilter-tp6593222p6593222.html
>> Sent from the ITK Insight Users mailing list archive at Nabble.com.
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>
>
>
> --
> John Drozd
> Post-Doctoral Fellow, Robarts Research Institute
> The University of Western Ontario
> London, ON, Canada
> http://publish.uwo.ca/~jdrozd2/index.htm
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110719/850d215d/attachment.htm>


More information about the Insight-users mailing list