15 #ifndef itkUCLBSplineTransform_h
16 #define itkUCLBSplineTransform_h
21 #include <itkImageRegion.h>
22 #include <itkVector.h>
23 #include <itkArray2D.h>
25 #include <itkContinuousIndex.h>
26 #include <itkImageRegionIterator.h>
27 #include <itkSingleValuedCostFunction.h>
53 unsigned int NDimensions,
54 class TDeformationScalar
74 itkStaticConstMacro(SpaceDimension,
unsigned int, NDimensions);
143 virtual void SetIdentity();
150 void Initialize(FixedImagePointer fixedImage, GridSpacingType finalGridSpacingInMillimetres,
int numberOfLevels);
153 void InterpolateNextGrid(FixedImagePointer fixedImage);
166 void SetParameters(
const ParametersType & parameters);
169 virtual const ParametersType& GetFixedParameters(
void)
const;
172 virtual void SetFixedParameters(
const ParametersType& parameters);
175 MeasureType GetBendingEnergy();
178 itkGetMacro(BendingEnergyHasBeenUpdatedFlag,
bool);
181 void GetBendingEnergyDerivative(DerivativeType & derivative);
184 void GetBendingEnergyDerivativeDaniel(DerivativeType & derivative);
187 void GetBendingEnergyDerivativeMarc(DerivativeType & derivative);
190 itkGetObjectMacro(Grid, GridImageType);
200 virtual OutputPointType TransformPoint(
const InputPointType &point )
const;
208 void PrintSelf(std::ostream &os, Indent indent)
const;
212 void operator=(
const Self&);
215 const static unsigned int s_LookupTableRows = 1000;
216 const static unsigned int s_LookupTableSize = s_LookupTableRows - 1;
217 const static unsigned int s_LookupTableCols = 4;
220 GridImagePointer m_Grid;
221 GridImagePointer m_OldGrid;
224 bool m_BendingEnergyHasBeenUpdatedFlag;
225 BendingEnergyImagePointer m_BendingEnergyGrid;
226 BendingEnergyDerivativeFilterPointer m_BendingEnergyDerivativeFilter;
229 void InterpolateDeformationField2D();
232 void InterpolateDeformationField3DDaniel();
235 void InterpolateDeformationField3DMarc();
238 MeasureType GetBendingEnergy2D(TScalarType
divisor)
const;
241 MeasureType GetBendingEnergy3DDaniel(TScalarType
divisor)
const;
244 MeasureType GetBendingEnergy3DMarc(TScalarType
divisor)
const;
247 void InterpolateNextGrid2D(GridImagePointer& oldGrid, GridImagePointer &newGrid);
250 void InterpolateNextGrid3D(GridImagePointer& oldGrid, GridImagePointer &newGrid);
253 TScalarType GetNewOrigin(TScalarType oldSize, TScalarType oldSpacing, TScalarType oldOrigin, TScalarType newSize, TScalarType newSpacing);
256 void InitializeGrid(FixedImagePointer fixedImage,
257 GridRegionType gridRegion,
258 GridSpacingType gridSpacing,
259 GridDirectionType gridDirection,
260 GridOriginType gridOrigin);
263 Array2D<TScalarType> m_Lookup;
264 Array2D<TScalarType> m_Lookup1stDerivative;
265 Array2D<TScalarType> m_Lookup2ndDerivative;
267 TScalarType B0(TScalarType u) {
return ((1-u)*(1-u)*(1-u))/6.0; }
268 TScalarType B1(TScalarType u) {
return (3*u*u*u - 6*u*u + 4)/6.0; }
269 TScalarType B2(TScalarType u) {
return (-3*u*u*u + 3*u*u + 3*u + 1)/6.0; }
270 TScalarType B3(TScalarType u) {
return (u*u*u)/6.0; }
271 TScalarType B01(TScalarType u) {
return -(1-u)*(1-u)/2.0; }
272 TScalarType B11(TScalarType u) {
return (9*u*u - 12*u)/6.0; }
273 TScalarType B21(TScalarType u) {
return (-9*u*u + 6*u + 3)/6.0; }
274 TScalarType B31(TScalarType u) {
return (u*u)/2.0; }
275 TScalarType B02(TScalarType u) {
return 1-u; }
276 TScalarType B12(TScalarType u) {
return 3*u - 2; }
277 TScalarType B22(TScalarType u) {
return -3*u + 1; }
278 TScalarType B32(TScalarType u) {
return u; }
280 TScalarType B(
int i, TScalarType u)
283 case 0:
return B0(u);
284 case 1:
return B1(u);
285 case 2:
return B2(u);
286 case 3:
return B3(u);
291 TScalarType B1(
int i, TScalarType u)
294 case 0:
return B01(u);
295 case 1:
return B11(u);
296 case 2:
return B21(u);
297 case 3:
return B31(u);
302 TScalarType B2(
int i, TScalarType u)
305 case 0:
return B02(u);
306 case 1:
return B12(u);
307 case 2:
return B22(u);
308 case 3:
return B32(u);
313 TScalarType B(
int i,
int derivative, TScalarType u)
316 case 0:
return B(i, u);
317 case 1:
return B1(i, u);
318 case 2:
return B2(i, u);
328 #ifndef ITK_MANUAL_INSTANTIATION
329 #include "itkUCLBSplineTransform.txx"
ImageType::SizeType SizeType
Definition: niftkMakeLapUSProbeBasicModel.cxx:31
SmartPointer< Self > Pointer
Definition: itkScalarImageToNormalizedGradientVectorImageFilter.h:82
Vector< VectorDataType, itkGetStaticConstMacro(Dimension) > OutputPixelType
Definition: itkScalarImageToNormalizedGradientVectorImageFilter.h:98
GLuint divisor
Definition: glew.h:2372
Definition: niftkITKAffineResampleImage.cxx:74
ImageType::IndexType IndexType
Definition: niftkMakeLapUSProbeBasicModel.cxx:32
itk::Point< double, 2 > InputPointType
Definition: EulerAffine2DJacobianTest.cxx:34
Simultaneous itk::Image and itk::Array (and hence vnl_vector) class.
This class takes scalar image as input, and outputs a vector field of image gradient.
Definition: itkScalarImageToNormalizedGradientVectorImageFilter.h:67
itk::Point< double, 2 > OutputPointType
Definition: EulerAffine2DJacobianTest.cxx:35
GLsizei const GLcharARB ** string
Definition: glew.h:5194
itk::Array2D< double > JacobianType
Definition: EulerAffine2DJacobianTest.cxx:28