Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

imrotate.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
00005 ******************************************************************************/
00006    
00007 #include "mrilib.h"
00008 #include <string.h>
00009 
00010 int main( int argc , char *argv[] )
00011 {
00012    MRI_IMAGE *imin , *imwarp ;
00013    float aa , bb , phi ;
00014    char * cp ;
00015    int kk , nopt , almode = MRI_BICUBIC ;
00016 
00017    if( argc < 6 || strncmp(argv[1],"-help",5) == 0 ){
00018       printf( "Usage: imrotate [-linear | -Fourier] dx dy phi input_image output_image\n"
00019               "Shifts and rotates an image:\n"
00020               "  dx pixels rightwards (not necessarily an integer)\n"
00021               "  dy pixels downwards\n"
00022               "  phi degrees clockwise\n"
00023               "  -linear means to use bilinear interpolation (default is bicubic)\n"
00024               "  -Fourier means to use Fourier interpolaion\n"
00025               "Values outside the input_image are taken to be zero.\n" ) ;
00026       exit(0) ;
00027    }
00028 
00029    machdep() ;
00030 
00031    /** get parameters **/
00032 
00033 #define ERR fprintf(stderr,"Illegal parameter!\n")
00034 
00035    nopt = 1 ;
00036    if( strncmp(argv[nopt],"-linear",4) == 0 ){
00037       almode = MRI_BILINEAR ;
00038       nopt++ ;
00039    } else if( strncmp(argv[nopt],"-Fourier",4) == 0 ){
00040       almode = MRI_FOURIER ;
00041       nopt++ ;
00042    }
00043 
00044    aa  = strtod( argv[nopt++] , &cp ) ;              if( *cp != '\0' ){ERR;exit(1);}
00045    bb  = strtod( argv[nopt++] , &cp ) ;              if( *cp != '\0' ){ERR;exit(1);}
00046    phi = strtod( argv[nopt++] , &cp ) * (PI/180.0) ; if( *cp != '\0' ){ERR;exit(1);}
00047 
00048    imin = mri_read_just_one( argv[nopt++] ) ;
00049    if( imin == NULL ) exit(1) ;
00050    if( ! MRI_IS_2D(imin) ){
00051       fprintf(stderr,"** Input image is not 2D!\a\n") ; exit(1) ;
00052    }
00053 
00054    kk = imin->kind ;
00055 
00056    imwarp = mri_rota_variable( almode , imin,aa,bb,phi ) ;
00057 
00058    mri_free( imin ) ;
00059 
00060    switch( kk ){
00061       case MRI_byte:    imin = mri_to_byte( imwarp )        ; break ;
00062       case MRI_short:   imin = mri_to_short( 1.0 , imwarp ) ; break ;
00063       default:          imin = mri_to_float( imwarp )       ; break ;
00064       case MRI_float:   imin = imwarp                       ; break ;
00065       case MRI_complex: imin = imwarp                       ; break ;
00066    }
00067 
00068    mri_write( argv[nopt++] , imin ) ;
00069    exit(0) ;
00070 }
 

Powered by Plone

This site conforms to the following standards: