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  

to26.c File Reference

#include "mrilib.h"
#include <string.h>

Go to the source code of this file.


Defines

#define NOUT   61

Functions

int main (int argc, char *argv[])

Variables

byte map [26]
byte bk [26]
char * alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
char * num = "0123456789"

Define Documentation

#define NOUT   61
 

Definition at line 19 of file to26.c.

Referenced by main().


Function Documentation

int main int    argc,
char *    argv[]
 

Definition at line 21 of file to26.c.

References alpha, argc, bk, map, MRI_BYTE_PTR, mri_read(), nc, NOUT, num, MRI_IMAGE::nvox, MRI_IMAGE::nx, and MRI_IMAGE::ny.

00022 {
00023    MRI_IMAGE * im ;
00024    byte * bp , bb ;
00025    int ii , jj , nn , rr , kk , nlin=0 ;
00026    char out[NOUT+1] , zout[NOUT+1] , cc,nc , *nam ;
00027 
00028    if( argc < 2 ){ fprintf(stderr,"Usage: to26 NAME input.pgm > output.26\n"); exit(0); }
00029 
00030    nam = argv[1] ;
00031    im = mri_read( argv[2] ) ; if( im == NULL ) exit(1) ;
00032    bp = MRI_BYTE_PTR(im) ;
00033 
00034    for( ii=0 ; ii < 25 ; ii++ ) bk[ii] = (map[ii]+map[ii+1])/2 ;
00035    bk[25] = 255 ;
00036 
00037 fprintf(stderr,"image dimensions = %d %d\n",im->nx,im->ny) ;
00038 
00039    nn = 0 ; rr = 0 ;
00040    printf( "#undef  NX_%s\n",nam) ;
00041    printf( "#undef  NY_%s\n",nam) ;
00042    printf( "#define NX_%s %d\n",nam,im->nx) ;
00043    printf( "#define NY_%s %d\n",nam,im->ny) ;
00044    printf( "static char * BAR_%s[] = {\n" , nam ) ;
00045    for( ii=0 ; ii < im->nvox ; ii++ ){
00046       bb = bp[ii] ;
00047       for( jj=0 ; jj < 26 ; jj++ ) if( bb <= bk[jj] ) break ;
00048 
00049       out[nn++] = (jj<26) ? alpha[jj] : 'Z' ;
00050 
00051       if( nn == NOUT && ii < im->nvox-1 ){
00052          out[nn] = '\0' ;
00053          cc = out[0] ; rr = 1 ; kk = 0 ;
00054          for( jj=1 ; jj <= nn ; jj++ ){
00055             nc = out[jj] ;
00056             if( nc == cc ){  /* same character */
00057                if( rr == 9 ){ zout[kk++] = num[rr] ; zout[kk++] = cc ; rr = 0 ; }
00058                rr++ ;
00059             } else {         /* new character */
00060                if( rr == 1 ){
00061                   zout[kk++] = cc ; rr = 1 ;
00062                } else if( rr == 2 ){
00063                   zout[kk++] = cc ; zout[kk++] = cc ; rr = 1 ;
00064                } else {
00065                   zout[kk++] = num[rr] ; zout[kk++] = cc ; rr = 1 ;
00066                }
00067             }
00068             cc = nc ;
00069          }
00070          zout[kk] = '\0' ;
00071          printf("   \"%s\",\n",zout) ; nlin++ ; nn = 0 ;
00072       }
00073    }
00074 
00075    out[nn] = '\0' ;
00076    printf("   \"%s\"\n};\n",out) ; nlin++ ;
00077    printf("#undef  NLINE_%s\n",nam) ;
00078    printf("#define NLINE_%s %d\n",nam,nlin) ;
00079    exit(0) ;
00080 }

Variable Documentation

char* alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" [static]
 

Definition at line 16 of file to26.c.

Referenced by main().

byte bk[26] [static]
 

Definition at line 14 of file to26.c.

Referenced by main().

byte map[26] [static]
 

Initial value:

  {  30,  50,  70,  90, 106, 118, 130, 140, 146, 152, 158, 164, 170,
    176, 182, 190, 198, 206, 212, 218, 224, 230, 236, 242, 248, 254 }

Definition at line 10 of file to26.c.

Referenced by main().

char* num = "0123456789" [static]
 

Definition at line 17 of file to26.c.

Referenced by main().

 

Powered by Plone

This site conforms to the following standards: