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  

impdif.c File Reference

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

Go to the source code of this file.


Defines

#define BAR(i, j)   bar[(i)+(j)*nx]
#define FAR(i, j)   far[(i)+(j)*nx]

Functions

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

Define Documentation

#define BAR i,
j       bar[(i)+(j)*nx]
 

#define FAR i,
j       far[(i)+(j)*nx]
 


Function Documentation

int 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 10 of file impdif.c.

References argc, far, MRI_IMAGE::kind, machdep(), MAX, MRI_BYTE_PTR, MRI_FLOAT_PTR, mri_free(), MRI_IS_2D, mri_max(), mri_new(), mri_read_just_one(), mri_to_float(), mri_write(), MRI_IMAGE::nx, MRI_IMAGE::ny, and top.

00011 {
00012    MRI_IMAGE *imin , *imout ;
00013    int nx,ny , ii,jj , nopt ;
00014    float * far , f00,fp0,f0p,fm0,f0m , top,bot,dif , fmax ;
00015    byte  * bar ;
00016 
00017 #define BAR(i,j) bar[(i)+(j)*nx]
00018 #define FAR(i,j) far[(i)+(j)*nx]
00019 
00020    if( argc < 3 || strncmp(argv[1],"-help",5) == 0 ){
00021       printf( "Usage: impdif image_in image_out\n"
00022               "Computes the NN difference percentage image\n" ) ;
00023       exit(0) ;
00024    }
00025 
00026    machdep() ;
00027 
00028    /** get parameters **/
00029 
00030    nopt = 1 ;
00031    imin = mri_read_just_one( argv[nopt++] ) ;
00032    if( imin == NULL ) exit(1) ;
00033    if( ! MRI_IS_2D(imin) ){fprintf(stderr,"** Input image is not 2D!\a\n"); exit(1);}
00034 
00035    if( imin->kind != MRI_float ){
00036       imout = mri_to_float(imin);  mri_free(imin) ; imin = imout ;
00037    }
00038 
00039    nx = imin->nx ; ny = imin->ny ;
00040    imout = mri_new( nx , ny , MRI_byte ) ;
00041    bar = MRI_BYTE_PTR(imout) ; far = MRI_FLOAT_PTR(imin) ;
00042    fmax = mri_max(imin) ;
00043 
00044    for( jj=0 ; jj < ny ; jj++ ){
00045       for( ii=0 ; ii < nx ; ii++ ){
00046          f00 = FAR( ii           , jj           ) ;
00047          fp0 = FAR( (ii+1)%nx    , jj           ) ;
00048          f0p = FAR( ii           , (jj+1)%ny    ) ;
00049          fm0 = FAR( (ii+nx-1)%nx , jj           ) ;
00050          f0m = FAR( ii           , (jj+ny-1)%ny ) ;
00051 
00052          dif = fabs(f00-fp0) ; top = dif ;
00053          dif = fabs(f00-f0p) ; top = MAX(top,dif) ;
00054          dif = fabs(f00-f0m) ; top = MAX(top,dif) ;
00055          dif = fabs(f00-fm0) ; top = MAX(top,dif) ;
00056 
00057          dif = fabs(f00) ; bot = dif ;
00058          dif = fabs(f0p) ; bot = MAX(bot,dif) ;
00059          dif = fabs(fp0) ; bot = MAX(bot,dif) ;
00060          dif = fabs(f0m) ; bot = MAX(bot,dif) ;
00061          dif = fabs(fm0) ; bot = MAX(bot,dif) ;
00062 
00063          if( bot > 0.05*fmax ) BAR(ii,jj) = (byte) (100.0 * top/bot) ;
00064          else                  BAR(ii,jj) = 0 ;
00065       }
00066    }
00067 
00068    mri_write( argv[nopt++] , imout ) ;
00069    exit(0) ;
00070 }
 

Powered by Plone

This site conforms to the following standards: