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  

grayer.c File Reference

#include <mrilib.h>

Go to the source code of this file.


Defines

#define TOP   ((byte)255)

Functions

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

Define Documentation

#define TOP   ((byte)255)
 

Definition at line 3 of file grayer.c.

Referenced by main().


Function Documentation

void main int    argc,
char *    argv[]
 

\** File : SUMA.c

Author:
: Ziad Saad Date : Thu Dec 27 16:21:01 EST 2001
Purpose :

Input paramters :

Parameters:
param  Usage : SUMA ( )
Returns :
Returns:
Support :
See also:
OpenGL prog. Guide 3rd edition , varray.c from book's sample code
Side effects :

Definition at line 5 of file grayer.c.

References argc, MRI_IMAGE::kind, mri_data_pointer(), mri_read(), mri_write(), name, MRI_IMAGE::nx, MRI_IMAGE::ny, strtod(), and TOP.

00006 {
00007    MRI_IMAGE * rim, * gim, * bim ;
00008    byte      * rby, * gby, * bby ;
00009    byte  bmax ;
00010    int   nx,ny,npix , ii , whiten ;
00011    float fac ;
00012    char name[256] ;
00013 
00014    if( argc < 4 || strncmp(argv[1],"-help",4) == 0 ){
00015       printf("Usage: grayer factor root_in root_out [-whiten]\n"
00016              "       [files are root.red root.grn root.blu]\n" ) ;
00017       exit(0) ;
00018    }
00019 
00020    fac = strtod( argv[1] , NULL ) ;
00021    if( fac < 0.0 || fac > 1.0 ){ printf("Illegal factor\n") ; exit(-1) ; }
00022 
00023    sprintf(name,"%s.red",argv[2]) ; rim = mri_read(name) ;
00024    if( rim == NULL || rim->kind != MRI_byte ){printf("bad red\n"); exit(-1) ;}
00025 
00026    sprintf(name,"%s.grn",argv[2]) ; gim = mri_read(name) ;
00027    if( gim == NULL || gim->kind != MRI_byte ){printf("bad grn\n"); exit(-1) ;}
00028 
00029    sprintf(name,"%s.blu",argv[2]) ; bim = mri_read(name) ;
00030    if( bim == NULL || bim->kind != MRI_byte ){printf("bad blu\n"); exit(-1) ;}
00031 
00032    nx = rim->nx ; ny = rim->ny ; npix = nx * ny ;
00033    if( bim->nx != nx || bim->ny != ny || gim->nx != nx || gim->ny != ny ){
00034       printf("input images not conformant!\n") ;
00035       exit(-1) ;
00036    }
00037 
00038    rby = mri_data_pointer(rim) ;
00039    gby = mri_data_pointer(gim) ;
00040    bby = mri_data_pointer(bim) ;
00041 
00042    whiten = (argc > 4) && (strncmp(argv[4],"-whiten",3)==0) ;
00043 
00044    for( ii=0 ; ii < npix ; ii++ ){
00045       if( rby[ii] == gby[ii] && gby[ii] == bby[ii] ){
00046          if( rby[ii] != TOP ){
00047             rby[ii] *= fac ; gby[ii] *= fac ; bby[ii] *= fac ;
00048          }
00049       } else if( whiten ){
00050          bmax = rby[ii] ; if( gby[ii] > bmax ) bmax = gby[ii] ;
00051                           if( bby[ii] > bmax ) bmax = bby[ii] ;
00052          rby[ii] = gby[ii] = bby[ii] = bmax ;
00053       }
00054    }
00055 
00056    sprintf(name,"%s.red",argv[3]) ; mri_write(name,rim) ;
00057 
00058    sprintf(name,"%s.grn",argv[3]) ; mri_write(name,gim) ;
00059 
00060    sprintf(name,"%s.blu",argv[3]) ; mri_write(name,bim) ;
00061 }
 

Powered by Plone

This site conforms to the following standards: