Doxygen Source Code Documentation
imrotate.c File Reference
#include "mrilib.h"
#include <string.h>
Go to the source code of this file.
Defines | |
#define | ERR fprintf(stderr,"Illegal parameter!\n") |
Functions | |
int | main (int argc, char *argv[]) |
Define Documentation
|
|
Function Documentation
|
\** File : SUMA.c
Input paramters :
Definition at line 10 of file imrotate.c. References argc, MRI_IMAGE::kind, machdep(), MRI_BICUBIC, MRI_BILINEAR, MRI_FOURIER, mri_free(), MRI_IS_2D, mri_read_just_one(), mri_rota_variable(), mri_to_byte(), mri_to_float(), mri_to_short(), mri_write(), and strtod().
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 } |