Doxygen Source Code Documentation
im2niml.c File Reference
#include "mrilib.h"Go to the source code of this file.
Functions | |
| int | main (int argc, char *argv[]) |
Function Documentation
|
||||||||||||
|
\** File : SUMA.c
Input paramters :
Definition at line 3 of file im2niml.c. References argc, ERROR_exit(), ERROR_message(), FREE_IMARR, IMARR_COUNT, IMARR_SUBIM, INFO_message(), mri_free(), mri_read_file(), mri_to_niml(), NI_free_element(), NI_stream_closenow(), NI_stream_open(), NI_TEXT_MODE, and NI_write_element().
00004 {
00005 MRI_IMARR *iar ;
00006 MRI_IMAGE *im ;
00007 NI_stream ns=NULL ;
00008 NI_element *nel ;
00009 int ii , iarg=1 ;
00010 int nb=0 ;
00011
00012 if( argc < 2 || strcmp(argv[1],"-help") == 0 ){
00013 printf("Usage: im2niml imagefile [imagefile ...]\n"
00014 "Converts the input image(s) to a text-based NIML element\n"
00015 "and writes the result to stdout. Sample usage:\n"
00016 " aiv -p 4444 &\n"
00017 " im2niml zork.jpg | nicat tcp:localhost:4444\n"
00018 "-- Author: RW Cox.\n"
00019 ) ;
00020 exit(0) ;
00021 }
00022
00023 ns = NI_stream_open( "stdout:" , "w" ) ;
00024 if( ns == NULL ) ERROR_exit("Can't open stdout?!") ;
00025 for( ; iarg < argc ; iarg++ ){
00026 iar = mri_read_file( argv[iarg] ) ;
00027 if( iar == NULL ){
00028 ERROR_message("Can't read file %s",argv[iarg]); continue;
00029 }
00030 for( ii=0 ; ii < IMARR_COUNT(iar) ; ii++ ){
00031 im = IMARR_SUBIM(iar,ii) ; nel = mri_to_niml(im) ; mri_free(im) ;
00032 if( nel == NULL ){
00033 ERROR_message("Can't process %s[%d]",argv[iarg],ii); continue;
00034 }
00035 nb += NI_write_element( ns , nel , NI_TEXT_MODE ) ;
00036 NI_free_element(nel) ;
00037 }
00038 FREE_IMARR(iar) ;
00039 }
00040 NI_stream_closenow(ns) ;
00041 INFO_message("Wrote %d bytes to stdout",nb) ;
00042 exit(0) ;
00043 }
|