vtkImageReslice problem on multi-frame DICOMs
OS: Windows 10 VTK: v9.0.0
I am using vtkImageReslice
to extract interpolated slices of a DICOM dataset to store them as preview images in JPEG format with the vtkJPEGWriter
.
With single-frame DICOMS this works as expected but with multi-frame DICOMS, the output of the vtkImageReslice
filter returns a vtkImageData
with correct dimensionality, but a big number of components (one component for each frame within the dataset).
When invoking the vtkJPEGWriter
I get error messages that the maximum supported number of components are exceeded (e.g. 414 > 10
in my case).
What's the preferred method to get interpolated slices out of the multi-frame DICOM to store them as JPEG images?
Example code: Input: multi-frame DICOM with 414 frames
// Reading in the image and orientation computation not shown here
// Extract a slice in the desired orientation
vtkSmartPointer<vtkImageReslice> reslice =
vtkSmartPointer<vtkImageReslice>::New();
reslice->SetInputConnection(_dicomReader->GetOutputPort());
reslice->SetOutputDimensionality(2);
reslice->SetResliceAxes(resliceAxes);
reslice->SetInterpolationModeToLinear();
double range[2];
_dicomReader->GetOutput()->GetScalarRange(range);
//set backgroundlevel
reslice->SetBackgroundLevel(range[0]);
reslice->AutoCropOutputOn();
reslice->SetOutputExtent(imageDimensions);
reslice->SetOutputSpacing(imageSpacing);
reslice->Update();