[vtkusers] Convert a series of DICOM files into a VTI File

kenichiro yoshimi rccm.kyoshimi at gmail.com
Wed Oct 17 01:11:42 EDT 2018


Hi,

Using vtkExtractVOI is a convenient way of deducing image data size.
If specifying the SampleRate=(2,2,2), the result has a volume 1/8th
the original size.

  // Read all the DICOM files in the specified directory.
  auto reader = vtkSmartPointer<vtkDICOMImageReader>::New();
  reader->SetDirectoryName(inputFoldername.c_str());
  reader->Update();

  int* extent = reader->GetOutput()->GetExtent();

  auto extractVOI = vtkSmartPointer<vtkExtractVOI>::New();
  extractVOI->SetInputData(reader->GetOutput());
  extractVOI->SetVOI(extent);
  extractVOI->SetSampleRate(2, 2, 2);
  extractVOI->Update();

  // write vti
  auto writer = vtkSmartPointer<vtkXMLImageDataWriter>::New();
  writer->SetFileName("head.vti");
  writer->SetInputData(extractVOI->GetOutput());
  writer->Write();

Best
2018年10月17日(水) 11:17 HinhCT <hinh1108 at gmail.com>:
>
> Hi,
>
> I need to write a vti file that can be opened in volView or paraveiw.
> I use the below code to convert a series of DICOM files into a vti file. But
> the output file size is too big,I want to reduce the size of it.
>
> // Read all the DICOM files in the specified directory.
> vtkSmartPointer<vtkDICOMImageReader> reader =
>                 vtkSmartPointer<vtkDICOMImageReader>::New();
> reader->SetDirectoryName(inputFoldername.c_str());
> reader->Update();
>
> //write vti
> vtkSmartPointer<vtkXMLImageDataWriter> writer =
> vtkSmartPointer<vtkXMLImageDataWriter>::New();
> writer->SetFileName("head.vti");
> writer-> SetInputData(reader->GetOutput());
> writer->Write();
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers


More information about the vtkusers mailing list