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  

edt_volamax.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
00005 ******************************************************************************/
00006 
00007 #include "mrilib.h"
00008 
00009 /*********** find the largest value in a volume of data ***********/
00010 
00011 float MCW_vol_amax( int nx, int ny, int nz , int ftype , void * fim )
00012 {
00013    register int nxyz = nx * ny * nz , ii ;
00014 
00015 ENTRY("MCW_vol_amax") ;
00016 
00017    if( fim == NULL ) RETURN( 0.0 );
00018 
00019    switch( ftype ){
00020 
00021       case MRI_byte:{
00022          register byte * bfar = (byte *) fim ;
00023          register byte max , val ;
00024          max = bfar[0] ;
00025          for( ii=1 ; ii < nxyz ; ii++ ){
00026             val = bfar[ii] ; if( val > max ) max = val ;
00027          }
00028          RETURN ((float) max) ;
00029       }
00030       break ;
00031 
00032       case MRI_short:{
00033          register short * sfar = (short *) fim ;
00034          register short max , val ;
00035          max = abs(sfar[0]) ;
00036          for( ii=1 ; ii < nxyz ; ii++ ){
00037             val = abs(sfar[ii]) ; if( val > max ) max = val ;
00038          }
00039          RETURN ((float) max) ;
00040       }
00041       break ;
00042 
00043       case MRI_float:{
00044          register float * ffar = (float *) fim ;
00045          register float max , val ;
00046          max = fabs(ffar[0]) ;
00047          for( ii=1 ; ii < nxyz ; ii++ ){
00048             val = fabs(ffar[ii]) ; if( val > max ) max = val ;
00049          }
00050          RETURN ((float) max) ;
00051       }
00052       break ;
00053 
00054       case MRI_double:{
00055          register double * dfar = (double *) fim ;
00056          register double max , val ;
00057          max = fabs(dfar[0]) ;
00058          for( ii=1 ; ii < nxyz ; ii++ ){
00059             val = fabs(dfar[ii]) ; if( val > max ) max = val ;
00060          }
00061          RETURN ((float) max) ;
00062       }
00063       break ;
00064 
00065       case MRI_complex:{
00066          register complex * cfar = (complex *) fim ;
00067          register float max , val ;
00068          max = CSQR(cfar[0]) ;
00069          for( ii=1 ; ii < nxyz ; ii++ ){
00070             val = CSQR(cfar[ii]) ; if( val > max ) max = val ;
00071          }
00072          RETURN( (float) sqrt(max) );
00073       }
00074       break ;
00075    }
00076    RETURN( 0.0 );
00077 }
 

Powered by Plone

This site conforms to the following standards: