or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-data-structures.mdimage-processing.mdindex.mdio-operations.mdmathematical-operations.mdmesh-processing.mdregistration.mdsegmentation.mdspatial-objects.md

registration.mddocs/

0

# Registration Framework

1

2

ITK's registration framework provides comprehensive algorithms for aligning and registering multiple image datasets. The framework follows a modular design with pluggable components for metrics, transforms, optimizers, and interpolators.

3

4

## Core Registration Components

5

6

### ImageRegistrationMethod

7

8

Main registration pipeline class that coordinates all registration components.

9

10

```cpp { .api }

11

template<typename TFixedImage, typename TMovingImage>

12

class ImageRegistrationMethod : public ProcessObject

13

{

14

public:

15

typedef ImageRegistrationMethod Self;

16

typedef ProcessObject Superclass;

17

typedef SmartPointer<Self> Pointer;

18

typedef SmartPointer<const Self> ConstPointer;

19

20

static Pointer New();

21

22

// Input images

23

void SetFixedImage(const FixedImageType * fixedImage);

24

itkGetConstObjectMacro(FixedImage, FixedImageType);

25

26

void SetMovingImage(const MovingImageType * movingImage);

27

itkGetConstObjectMacro(MovingImage, MovingImageType);

28

29

// Registration components

30

void SetMetric(MetricType * metric);

31

itkGetObjectMacro(Metric, MetricType);

32

33

void SetOptimizer(OptimizerType * optimizer);

34

itkGetObjectMacro(Optimizer, OptimizerType);

35

36

void SetTransform(TransformType * transform);

37

itkGetObjectMacro(Transform, TransformType);

38

39

void SetInterpolator(InterpolatorType * interpolator);

40

itkGetObjectMacro(Interpolator, InterpolatorType);

41

42

// Region specification

43

void SetFixedImageRegion(const FixedImageRegionType & region);

44

itkGetConstReferenceMacro(FixedImageRegion, FixedImageRegionType);

45

46

// Initial parameters

47

void SetInitialTransformParameters(const ParametersType & param);

48

itkGetConstReferenceMacro(InitialTransformParameters, ParametersType);

49

50

// Results

51

itkGetConstReferenceMacro(LastTransformParameters, ParametersType);

52

53

// Execution

54

void StartRegistration();

55

virtual void Update() ITK_OVERRIDE;

56

};

57

```

58

59

### MultiResolutionImageRegistrationMethod

60

61

Multi-scale registration for improved robustness and speed.

62

63

```cpp { .api }

64

template<typename TFixedImage, typename TMovingImage>

65

class MultiResolutionImageRegistrationMethod : public ImageRegistrationMethod<TFixedImage, TMovingImage>

66

{

67

public:

68

typedef MultiResolutionImageRegistrationMethod Self;

69

typedef ImageRegistrationMethod<TFixedImage, TMovingImage> Superclass;

70

typedef SmartPointer<Self> Pointer;

71

typedef SmartPointer<const Self> ConstPointer;

72

73

static Pointer New();

74

75

// Pyramid generation

76

void SetFixedImagePyramid(FixedImagePyramidType * pyramid);

77

itkGetObjectMacro(FixedImagePyramid, FixedImagePyramidType);

78

79

void SetMovingImagePyramid(MovingImagePyramidType * pyramid);

80

itkGetObjectMacro(MovingImagePyramid, MovingImagePyramidType);

81

82

// Resolution levels

83

void SetNumberOfLevels(unsigned long numberOfLevels);

84

itkGetConstMacro(NumberOfLevels, unsigned long);

85

86

itkGetConstMacro(CurrentLevel, unsigned long);

87

88

// Schedule control

89

void SetSchedules(const ScheduleType & fixedImageSchedule,

90

const ScheduleType & movingImageSchedule);

91

void SetFixedImagePyramidSchedule(const ScheduleType & schedule);

92

void SetMovingImagePyramidSchedule(const ScheduleType & schedule);

93

94

itkGetConstReferenceMacro(FixedImagePyramidSchedule, ScheduleType);

95

itkGetConstReferenceMacro(MovingImagePyramidSchedule, ScheduleType);

96

};

97

```

98

99

## Similarity Metrics

100

101

### ImageToImageMetric

102

103

Base class for image similarity metrics.

104

105

```cpp { .api }

106

template<typename TFixedImage, typename TMovingImage>

107

class ImageToImageMetric : public SingleValuedCostFunction

108

{

109

public:

110

typedef ImageToImageMetric Self;

111

typedef SingleValuedCostFunction Superclass;

112

typedef SmartPointer<Self> Pointer;

113

typedef SmartPointer<const Self> ConstPointer;

114

115

// Image inputs

116

void SetFixedImage(const FixedImageType * image);

117

itkGetConstObjectMacro(FixedImage, FixedImageType);

118

119

void SetMovingImage(const MovingImageType * image);

120

itkGetConstObjectMacro(MovingImage, MovingImageType);

121

122

// Transform and interpolator

123

void SetTransform(TransformType * transform);

124

itkGetObjectMacro(Transform, TransformType);

125

126

void SetInterpolator(InterpolatorType * interpolator);

127

itkGetObjectMacro(Interpolator, InterpolatorType);

128

129

// Region specification

130

void SetFixedImageRegion(const FixedImageRegionType & region);

131

itkGetConstReferenceMacro(FixedImageRegion, FixedImageRegionType);

132

133

// Sampling

134

void SetNumberOfSpatialSamples(unsigned long numberOfPixels);

135

itkGetConstMacro(NumberOfSpatialSamples, unsigned long);

136

137

// Evaluation methods

138

virtual MeasureType GetValue(const ParametersType & parameters) const ITK_OVERRIDE;

139

virtual void GetDerivative(const ParametersType & parameters,

140

DerivativeType & derivative) const ITK_OVERRIDE;

141

virtual void GetValueAndDerivative(const ParametersType & parameters,

142

MeasureType & value,

143

DerivativeType & derivative) const ITK_OVERRIDE;

144

145

// Initialization

146

virtual void Initialize();

147

148

protected:

149

virtual void ComputeImageDerivatives(const MovingImagePointType & mappedPoint,

150

ImageDerivativesType & gradient,

151

ThreadIdType threadID) const;

152

};

153

```

154

155

### MeanSquaresImageToImageMetric

156

157

Mean squared differences similarity metric.

158

159

```cpp { .api }

160

template<typename TFixedImage, typename TMovingImage>

161

class MeanSquaresImageToImageMetric : public ImageToImageMetric<TFixedImage, TMovingImage>

162

{

163

public:

164

typedef MeanSquaresImageToImageMetric Self;

165

typedef ImageToImageMetric<TFixedImage, TMovingImage> Superclass;

166

typedef SmartPointer<Self> Pointer;

167

typedef SmartPointer<const Self> ConstPointer;

168

169

static Pointer New();

170

171

// Cost function evaluation

172

virtual MeasureType GetValue(const ParametersType & parameters) const ITK_OVERRIDE;

173

virtual void GetDerivative(const ParametersType & parameters,

174

DerivativeType & derivative) const ITK_OVERRIDE;

175

virtual void GetValueAndDerivative(const ParametersType & parameters,

176

MeasureType & value,

177

DerivativeType & derivative) const ITK_OVERRIDE;

178

};

179

```

180

181

### MutualInformationImageToImageMetric

182

183

Mutual information similarity metric for multi-modal registration.

184

185

```cpp { .api }

186

template<typename TFixedImage, typename TMovingImage>

187

class MutualInformationImageToImageMetric : public ImageToImageMetric<TFixedImage, TMovingImage>

188

{

189

public:

190

typedef MutualInformationImageToImageMetric Self;

191

typedef ImageToImageMetric<TFixedImage, TMovingImage> Superclass;

192

typedef SmartPointer<Self> Pointer;

193

typedef SmartPointer<const Self> ConstPointer;

194

195

static Pointer New();

196

197

// Histogram parameters

198

void SetNumberOfSpatialSamples(unsigned long numberOfSamples);

199

void SetFixedImageStandardDeviation(double standardDeviation);

200

void SetMovingImageStandardDeviation(double standardDeviation);

201

202

itkGetConstMacro(FixedImageStandardDeviation, double);

203

itkGetConstMacro(MovingImageStandardDeviation, double);

204

205

// Kernel function

206

void SetKernelFunction(KernelFunctionType * kernelFunction);

207

itkGetObjectMacro(KernelFunction, KernelFunctionType);

208

209

// Cost function evaluation

210

virtual MeasureType GetValue(const ParametersType & parameters) const ITK_OVERRIDE;

211

virtual void GetDerivative(const ParametersType & parameters,

212

DerivativeType & derivative) const ITK_OVERRIDE;

213

virtual void GetValueAndDerivative(const ParametersType & parameters,

214

MeasureType & value,

215

DerivativeType & derivative) const ITK_OVERRIDE;

216

};

217

```

218

219

### NormalizedCorrelationImageToImageMetric

220

221

Normalized correlation similarity metric.

222

223

```cpp { .api }

224

template<typename TFixedImage, typename TMovingImage>

225

class NormalizedCorrelationImageToImageMetric : public ImageToImageMetric<TFixedImage, TMovingImage>

226

{

227

public:

228

typedef NormalizedCorrelationImageToImageMetric Self;

229

typedef ImageToImageMetric<TFixedImage, TMovingImage> Superclass;

230

typedef SmartPointer<Self> Pointer;

231

typedef SmartPointer<const Self> ConstPointer;

232

233

static Pointer New();

234

235

// Intensity scaling

236

void SetSubtractMean(bool subtractMean);

237

itkGetConstMacro(SubtractMean, bool);

238

239

// Cost function evaluation

240

virtual MeasureType GetValue(const ParametersType & parameters) const ITK_OVERRIDE;

241

virtual void GetDerivative(const ParametersType & parameters,

242

DerivativeType & derivative) const ITK_OVERRIDE;

243

virtual void GetValueAndDerivative(const ParametersType & parameters,

244

MeasureType & value,

245

DerivativeType & derivative) const ITK_OVERRIDE;

246

};

247

```

248

249

## Transform Framework

250

251

### Transform

252

253

Base class for geometric transformations.

254

255

```cpp { .api }

256

template<typename TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>

257

class Transform : public TransformBase

258

{

259

public:

260

typedef Transform Self;

261

typedef TransformBase Superclass;

262

typedef SmartPointer<Self> Pointer;

263

typedef SmartPointer<const Self> ConstPointer;

264

265

// Point transformation

266

virtual OutputPointType TransformPoint(const InputPointType & point) const = 0;

267

virtual OutputVectorType TransformVector(const InputVectorType & vector) const;

268

virtual OutputVnlVectorType TransformVector(const InputVnlVectorType & vector) const;

269

virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType & vector) const;

270

271

// Jacobian computation

272

virtual const JacobianType & GetJacobian(const InputPointType & point) const;

273

274

// Parameters

275

virtual void SetParameters(const ParametersType & parameters);

276

virtual const ParametersType & GetParameters() const;

277

virtual void SetFixedParameters(const ParametersType & parameters);

278

virtual const ParametersType & GetFixedParameters() const;

279

280

virtual unsigned int GetNumberOfParameters() const;

281

282

// Transform composition

283

virtual bool IsLinear() const;

284

virtual LightObject::Pointer InternalClone() const ITK_OVERRIDE;

285

};

286

```

287

288

### AffineTransform

289

290

Linear transformation including rotation, scaling, shearing, and translation.

291

292

```cpp { .api }

293

template<typename TScalarType, unsigned int NDimensions>

294

class AffineTransform : public MatrixOffsetTransformBase<TScalarType, NDimensions, NDimensions>

295

{

296

public:

297

typedef AffineTransform Self;

298

typedef MatrixOffsetTransformBase<TScalarType, NDimensions, NDimensions> Superclass;

299

typedef SmartPointer<Self> Pointer;

300

typedef SmartPointer<const Self> ConstPointer;

301

302

static Pointer New();

303

304

// Matrix and offset access

305

virtual void SetMatrix(const MatrixType & matrix);

306

const MatrixType & GetMatrix() const;

307

308

virtual void SetOffset(const OutputVectorType & offset);

309

const OutputVectorType & GetOffset() const;

310

311

// Transformation operations

312

void SetIdentity();

313

void Translate(const OutputVectorType & offset, bool pre = false);

314

void Scale(const OutputVectorType & factor, bool pre = false);

315

void Scale(const TScalarType & factor, bool pre = false);

316

void Rotate2D(TScalarType angle, bool pre = false);

317

void Rotate3D(const OutputVectorType & axis, TScalarType angle, bool pre = false);

318

void Shear(int axis1, int axis2, TScalarType coeff, bool pre = false);

319

320

// Inverse transformation

321

bool GetInverse(Self * inverse) const;

322

InverseTransformBasePointer GetInverseTransform() const ITK_OVERRIDE;

323

};

324

```

325

326

### BSplineTransform

327

328

B-spline deformable transformation for non-rigid registration.

329

330

```cpp { .api }

331

template<typename TScalarType, unsigned int NDimensions, unsigned int VSplineOrder>

332

class BSplineTransform : public Transform<TScalarType, NDimensions, NDimensions>

333

{

334

public:

335

typedef BSplineTransform Self;

336

typedef Transform<TScalarType, NDimensions, NDimensions> Superclass;

337

typedef SmartPointer<Self> Pointer;

338

typedef SmartPointer<const Self> ConstPointer;

339

340

static Pointer New();

341

342

// Grid specification

343

virtual void SetGridRegion(const RegionType & region);

344

itkGetConstMacro(GridRegion, RegionType);

345

346

virtual void SetGridSpacing(const SpacingType & spacing);

347

itkGetConstMacro(GridSpacing, SpacingType);

348

349

virtual void SetGridOrigin(const OriginType & origin);

350

itkGetConstMacro(GridOrigin, OriginType);

351

352

virtual void SetGridDirection(const DirectionType & direction);

353

itkGetConstMacro(GridDirection, DirectionType);

354

355

// Bulk transform

356

void SetBulkTransform(const BulkTransformType * bulkTransform);

357

itkGetConstObjectMacro(BulkTransform, BulkTransformType);

358

359

// Coefficient images

360

virtual void SetCoefficientImages(const CoefficientImageArray & images);

361

const CoefficientImageArray GetCoefficientImages() const;

362

363

// Point transformation

364

virtual OutputPointType TransformPoint(const InputPointType & point) const ITK_OVERRIDE;

365

virtual void TransformPoint(const InputPointType & inputPoint,

366

OutputPointType & outputPoint,

367

WeightsType & weights,

368

ParameterIndexArrayType & indices,

369

bool & inside) const;

370

371

// Jacobian computation

372

virtual const JacobianType & GetJacobian(const InputPointType & point) const ITK_OVERRIDE;

373

virtual void ComputeJacobianWithRespectToParameters(const InputPointType & point,

374

JacobianType & jacobian) const ITK_OVERRIDE;

375

};

376

```

377

378

## Interpolation

379

380

### InterpolateImageFunction

381

382

Base class for image interpolation.

383

384

```cpp { .api }

385

template<typename TInputImage, typename TCoordRep>

386

class InterpolateImageFunction : public ImageFunction<TInputImage, typename TInputImage::PixelType, TCoordRep>

387

{

388

public:

389

typedef InterpolateImageFunction Self;

390

typedef ImageFunction<TInputImage, typename TInputImage::PixelType, TCoordRep> Superclass;

391

typedef SmartPointer<Self> Pointer;

392

typedef SmartPointer<const Self> ConstPointer;

393

394

// Interpolation methods

395

virtual OutputType Evaluate(const PointType & point) const ITK_OVERRIDE = 0;

396

virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index) const = 0;

397

398

// Bounds checking

399

virtual bool IsInsideBuffer(const PointType & point) const;

400

virtual bool IsInsideBuffer(const ContinuousIndexType & index) const;

401

};

402

```

403

404

### LinearInterpolateImageFunction

405

406

Linear interpolation of image values.

407

408

```cpp { .api }

409

template<typename TInputImage, typename TCoordRep>

410

class LinearInterpolateImageFunction : public InterpolateImageFunction<TInputImage, TCoordRep>

411

{

412

public:

413

typedef LinearInterpolateImageFunction Self;

414

typedef InterpolateImageFunction<TInputImage, TCoordRep> Superclass;

415

typedef SmartPointer<Self> Pointer;

416

typedef SmartPointer<const Self> ConstPointer;

417

418

static Pointer New();

419

420

// Interpolation methods

421

virtual OutputType Evaluate(const PointType & point) const ITK_OVERRIDE;

422

virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index) const ITK_OVERRIDE;

423

424

// Derivative computation

425

CovariantVectorType EvaluateDerivative(const PointType & point) const;

426

CovariantVectorType EvaluateDerivativeAtContinuousIndex(const ContinuousIndexType & index) const;

427

};

428

```

429

430

### BSplineInterpolateImageFunction

431

432

B-spline interpolation for smooth image resampling.

433

434

```cpp { .api }

435

template<typename TImageType, typename TCoordRep, typename TCoefficientType>

436

class BSplineInterpolateImageFunction : public InterpolateImageFunction<TImageType, TCoordRep>

437

{

438

public:

439

typedef BSplineInterpolateImageFunction Self;

440

typedef InterpolateImageFunction<TImageType, TCoordRep> Superclass;

441

typedef SmartPointer<Self> Pointer;

442

typedef SmartPointer<const Self> ConstPointer;

443

444

static Pointer New();

445

446

// Spline order

447

void SetSplineOrder(unsigned int splineOrder);

448

itkGetConstMacro(SplineOrder, int);

449

450

// Interpolation methods

451

virtual OutputType Evaluate(const PointType & point) const ITK_OVERRIDE;

452

virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index) const ITK_OVERRIDE;

453

454

// Derivative computation

455

CovariantVectorType EvaluateDerivative(const PointType & point) const;

456

CovariantVectorType EvaluateDerivativeAtContinuousIndex(const ContinuousIndexType & index) const;

457

458

// Higher-order derivatives

459

void EvaluateValueAndDerivative(const PointType & point,

460

OutputType & value,

461

CovariantVectorType & derivative) const;

462

};

463

```

464

465

## Image Pyramids

466

467

### RecursiveMultiResolutionPyramidImageFilter

468

469

Generates multi-resolution image pyramids.

470

471

```cpp { .api }

472

template<typename TInputImage, typename TOutputImage>

473

class RecursiveMultiResolutionPyramidImageFilter : public MultiResolutionPyramidImageFilter<TInputImage, TOutputImage>

474

{

475

public:

476

typedef RecursiveMultiResolutionPyramidImageFilter Self;

477

typedef MultiResolutionPyramidImageFilter<TInputImage, TOutputImage> Superclass;

478

typedef SmartPointer<Self> Pointer;

479

typedef SmartPointer<const Self> ConstPointer;

480

481

static Pointer New();

482

483

// Pyramid generation parameters

484

virtual void SetNumberOfLevels(unsigned int num) ITK_OVERRIDE;

485

void SetSchedule(const ScheduleType & schedule);

486

itkGetConstReferenceMacro(Schedule, ScheduleType);

487

488

// Smoothing control

489

virtual void SetUseShrinkImageFilter(bool useShrinkFilter);

490

itkGetConstMacro(UseShrinkImageFilter, bool);

491

492

protected:

493

virtual void GenerateData() ITK_OVERRIDE;

494

virtual void GenerateOutputInformation() ITK_OVERRIDE;

495

virtual void GenerateOutputRequestedRegion(DataObject * output) ITK_OVERRIDE;

496

};

497

```

498

499

## Common Usage Patterns

500

501

### Basic Rigid Registration

502

503

```cpp

504

// Define image types

505

typedef itk::Image<float, 2> FixedImageType;

506

typedef itk::Image<float, 2> MovingImageType;

507

508

// Registration method

509

typedef itk::ImageRegistrationMethod<FixedImageType, MovingImageType> RegistrationType;

510

RegistrationType::Pointer registration = RegistrationType::New();

511

512

// Transform

513

typedef itk::TranslationTransform<double, 2> TransformType;

514

TransformType::Pointer transform = TransformType::New();

515

registration->SetTransform(transform);

516

517

// Metric

518

typedef itk::MeanSquaresImageToImageMetric<FixedImageType, MovingImageType> MetricType;

519

MetricType::Pointer metric = MetricType::New();

520

registration->SetMetric(metric);

521

522

// Optimizer

523

typedef itk::RegularStepGradientDescentOptimizer OptimizerType;

524

OptimizerType::Pointer optimizer = OptimizerType::New();

525

registration->SetOptimizer(optimizer);

526

527

// Interpolator

528

typedef itk::LinearInterpolateImageFunction<MovingImageType, double> InterpolatorType;

529

InterpolatorType::Pointer interpolator = InterpolatorType::New();

530

registration->SetInterpolator(interpolator);

531

532

// Set images

533

registration->SetFixedImage(fixedImage);

534

registration->SetMovingImage(movingImage);

535

registration->SetFixedImageRegion(fixedImage->GetBufferedRegion());

536

537

// Initialize parameters

538

TransformType::ParametersType initialParameters(transform->GetNumberOfParameters());

539

initialParameters[0] = 0.0; // Initial offset in X

540

initialParameters[1] = 0.0; // Initial offset in Y

541

registration->SetInitialTransformParameters(initialParameters);

542

543

// Configure optimizer

544

optimizer->SetMaximumStepLength(4.00);

545

optimizer->SetMinimumStepLength(0.01);

546

optimizer->SetNumberOfIterations(200);

547

548

// Run registration

549

try {

550

registration->Update();

551

TransformType::ParametersType finalParameters = registration->GetLastTransformParameters();

552

} catch (itk::ExceptionObject & err) {

553

std::cerr << "Registration failed: " << err << std::endl;

554

}

555

```

556

557

## Type Definitions

558

559

```cpp { .api }

560

// Common registration instantiations

561

typedef ImageRegistrationMethod<Image<float,2>, Image<float,2>> Registration2D;

562

typedef ImageRegistrationMethod<Image<float,3>, Image<float,3>> Registration3D;

563

564

typedef MultiResolutionImageRegistrationMethod<Image<float,2>, Image<float,2>> MultiResRegistration2D;

565

typedef MultiResolutionImageRegistrationMethod<Image<float,3>, Image<float,3>> MultiResRegistration3D;

566

567

// Transform types

568

typedef TranslationTransform<double, 2> Translation2D;

569

typedef TranslationTransform<double, 3> Translation3D;

570

typedef AffineTransform<double, 2> Affine2D;

571

typedef AffineTransform<double, 3> Affine3D;

572

573

// Metric types

574

typedef MeanSquaresImageToImageMetric<Image<float,2>, Image<float,2>> MSMetric2D;

575

typedef MutualInformationImageToImageMetric<Image<float,2>, Image<float,2>> MIMetric2D;

576

typedef NormalizedCorrelationImageToImageMetric<Image<float,2>, Image<float,2>> NCMetric2D;

577

578

// Interpolator types

579

typedef LinearInterpolateImageFunction<Image<float,2>, double> LinearInterpolator2D;

580

typedef BSplineInterpolateImageFunction<Image<float,2>, double> BSplineInterpolator2D;

581

typedef NearestNeighborInterpolateImageFunction<Image<float,2>, double> NNInterpolator2D;

582

583

// Parameter and schedule types

584

typedef OptimizerType::ParametersType ParametersType;

585

typedef OptimizerType::ScalesType OptimizerScalesType;

586

typedef MultiResolutionPyramidImageFilter<Image<float,2>, Image<float,2>>::ScheduleType ScheduleType;

587

```

588

589

ITK's registration framework provides a comprehensive, modular approach to image alignment with support for rigid, affine, and deformable transformations across multiple scales and with various similarity metrics.