Doxygen Source Code Documentation
edt_scl2max.c File Reference
#include "mrilib.h"
Go to the source code of this file.
Functions | |
void | MCW_scale_to_max (int nx, int ny, int nz, int ftype, void *fim) |
Function Documentation
|
Definition at line 14 of file edt_scl2max.c. References abs, CSQR, ENTRY, fim, complex::i, nz, and complex::r. Referenced by EDIT_one_dataset().
00015 { 00016 register int nxyz = nx * ny * nz , ii ; 00017 register float fac ; 00018 00019 ENTRY("MCW_scale_to_max") ; 00020 00021 if( fim == NULL ) EXRETURN ; 00022 00023 switch( ftype ){ 00024 00025 case MRI_byte:{ 00026 register byte * bfar = (byte *) fim ; 00027 register byte max , val ; 00028 max = bfar[0] ; 00029 for( ii=1 ; ii < nxyz ; ii++ ){ 00030 val = bfar[ii] ; if( val > max ) max = val ; 00031 } 00032 if( max == 0 ) EXRETURN ; 00033 fac = 255.0 / max ; 00034 for( ii=0 ; ii < nxyz ; ii++ ) bfar[ii] *= fac ; 00035 } 00036 break ; 00037 00038 case MRI_short:{ 00039 register short * sfar = (short *) fim ; 00040 register short max , val ; 00041 max = abs(sfar[0]) ; 00042 for( ii=1 ; ii < nxyz ; ii++ ){ 00043 val = abs(sfar[ii]) ; if( val > max ) max = val ; 00044 } 00045 if( max == 0 ) EXRETURN ; 00046 fac = 10000.0 / max ; 00047 for( ii=0 ; ii < nxyz ; ii++ ) sfar[ii] *= fac ; 00048 } 00049 break ; 00050 00051 case MRI_float:{ 00052 register float * ffar = (float *) fim ; 00053 register float max , val ; 00054 max = fabs(ffar[0]) ; 00055 for( ii=1 ; ii < nxyz ; ii++ ){ 00056 val = fabs(ffar[ii]) ; if( val > max ) max = val ; 00057 } 00058 if( max == 0.0 ) EXRETURN ; 00059 fac = 10000.0 / max ; 00060 for( ii=0 ; ii < nxyz ; ii++ ) ffar[ii] *= fac ; 00061 } 00062 break ; 00063 00064 case MRI_complex:{ 00065 register complex * cfar = (complex *) fim ; 00066 register float max , val ; 00067 max = CSQR(cfar[0]) ; 00068 for( ii=1 ; ii < nxyz ; ii++ ){ 00069 val = CSQR(cfar[ii]) ; if( val > max ) max = val ; 00070 } 00071 if( max == 0.0 ) EXRETURN ; 00072 fac = 10000.0 / sqrt(max) ; 00073 for( ii=0 ; ii < nxyz ; ii++ ){ 00074 cfar[ii].r *= fac ; cfar[ii].i *= fac ; 00075 } 00076 } 00077 break ; 00078 } 00079 00080 EXRETURN ; 00081 } |