本文整理汇总了C++中volume::setextrapolationmethod方法的典型用法代码示例。如果您正苦于以下问题:C++ volume::setextrapolationmethod方法的具体用法?C++ volume::setextrapolationmethod怎么用?C++ volume::setextrapolationmethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类volume
的用法示例。
在下文中一共展示了volume::setextrapolationmethod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: common_field_construction
void FnirtFileWriter::common_field_construction(const string& fname,
const volume<float>& ref,
const volume<float>& fieldx,
const volume<float>& fieldy,
const volume<float>& fieldz,
const Matrix& aff)
{
volume4D<float> fields(ref.xsize(),ref.ysize(),ref.zsize(),3);
fields.copyproperties(ref);
Matrix M;
bool add_affine = false;
if (add_affine = ((aff-IdentityMatrix(4)).MaximumAbsoluteValue() > 1e-6)) { // Add affine part to fields
M = (aff.i() - IdentityMatrix(4))*ref.sampling_mat();
}
if (samesize(ref,fieldx,true)) { // If ref is same size as the original field
fields[0] = fieldx; fields[1] = fieldy; fields[2] = fieldz;
fields.copyproperties(ref); // Put qform/sform and stuff back.
if (add_affine) {
ColumnVector xv(4), xo(4);
int zs = ref.zsize(), ys = ref.ysize(), xs = ref.xsize();
xv(4) = 1.0;
for (int z=0; z<zs; z++) {
xv(3) = double(z);
for (int y=0; y<ys; y++) {
xv(2) = double(y);
for (int x=0; x<xs; x++) {
xv(1) = double(x);
xo = M*xv;
fields(x,y,z,0) += xo(1);
fields(x,y,z,1) += xo(2);
fields(x,y,z,2) += xo(3);
}
}
}
}
}
else {
fieldx.setextrapolationmethod(extraslice);
fieldy.setextrapolationmethod(extraslice);
fieldz.setextrapolationmethod(extraslice);
Matrix R2F = fieldx.sampling_mat().i() * ref.sampling_mat();
ColumnVector xv(4), xo(4), xr(4);
int zs = ref.zsize(), ys = ref.ysize(), xs = ref.xsize();
xv(4) = 1.0;
for (int z=0; z<zs; z++) {
xv(3) = double(z);
for (int y=0; y<ys; y++) {
xv(2) = double(y);
for (int x=0; x<xs; x++) {
xv(1) = double(x);
xr = R2F*xv;
fields(x,y,z,0) = fieldx.interpolate(xr(1),xr(2),xr(3));
fields(x,y,z,1) = fieldy.interpolate(xr(1),xr(2),xr(3));
fields(x,y,z,2) = fieldz.interpolate(xr(1),xr(2),xr(3));
if (add_affine) {
xo = M*xv;
fields(x,y,z,0) += xo(1);
fields(x,y,z,1) += xo(2);
fields(x,y,z,2) += xo(3);
}
}
}
}
}
fields.set_intent(FSL_FNIRT_DISPLACEMENT_FIELD,fields.intent_param(0),fields.intent_param(1),fields.intent_param(2));
fields.setDisplayMaximum(0.0);
fields.setDisplayMinimum(0.0);
// Save resulting field
save_volume4D(fields,fname);
}