1 /*****************************************************************************
2 Major portions of this software are copyrighted by the Medical College
3 of Wisconsin, 1994-2000, and are released under the Gnu General Public
4 License, Version 2. See the file README.Copyright for details.
5 ******************************************************************************/
6
7 #include "mrilib.h"
8
main(int argc,char * argv[])9 int main( int argc , char * argv[] )
10 {
11 int nx,ny,ii,npix ;
12 MRI_IMAGE * im1 , * im2 , * flim , * cxim ;
13 float * a1 , * a2 ;
14 complex * cxar ;
15
16 if( argc < 4 ){
17 printf("Usage: 2tocx im1 im2 cxim\n") ;
18 exit(0) ;
19 }
20
21 im1 = mri_read( argv[1] ) ;
22 im2 = mri_read( argv[2] ) ;
23 if( im1 == NULL || im2 == NULL ) exit(1) ;
24
25 flim = mri_to_float(im1) ; mri_free(im1) ; im1 = flim ; a1 = MRI_FLOAT_PTR(im1) ;
26 flim = mri_to_float(im2) ; mri_free(im2) ; im2 = flim ; a2 = MRI_FLOAT_PTR(im2) ;
27
28 nx = im1->nx ; ny = im1->ny ; npix = nx*ny ;
29
30 cxim = mri_new( nx , ny , MRI_complex ) ;
31 cxar = MRI_COMPLEX_PTR(cxim) ;
32
33 for( ii=0 ; ii < npix ; ii++ ){
34 cxar[ii].r = a1[ii] ;
35 cxar[ii].i = a2[ii] ;
36 }
37
38 mri_write( argv[3] , cxim ) ;
39 exit(0) ;
40 }
41