Description Usage Arguments Value Author(s) Examples
View source: R/invariantImageSimilarity.R
compute similarity metric between two images as image is rotated about its center w/or w/o optimization
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 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] ))
print( cor( fi[ fi > 0 ], mapped[fi>0] ))
print( cor( fi[ fi > 0 ], mapped2[fi>0] ))
cos45 = 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]] )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.