Doxygen Source Code Documentation
imaver.c File Reference
#include <mrilib.h>
#include <string.h>
Go to the source code of this file.
Defines | |
#define | MAX(x, y) (((x)>(y))?(x):(y)) |
Functions | |
int | main (int argc, char *argv[]) |
Define Documentation
|
|
Function Documentation
|
\** File : SUMA.c
Input paramters :
Definition at line 16 of file imaver.c. References argc, MRI_IMAGE::kind, machdep(), mri_free(), mri_read_just_one(), mri_stat_seq(), mri_to_short(), and mri_write().
00017 { 00018 int narg , narg_ave,narg_sig ; 00019 MRI_IMAGE * imin , ** imstat ; 00020 int to_short = -1 ; 00021 00022 /*** process command switches ***/ 00023 00024 if( argc < 5 || strncmp(argv[1],"-help",2) == 0 ){ 00025 printf( "Usage: imaver out_ave out_sig input_images ...\n" 00026 " (use - to skip output of out_ave and/or out_sig)\n" 00027 "* Computes the mean and standard deviation, pixel-by-pixel,\n" 00028 " of a whole bunch of images.\n" 00029 "* Write output images in 'short int' format if inputs are\n" 00030 " short ints, otherwise output images are floating point.\n" 00031 ) ; 00032 exit(0) ; 00033 } 00034 00035 machdep() ; 00036 00037 narg = 1 ; 00038 00039 /*** process input files ***/ 00040 00041 narg_ave = narg++ ; 00042 narg_sig = narg++ ; 00043 00044 do{ 00045 imin = mri_read_just_one( argv[narg] ) ; 00046 if( imin == NULL ) continue ; /* skip this image! */ 00047 00048 if( to_short == -1 ) to_short = (imin->kind == MRI_short) ; 00049 00050 (void) mri_stat_seq( imin ) ; 00051 mri_free( imin ) ; 00052 } while( ++narg < argc ) ; 00053 00054 /*** compute output ***/ 00055 00056 imstat = mri_stat_seq( NULL ) ; 00057 00058 if( strcmp(argv[narg_ave],"-") != 0 ){ 00059 if( to_short ) imin = mri_to_short( 1.0 , imstat[0] ) ; 00060 else imin = imstat[0] ; 00061 00062 mri_write( argv[narg_ave] , imin ) ; 00063 mri_free( imin ) ; 00064 } 00065 00066 if( strcmp(argv[narg_sig],"-") != 0 ){ 00067 if( to_short ) imin = mri_to_short( 1.0 , imstat[1] ) ; 00068 else imin = imstat[1] ; 00069 00070 mri_write( argv[narg_sig] , imin ) ; 00071 mri_free( imin ) ; 00072 } 00073 00074 exit(0) ; 00075 } |