Developer documentation
Version 3.0.3-105-gd3941f44
transform.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __image_transform_h__
18#define __image_transform_h__
19
20#include "types.h"
21
22namespace MR
23{
24 class Transform { MEMALIGN(Transform)
25 public:
26
28 template <class HeaderType>
29 Transform (const HeaderType& header) :
30 voxelsize (header.spacing(0), header.spacing(1), header.spacing(2)),
31 voxel2scanner (header.transform() * voxelsize),
32 scanner2voxel (voxel2scanner.inverse()),
33 image2scanner (header.transform()),
34 scanner2image (image2scanner.inverse()) { }
35
36
37 Transform (const Transform&) = default;
38 Transform (Transform&&) = default;
39 Transform& operator= (const Transform&) = delete;
40 Transform& operator= (Transform&&) = delete;
41
42 const Eigen::DiagonalMatrix<default_type, 3> voxelsize;
44
45
46 template <class HeaderType>
47 static inline transform_type get_default (const HeaderType& header) {
49 M.setIdentity();
50 M.translation() = Eigen::Vector3d (
51 -0.5 * (header.size (0)-1) * header.spacing (0),
52 -0.5 * (header.size (1)-1) * header.spacing (1),
53 -0.5 * (header.size (2)-1) * header.spacing (2)
54 );
55 return M;
56 }
57
58 };
59
60
61}
62
63#endif
64
const transform_type scanner2image
Definition: transform.h:43
Transform(const HeaderType &header)
An object for transforming between voxel, scanner and image coordinate spaces.
Definition: transform.h:29
const transform_type image2scanner
Definition: transform.h:43
static transform_type get_default(const HeaderType &header)
Definition: transform.h:47
const transform_type voxel2scanner
Definition: transform.h:43
Transform & operator=(const Transform &)=delete
const Eigen::DiagonalMatrix< default_type, 3 > voxelsize
Definition: transform.h:42
const transform_type scanner2voxel
Definition: transform.h:43
Definition: base.h:24
Eigen::Transform< default_type, 3, Eigen::AffineCompact > transform_type
the type for the affine transform of an image:
Definition: types.h:234
#define MEMALIGN(...)
Definition: types.h:185