invariantImageSimilarity.Rd
compute similarity metric between two images as image is rotated about its center w/or w/o optimization
invariantImageSimilarity( in_image1, in_image2, localSearchIterations = 0, metric = "MI", thetas = seq(from = 0, to = 360, length.out = 5), thetas2 = seq(from = 0, to = 360, length.out = 5), thetas3 = seq(from = 0, to = 360, length.out = 5), scaleImage = 1, doReflection = 0, txfn = NA, transform = c("Affine", "Similarity", "Rigid"), mask )
in_image1 | reference image |
---|---|
in_image2 | moving image |
localSearchIterations | integer controlling local search in multistart |
metric | which metric MI or GC (string) |
thetas | numeric vector of search angles in degrees |
thetas2 | numeric vector of search angles in degrees around principal axis 2 (3D) |
thetas3 | numeric vector of search angles in degrees around principal axis 3 (3D) |
scaleImage | global scale |
doReflection | reflect image about principal axis |
txfn | if present, write optimal tx to .mat file |
transform | Rigid, Similarity or Affine transform |
mask | optional fixed image mask |
dataframe with metric values and transformation parameters
Brian B. Avants
fi<-antsImageRead( getANTsRData("r16") ) mi<-antsImageRead( getANTsRData("r64") ) mival<-invariantImageSimilarity( fi, mi, thetas = c(0,10,20) ) mapped = antsApplyTransforms( fi, mi, transformlist=mival[[2]] ) areg = antsRegistration( fi, mi, typeofTransform="Affine", initialTransform=mival[[2]] ) bestInd = which.min( mival[[1]]$MetricValue ) txparams = as.numeric( mival[[1]][ bestInd,2:(ncol( mival[[1]] )-2) ] ) txfixedparams = as.numeric( mival[[1]][ bestInd, (ncol( mival[[1]] )-2+1):ncol( mival[[1]] )] ) affTx = createAntsrTransform( type = "AffineTransform", dimension = 2, parameters = txparams, fixed.parameters = txfixedparams ) mapped2 = applyAntsrTransformToImage( affTx, mi, fi ) scaleMat = diag( 2 ) * 0.75 affTx = createAntsrTransform( type = "AffineTransform", dimension = 2, matrix = scaleMat, fixed.parameters = c(125.2706, 129.2100) ) temp = applyAntsrTransformToImage( affTx, mi, mi ) mival<-invariantImageSimilarity( fi, temp, thetas = c(0,10,20), localSearchIterations = 10, transform='Similarity' ) mapped = antsApplyTransforms( fi, temp, transformlist=mival[[2]] ) mival<-invariantImageSimilarity( fi, temp, thetas = c(0,10,20), localSearchIterations = 10, transform='Affine' ) mapped2 = antsApplyTransforms( fi, temp, transformlist=mival[[2]] ) print( cor( fi[ fi > 0 ], temp[fi>0] ))#> [1] 0.1962543#> [1] 0.1705282#> [1] 0.1449335cos45 = cos(pi*45/180) sin45 = sin(pi*45/180) txRotate <- createAntsrTransform( precision="float", type="AffineTransform", dim=2 ) setAntsrTransformParameters(txRotate, c(cos45,-sin45,sin45,cos45,0,0) ) setAntsrTransformFixedParameters(txRotate, c(128,128)) rotatedImage = applyAntsrTransform(txRotate, mi, mi) mival<-invariantImageSimilarity( fi, rotatedImage, thetas = c(0,10,20,30,40,50), localSearchIterations = 10, transform='Rigid' ) mapped2 = antsApplyTransforms( fi, rotatedImage, transformlist=mival[[2]] )