Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
imupsam.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "mrilib.h"
00008 #include <stdlib.h>
00009
00010 int main( int argc , char *argv[] )
00011 {
00012 MRI_IMAGE *inim , *outim ;
00013 int nup , iarg=1 , do_ascii=0 ;
00014
00015 if( argc < 4 || strcmp(argv[1],"-help") == 0 ){
00016 printf( "Usage: imupsam [-A] n input_image output_image\n"
00017 "* Upsamples the input 2D image by a factor of n and\n"
00018 " writes result into output_image; n must be an\n"
00019 " integer in the range 2..30.\n"
00020 "* 7th order polynomial interpolation is used in each\n"
00021 " direction.\n"
00022 "* Inputs can be complex, float, short, PGM, PPM, or JPG.\n"
00023 "* If input_image is in color (PPM or JPG), output will\n"
00024 " be PPM unless output_image ends in '.jpg'.\n"
00025 "* If output_image is '-', the result will be written\n"
00026 " to stdout (so you could pipe it into something else).\n"
00027 "* The '-A' option means to write the result in ASCII\n"
00028 " format: all the numbers for the file are output,\n"
00029 " and nothing else (no header info).\n"
00030 "* Author: RW Cox -- 16 April 1999.\n" ) ;
00031 exit(0) ;
00032 }
00033
00034 machdep() ;
00035
00036 if( strcmp(argv[iarg],"-A") == 0 ){
00037 iarg++ ; do_ascii = 1 ;
00038 if( iarg+3 > argc ){
00039 fprintf(stderr,"** imupsam: not enough arguments!\n") ; exit(1) ;
00040 }
00041 }
00042
00043 nup = strtol( argv[iarg++] , NULL , 10 ) ;
00044 if( nup < 1 || nup > 30 ){
00045 fprintf(stderr,"** imupsam: nup=%s out of range 1..30\n",argv[iarg-1]); exit(1);
00046 }
00047
00048 inim = mri_read_just_one( argv[iarg++] ) ;
00049 if( inim == NULL ){
00050 fprintf(stderr,"** imupsam: can't read input image %s\n",argv[iarg-1]); exit(1);
00051 }
00052
00053 outim = mri_dup2D( nup , inim ) ;
00054 if( outim == NULL ){
00055 fprintf(stderr,"** imupsam: upsampling fails!\n"); exit(1);
00056 }
00057
00058 if( do_ascii )
00059 nup = mri_write_ascii( argv[iarg] , outim ) ;
00060 else
00061 nup = mri_write( argv[iarg] , outim ) ;
00062
00063 if( nup == 0 ){
00064 fprintf(stderr,"** imupsam: can't write output image %s\n",argv[iarg]); exit(1);
00065 }
00066
00067 exit(0) ;
00068 }