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 #include "string.h"
9
10 #define ERREX(str) ( fprintf(stderr,"ERROR: %s\a\n",str) , exit(1) )
11
main(int argc,char * argv[])12 int main( int argc , char * argv[] )
13 {
14 MRI_IMAGE * imin , * imout ;
15 MRI_IMARR * imar ;
16
17 if( argc < 3 || strncmp(argv[1],"-help",2) == 0 ){
18 printf(
19 "Usage: nsize image_in image_out\n"
20 " Zero pads 'image_in' to NxN, N=64,128,256,512, or 1024, \n"
21 " whichever is the closest size larger than 'image_in'.\n"
22 " [Works only for byte and short images.]\n" ) ;
23 exit(0) ;
24 }
25
26 machdep() ;
27
28 imar = mri_read_file( argv[1] ) ; if( imar == NULL ) ERREX("can't continue!") ;
29 if( imar->num != 1 ) ERREX("more than 1 image in input file!") ;
30 imin = IMAGE_IN_IMARR(imar,0) ;
31
32 imout = mri_nsize( imin ) ;
33 if( imout == NULL ){
34 fprintf(stderr,"*** failed to scale image! error exit!\n") ;
35 exit(-1) ;
36 }
37
38 mri_write( argv[2] , imout ) ;
39 exit(0) ;
40 }
41