17#ifndef __image_filter_resize_h__
18#define __image_filter_resize_h__
20#include "filter/base.h"
22#include "filter/smooth.h"
61 template <
class HeaderType>
62 Resize (
const HeaderType& in) :
73 set_voxel_size (voxel_size);
78 if (voxel_size.size() != 3)
79 throw Exception (
"the voxel size must be defined using a value for all three dimensions.");
81 Eigen::Vector3d original_extent;
82 for (
size_t j = 0; j < 3; ++j) {
83 if (voxel_size[j] <= 0.0)
84 throw Exception (
"the voxel size must be larger than zero");
85 original_extent[j] =
axes_[j].size *
axes_[j].spacing;
89 for (
size_t i = 0; i < 3; ++i)
91 axes_[j].spacing = voxel_size[j];
97 if (image_res.size() != 3)
98 throw Exception (
"the image resolution must be defined for 3 spatial dimensions");
100 for (
size_t d = 0; d < 3; ++d) {
101 if (image_res[d] <= 0)
102 throw Exception (
"the image resolution must be larger than zero for all 3 spatial dimensions");
103 new_voxel_size[d] = (this->size(d) * this->spacing(d)) / image_res[d];
105 set_voxel_size (new_voxel_size);
115 if (
scale.size() != 3)
116 throw Exception (
"a scale factor for each spatial dimension is required");
118 for (
size_t d = 0; d < 3; ++d) {
120 throw Exception (
"the scale factor must be larger than zero");
121 new_voxel_size[d] = (this->size(d) * this->spacing(d)) /
std::ceil (this->size(d) *
scale[d]);
123 set_voxel_size (new_voxel_size);
127 if (oversample.size() == 1)
128 oversample.resize (3, oversample[0]);
129 else if (oversample.size() != 3 and oversample.size() != 0)
130 throw Exception (
"FIXME oversample requires either a vector of a 0 (auto), 1 or 3 integers integer, got " +
str(oversample.size()));
131 for (
auto f : oversample) {
133 throw Exception (
"oversample factors must be positive integers");
138 void set_interp_type (
int type) {
151 template <
class InputImageType,
class OutputImageType>
152 void operator() (InputImageType& input, OutputImageType& output) {
vector< uint32_t > oversampling
default_type * out_of_bounds_value
transform_type transformation
This class defines the interface for classes that perform image interpolation.
constexpr I ceil(const T x)
template function with cast to different type
constexpr I round(const T x)
VectorType::Scalar value(const VectorType &coefs, typename VectorType::Scalar cos_elevation, typename VectorType::Scalar cos_azimuth, typename VectorType::Scalar sin_azimuth, int lmax)
const vector< uint32_t > AutoOverSample
const transform_type NoTransform
mat4 scale(float x, float y, float z)
MR::default_type value_type
double default_type
the default type used throughout MRtrix
std::string str(const T &value, int precision=0)
Eigen::Transform< default_type, 3, Eigen::AffineCompact > transform_type
the type for the affine transform of an image: