java - 将 Java 中的 3D 仿射变换构建导入 R
问题描述
我有一个与仿射变换(<affine>
标签之间)有关的问题。我使用AffineTransform3D函数从使用 Java 创建的 BigDataViewer Fiji 插件创建的 xml 文件(此处为完整的 xml 文件)中提取以下两个仿射变换:
<ViewRegistrations>
<ViewRegistration timepoint="0" setup="0">
<ViewTransform type="affine">
<Name>Fast 3d geometric hashing (rotation invariant), AffineModel3D on [beads (c=0)]</Name>
<affine>1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0</affine>
</ViewTransform>
<ViewTransform type="affine">
<Name>calibration</Name>
<affine>1.9998662296836334 0.0 0.0 0.0 0.0 1.9998662296836334 0.0 0.0 0.0 0.0 1.9998662296836334 0.0</affine>
</ViewTransform>
</ViewRegistration>
我想使用buildAffine()
R 包 {RNiftyReg} 中的函数在 R 中导入两个仿射变换,然后使用 {RNiftyReg} 计算它们的组成composeTransforms()
。
buildAffine(translation = c(0, 0, 0), scales = c(1, 1, 1), skews = c(0, 0,0),
angles = c(0, 0, 0), source = NULL, target = NULL,
anchor = c("none", "origin", "centre", "center"))
我的问题:
上面的仿射变换存储在 12 个索引的向量中。buildAffine()
需要平移、比例、倾斜和角度的值作为输入参数。
我想知道哪个值对应什么。
解决方案
我主要是 R 用户,但这里有:hte Java 调用中的变量名称是:
dat <- scan (text="double xx, double yx, double zx, double tx, double xy, double yy, double zy, double ty, double xz, double yz, double zz, double tz", what="")
dat <- dat[dat != "double"]
matrix(dat,4)
[,1] [,2] [,3]
[1,] "xx," "xy," "xz,"
[2,] "yx," "yy," "yz,"
[3,] "zx," "zy," "zz,"
[4,] "tx," "ty," "tz"
此页面记录了如何对仿射变换进行编码,唯一的区别是 4x3 矩阵被转置:https ://o7planning.org/en/11157/javafx-transformations-tutorial
t( matrix(dat,4) )
[,1] [,2] [,3] [,4]
[1,] "xx," "yx," "zx," "tx,"
[2,] "xy," "yy," "zy," "ty,"
[3,] "xz," "yz," "zz," "tz"
因此,矩阵将应用于 c(x,y,z,1) 的向量以获得以下输出:
推荐阅读
- laravel - laravel carbon isoFormat 方法不存在
- javascript - 如何在其中使用 es6 函数参数?
- jquery - 排序 div 的 JQuery 浏览器兼容性问题
- java - compareTo() 方法使用对象的 float 属性。它是如何使用的,为什么?
- c++ - 执行特征实现细节
- node.js - 如果验证失败,如何停止路由到给定的路由
- python - 使用 conda 指定特定 python 可执行文件的路径
- google-play - Google Play 商店是否要求用户提供付款方式?
- xml - Python3:解析 xml 以获取具有特定孙子的孩子
- dsl - 哪个工具提供了创建文本外部 DSL 以进行简单代码翻译的最简单方法?