Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
nsize.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "mrilib.h"
00008 #include "string.h"
00009
00010 #define ERREX(str) ( fprintf(stderr,"ERROR: %s\a\n",str) , exit(1) )
00011
00012 int main( int argc , char * argv[] )
00013 {
00014 MRI_IMAGE * imin , * imout ;
00015 MRI_IMARR * imar ;
00016
00017 if( argc < 3 || strncmp(argv[1],"-help",2) == 0 ){
00018 printf(
00019 "Usage: nsize image_in image_out\n"
00020 " Zero pads 'image_in' to NxN, N=64,128,256,512, or 1024, \n"
00021 " whichever is the closest size larger than 'image_in'.\n"
00022 " [Works only for byte and short images.]\n" ) ;
00023 exit(0) ;
00024 }
00025
00026 machdep() ;
00027
00028 imar = mri_read_file( argv[1] ) ; if( imar == NULL ) ERREX("can't continue!") ;
00029 if( imar->num != 1 ) ERREX("more than 1 image in input file!") ;
00030 imin = IMAGE_IN_IMARR(imar,0) ;
00031
00032 imout = mri_nsize( imin ) ;
00033 if( imout == NULL ){
00034 fprintf(stderr,"*** failed to scale image! error exit!\n") ;
00035 exit(-1) ;
00036 }
00037
00038 mri_write( argv[2] , imout ) ;
00039 exit(0) ;
00040 }