Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
qqq_rota.c
Go to the documentation of this file.00001 #include "mrilib.h"
00002 #include <string.h>
00003
00004 int main( int argc , char *argv[] )
00005 {
00006 MRI_IMAGE *imin , *imwarp ;
00007 float aa , bb , phi ;
00008 char * cp ;
00009 int kk , nopt , almode = MRI_BICUBIC ;
00010 double ct ;
00011 int qq ;
00012
00013 if( argc < 6 || strncmp(argv[1],"-help",5) == 0 ){
00014 printf( "Usage: imrotate [-linear | -Fourier] dx dy phi input_image output_image\n"
00015 "Shifts and rotates an image:\n"
00016 " dx pixels rightwards (not necessarily an integer)\n"
00017 " dy pixels downwards\n"
00018 " phi degrees clockwise\n"
00019 " -linear means to use bilinear interpolation (default is bicubic)\n"
00020 " -Fourier means to use Fourier interpolaion\n"
00021 "Values outside the input_image are taken to be zero.\n" ) ;
00022 exit(0) ;
00023 }
00024
00025
00026
00027 #define ERR fprintf(stderr,"Illegal parameter!\n")
00028
00029 nopt = 1 ;
00030 if( strncmp(argv[nopt],"-linear",4) == 0 ){
00031 almode = MRI_BILINEAR ;
00032 nopt++ ;
00033 } else if( strncmp(argv[nopt],"-Fourier",4) == 0 ){
00034 almode = MRI_FOURIER ;
00035 nopt++ ;
00036 }
00037
00038 aa = strtod( argv[nopt++] , &cp ) ; if( *cp != '\0' ){ERR;exit(1);}
00039 bb = strtod( argv[nopt++] , &cp ) ; if( *cp != '\0' ){ERR;exit(1);}
00040 phi = strtod( argv[nopt++] , &cp ) * (PI/180.0) ; if( *cp != '\0' ){ERR;exit(1);}
00041
00042 imin = mri_read_just_one( argv[nopt++] ) ;
00043 if( imin == NULL ) exit(1) ;
00044 if( ! MRI_IS_2D(imin) ){
00045 fprintf(stderr,"** Input image is not 2D!\a\n") ; exit(1) ;
00046 }
00047
00048 kk = imin->kind ;
00049 if( kk != MRI_float ){
00050 MRI_IMAGE * qim = mri_to_float(imin) ;
00051 mri_free(imin) ; imin = qim ;
00052 }
00053
00054 ct = COX_cpu_time() ;
00055
00056 for( qq=0 ; qq < 100 ; qq++ ){
00057 imwarp = mri_rota_variable( almode , imin,aa,bb,phi ) ;
00058 mri_free(imwarp) ;
00059 }
00060 ct = COX_cpu_time() - ct ;
00061 printf("CPU time = %g\n",ct) ; exit(0) ;
00062 exit(0) ;
00063 }