I am trying to read and save in a raw form a DICOM series. At runtime, the program crashes and the following error is generated:
DICOMParser couldn't parse.
Here is my code:
int main(int argc, char* argv[])
{
// Verify input arguments
std::string folder = "C:/dicom decompress/GM_23/2801/0";
//std::string folder = "C:\\VTK\\vtkdata-5.8.0\\Data\\DicomTestImages";
// Read all the DICOM files in the specified directory.
vtkSmartPointer<vtkDICOMImageReader> reader =
vtkSmartPointer<vtkDICOMImageReader>::New();
reader->SetDirectoryName(folder.c_str());
reader->Update();
vtkSmartPointer<vtkImageWriter> writer = vtkSmartPointer<vtkImageWriter>::New();
writer->SetInputConnection(reader->GetOutputPort());
// writer->SetFilePrefix(folder.c_str());
writer->SetFilePattern("3d.raw");
writer->Write();
writer->Update();
return EXIT_SUCCESS;
}