readNumpyToANTsImage: readNumpyToANTsImage

Description Usage Arguments Value Author(s) Examples

Description

Read numpy array to antsImage. This inverts writeANTsImageToNumpy.

Usage

1

Arguments

fn

input filename (probably a .npy extension)

img

reference antsImage in which to put numpy data

Value

antsImage is output

Author(s)

Avants BB

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
img = ANTsR::antsImageRead( ANTsR::getANTsRData( "r16" ) )
ofn = tempfile( fileext=".npy" )
writeANTsImageToNumpy( img, ofn )
img2 = readNumpyToANTsImage( ofn, img )
img = ANTsR::makeImage( c( 5, 6, 7 ) )
writeANTsImageToNumpy( img, ofn )
img3 = readNumpyToANTsImage( ofn, img )

img = antsImageRead( getANTsRData( "mni" ) )
writeANTsImageToNumpy( img, ofn )
img3 = readNumpyToANTsImage( ofn, img )
# # in python
# from PIL import Image
# import numpy as np
# from scipy.misc import toimage
# data = np.load( ofn )
# array = np.reshape( data, [ 182, 218, 182 ] )
# toimage(array[:,111,:]).show()

stnava/ANTsRNpy documentation built on May 30, 2019, 7:20 p.m.