Something similar to the following needs to be part of your solution. It provides conversion from 4DVolume to a 3DVectorVolume.
Hans
include
include
include
typedef itk::VectorImage<unsigned short, 3> VectorVolumeType;
VectorVolumeType::Pointer Convert4DVolumeTo3DVectorVolume(Volume4DType::Pointer inputVol)
{
typedef itk::Image<unsigned short,3> Volume3DType; //Used for a single 3D volume component
// convert from image series to vector voxels
Volume4DType::SpacingType inputSpacing = inputVol->GetSpacing();
Volume4DType::SizeType inputSize = inputVol->GetLargestPossibleRegion().GetSize();
Volume4DType::IndexType inputIndex = inputVol->GetLargestPossibleRegion().GetIndex();
////////
// "inputVol" is read as a 4D image. Here we convert that to a VectorImageType:
//
typedef itk::ExtractImageFilter< Volume4DType, Volume3DType > ExtractFilterType;
Hui,
Something similar to the following needs to be part of your solution. It provides conversion from 4DVolume to a 3DVectorVolume.
Hans
include
include
include
typedef itk::VectorImage<unsigned short, 3> VectorVolumeType; VectorVolumeType::Pointer Convert4DVolumeTo3DVectorVolume(Volume4DType::Pointer inputVol) { typedef itk::Image<unsigned short,3> Volume3DType; //Used for a single 3D volume component // convert from image series to vector voxels Volume4DType::SpacingType inputSpacing = inputVol->GetSpacing(); Volume4DType::SizeType inputSize = inputVol->GetLargestPossibleRegion().GetSize(); Volume4DType::IndexType inputIndex = inputVol->GetLargestPossibleRegion().GetIndex(); //////// // "inputVol" is read as a 4D image. Here we convert that to a VectorImageType: // typedef itk::ExtractImageFilter< Volume4DType, Volume3DType > ExtractFilterType;
typedef itk::ComposeImageFilter<Volume3DType, VectorVolumeType> ComposeImageFilterType; ComposeImageFilterType::Pointer composer= ComposeImageFilterType::New();
for( size_t componentNumber = 0; componentNumber < inputSize[3]; ++componentNumber ) { Volume4DType::SizeType extractSize = inputSize; extractSize[3] = 0; Volume4DType::IndexType extractIndex = inputIndex; extractIndex[3] = componentNumber; Volume4DType::RegionType extractRegion(extractIndex, extractSize);
} composer->Update(); VectorVolumeType::Pointer nrrdVolume = composer->GetOutput(); return nrrdVolume; }