Hello everyone!
I am developing a DICOM viewer/segmentation software in C++, using vtk and vtk-dicom to load the images and OpenCV to process them within an Qt GUI.
For the initial loading process, I let a vtkDICOMDirectory browse and sort files in the given input directory, and pass the resulting filenames then to a function where a vtkDICOMReader reads the datasets. The resulting vtkImageDatas are then processed by three function, each of them handling a different axis where the volume is sliced along. The result is then converted to Vectors of cv::Mats and then further processed.
Everything works great and as intended. The functions can even be executed parallel via the Qt concurrent framework. The results are always as expected.
But in comparison to slicing for example in coronal and transverse plane, where the whole volume takes 0.3s and 0.9s respectively, the update call for the sagittal direction takes around 9.6s. Am I doing something wrong by design, or is this expected behavior?
The code for one of my slicing functions is the following:
cv::Mat DICOMReaderInterface::sliceAndConvertVTKVolumeX(const vtkSmartPointer<vtkImageData> &vtkVolume, int slice) {
int imageDimensions[3] = {0, 0, 0};
vtkVolume->GetDimensions(imageDimensions);
int imageHeight = imageDimensions[1];
int imageSlices = imageDimensions[2];
int numberOfImageChannels = vtkVolume->GetNumberOfScalarComponents();
int cvType = CV_16SC1;
if(numberOfImageChannels == 1){
cvType = CV_16SC1;
}else if (numberOfImageChannels == 3){
cvType = CV_16SC3;
}else{
cvType = CV_16SC4;
}
vtkSmartPointer<vtkExtractVOI> extractVOI = vtkSmartPointer<vtkExtractVOI>::New();
extractVOI->SetInputData(vtkVolume);
extractVOI->ReleaseDataFlagOn();
extractVOI->SetVOI(slice,slice,0,imageHeight-1,0,imageSlices-1);
extractVOI->Update();
cv::Mat resultingCVMat = cv::Mat(imageSlices,imageHeight , cvType, extractVOI->GetOutput()->GetScalarPointer());
cv::Mat allignedMat;
cv::transpose(resultingCVMat,resultingCVMat);
cv::flip(resultingCVMat,allignedMat, 0);
convertCVSlice(allignedMat);
return allignedMat;
}
Thank you in advance!
Greetings