You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在R中基于硬组织Procrustes拟合对齐完整3D地标数据?

解决基于硬组织配准完整软硬地标集的问题

核心思路是:对每个个体,先通过硬组织地标计算出对齐到硬组织共识所需的旋转、平移、缩放变换,再将该变换完整应用到包含软组织的全部地标矩阵,而非仅处理硬组织部分。

方法一:使用rotonto获取变换并应用到完整地标

  1. 提取硬组织的共识形状:
hard_consensus <- hardproc$mshape
  1. 创建空数组存储对齐后的完整地标数据:
aligned_full_array <- array(0, dim = dim(combinedarray))
  1. 循环处理每个个体,将变换应用到完整地标:
for (i in 1:dim(combinedarray)[3]) {
  # 提取当前个体的完整地标矩阵
  full_landmarks <- combinedarray[,,i]
  # 提取当前个体的硬组织地标
  hard_landmarks <- full_landmarks[618:931,]
  
  # 计算硬组织对齐到共识的变换
  trans <- rotonto(target = hard_consensus, source = hard_landmarks)
  
  # 将变换应用到完整地标集
  aligned_full <- applyTransform(trans, full_landmarks)
  
  # 存入结果数组
  aligned_full_array[,,i] <- aligned_full
}

方法二:利用align2procSym的变换参数处理完整地标

align2procSym会返回对齐硬组织的变换参数(旋转、平移、缩放),可直接用这些参数变换完整地标:

aligned_full_array <- array(0, dim = dim(combinedarray))
hard_consensus <- hardproc$mshape

for (i in 1:dim(combinedarray)[3]) {
  full_landmarks <- combinedarray[,,i]
  hard_landmarks <- full_landmarks[618:931,]
  
  # 获取硬组织的对齐结果及变换参数
  align_result <- align2procSym(hardproc, hard_landmarks)
  
  # 提取变换参数
  rot_mat <- align_result$rotation
  trans_vec <- align_result$translation
  scale_factor <- align_result$scaling
  
  # 对完整地标应用缩放、旋转、平移变换
  full_centered <- scale(full_landmarks, center = TRUE, scale = FALSE)
  full_scaled <- full_centered * scale_factor
  full_rotated <- full_scaled %*% rot_mat
  full_aligned <- full_rotated + trans_vec + colMeans(hard_consensus)
  
  # 存入结果数组
  aligned_full_array[,,i] <- full_aligned
}

验证结果

对齐完成后,可检查硬组织部分是否与hardproc$orpdata匹配:

# 提取第一个个体对齐后的硬组织
aligned_hard <- aligned_full_array[618:931,,1]
# 对比硬组织Procrustes后的结果
all.equal(aligned_hard, hardproc$orpdata[,,1], tolerance = 1e-6)

内容的提问来源于stack exchange,提问作者Catherine Sulzmann

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 23:32:51