[Insight-users] ExtractImageFilter for vector field
Sadegh
sadegh.riyahi at gmail.com
Mon Jul 29 11:01:43 EDT 2013
Hello People!
I have a problem in extracting slices from the 3D deformation field. The
whole story is that I need to perform 3D time series registration, so I have
a 3D image with 500 frames/slices. Simply I need to align the slices on
eachother. The first frame/slice becomes the fixed image and all the other
slices act as the moving image. I was successfully able to perform it on the
scalar images and I even obtained the deformation fields for every frame at
each iteration. Now I'm interested to do Jacobian determinant evaluation on
the deformation field that I obtained (after joining them together), but THE
PROBLEM is that I guess the class ExtractImageFilter does not work with
vector field or "covariant vector" type and it only works on scalar field.
Does anybody know how to extract slices of vector type?
Below is the code I used which doe not work.
Thanks in advance for your help.
//////////////////////////////////////////////////////
#include <itkImage.h>
#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include <itkVectorResampleImageFilter.h>
#include <itkVectorNearestNeighborInterpolateImageFunction.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <fstream>
#include <itkMinimumMaximumImageCalculator.h>
#include <itkDisplacementFieldJacobianDeterminantFilter.h>
#include "itkSplitComponentsImageFilter.h"
#include "itkExtractImageFilter.h"
#include "itkImage.h"
#include "itkImageToVectorImageFilter.h"
#include "itkArray2D.h"
#include "itkCovariantVector.h"
const unsigned int InputImageDimension =3;
const unsigned int FrameDimension =2;
typedef float InputPixelType3D;
typedef itk::Image< InputPixelType3D, InputImageDimension >
InputImageType3D;
typedef itk::Image< InputPixelType3D, FrameDimension > FixedImageType;
FixedImageType::Pointer fixedimage = FixedImageType::New();
typedef itk::Vector< InputPixelType3D, InputImageDimension >
VectorPixelType;
typedef itk::Image< VectorPixelType, InputImageDimension >
InputDeformationFieldType;
typedef itk::ImageFileReader< InputDeformationFieldType >
DeformationFieldReaderType;
typedef itk::Vector< float, 2 > VectorType;
typedef itk::Image< VectorType, 2 > FrameDeformationFieldType;
InputDeformationFieldType::Pointer vectorimage =
InputDeformationFieldType::New();
typedef itk::ExtractImageFilter< InputDeformationFieldType,
InputDeformationFieldType> InputFilterType2D;
////////////////
InputDeformationFieldType::Pointer
extract2DImageSlice(InputDeformationFieldType::Pointer reader, int plane,
int slice) {
reader->UpdateOutputInformation();
InputFilterType2D::Pointer filter = InputFilterType2D::New();
filter->InPlaceOn();
// filter->SetDirectionCollapseToSubmatrix();
filter->SetDirectionCollapseToIdentity();
InputDeformationFieldType::RegionType inputRegion =
reader->GetLargestPossibleRegion();
InputDeformationFieldType::SizeType size = inputRegion.GetSize();
size[plane] = 0;
InputDeformationFieldType::IndexType start = inputRegion.GetIndex();
const unsigned int sliceNumber = slice;
start[plane] = sliceNumber;
InputDeformationFieldType::RegionType desiredRegion;
desiredRegion.SetSize( size );
desiredRegion.SetIndex( start );
filter->SetExtractionRegion( desiredRegion );
filter->SetInput( reader );
InputDeformationFieldType::Pointer img = filter->GetOutput();
img->Update();
return img;
}
///////////////////////////////////////////
-----
Sadegh Riyahi
Politecnico di Milano
--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/ExtractImageFilter-for-vector-field-tp7583612.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
More information about the Insight-users
mailing list