-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2tocx.c
40 lines (31 loc) · 1.16 KB
/
2tocx.c
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
38
39
40
/*****************************************************************************
Major portions of this software are copyrighted by the Medical College
of Wisconsin, 1994-2000, and are released under the Gnu General Public
License, Version 2. See the file README.Copyright for details.
******************************************************************************/
#include "mrilib.h"
int main( int argc , char * argv[] )
{
int nx,ny,ii,npix ;
MRI_IMAGE * im1 , * im2 , * flim , * cxim ;
float * a1 , * a2 ;
complex * cxar ;
if( argc < 4 ){
printf("Usage: 2tocx im1 im2 cxim\n") ;
exit(0) ;
}
im1 = mri_read( argv[1] ) ;
im2 = mri_read( argv[2] ) ;
if( im1 == NULL || im2 == NULL ) exit(1) ;
flim = mri_to_float(im1) ; mri_free(im1) ; im1 = flim ; a1 = MRI_FLOAT_PTR(im1) ;
flim = mri_to_float(im2) ; mri_free(im2) ; im2 = flim ; a2 = MRI_FLOAT_PTR(im2) ;
nx = im1->nx ; ny = im1->ny ; npix = nx*ny ;
cxim = mri_new( nx , ny , MRI_complex ) ;
cxar = MRI_COMPLEX_PTR(cxim) ;
for( ii=0 ; ii < npix ; ii++ ){
cxar[ii].r = a1[ii] ;
cxar[ii].i = a2[ii] ;
}
mri_write( argv[3] , cxim ) ;
exit(0) ;
}