我找不到合适的格式让applyTransform()
咬人。
applyTransform(transform, sourceImageorMatrix)
找不到函数想要的sourceImageorMatrix
的正确格式
我不断收到错误消息:
“要变换的对象应该是合适的图像或点矩阵”
我尝试过as.matrix
,as.cimg
,image(as.matrix())
,当然还有矩阵本身,但是applyTransform
一直让我失望。
library(oro.nifti)
library(RNiftyReg)
library(jpeg)
library(mmand)
library(Thermimage)
library(imager)
library(raster)
library(opencv)
affine.path <- 'c:/pathtoaffines/'
image.path <- "c:'pathtoimages/"
source('image reg functions.R')
############################# get affines and determine the mean ###########################
Astart <- 1748
Aend <- 2198
goodsults <- list(1:55)
index <- 1
for (filenum in Astart:Aend){
affine.file <- paste0(affine.path, 'AffineMatrixFor_',filenum,'.nii')
if (file.exists(affine.file)){
goodsults[[index]] <- readAffine(affine.file)
index <- index + 1
}
}
mean.ft <- goodsults[[1]]
for (i in 2:43){
mean.ft <- mean.ft + goodsults[[i]]
}
mean.ft <- mean.ft/length(goodsults)
################## apply the mean to an image that didnt get mapped right #########################
testflnum <- 1734 #good image
testflnum2 <- 1750 # bad image
psource <- get.IR(testflnum, image.path)
#im.targetNumber <- load.image(paste0(image.path,'FLIR',testflnum + 1, '.jpg'))
#im.targetcg <- grayscale(crop.borders(im.targetNumber, nx = 250, ny = 120))
im.targetNumber2 <- load.image(paste0(image.path, 'FLIR',testflnum + 1, '.jpg'))
im.targetcg2 <- grayscale(crop.borders(im.targetNumber2, nx = 250, ny = 120))
#result <- niftyreg(source, t(as.matrix(im.targetcg2)),nLevels = 8, init = mean.ft)
new.s <- applyTransform(mean.ft, psource)
#get.IR reads an FLIR IR photo and returns a matrix of pixel values of size # 348 x 464
预期结果是一个转换后的矩阵,代表“坏”图像(或者没有正确映射的图像。
我得到的错误是:
applyTransform(mean.ft,w)中的错误: 要转换的对象应该是合适的图像或点矩阵
答案 0 :(得分:0)
我发现在Python上对图像集执行转换要容易得多,然后将其移回R即可执行其他所有操作。解决的问题:使用python。