Doxygen Source Code Documentation
mri_histog.c File Reference
#include "mrilib.h"
Go to the source code of this file.
Functions | |
void | mri_histogram (MRI_IMAGE *im, float hbot, float htop, int initialize, int nbin, int hist[]) |
Function Documentation
|
Definition at line 11 of file mri_histog.c. References ENTRY, MRI_IMAGE::kind, mri_data_pointer(), mri_free(), mri_to_float(), mri_to_short(), and MRI_IMAGE::nvox. Referenced by BFIT_compute(), BFIT_main(), CORREL_main(), HISTO_main(), ISQ_process_mri(), ISQ_statify_one(), RCREND_reload_dataset(), and REND_reload_dataset().
00013 { 00014 register int ih , npix , ii ; 00015 register float sbin ; 00016 MRI_IMAGE * lim ; 00017 00018 ENTRY("mri_histogram") ; 00019 00020 if( im == NULL || htop <= hbot || nbin < 2 ) EXRETURN ; 00021 00022 /* can handle shorts and floats; all else -> convert to float */ 00023 00024 switch( im->kind ){ 00025 00026 default: lim = mri_to_float(im) ; break ; 00027 00028 case MRI_byte: lim = mri_to_short(1.0,im) ; break ; 00029 00030 case MRI_short: 00031 case MRI_float: lim = im ; break ; 00032 } 00033 00034 npix = lim->nvox ; 00035 sbin = 0.999999 * nbin / (htop-hbot) ; 00036 00037 if( initialize ) for( ih=0 ; ih < nbin ; ih++ ) hist[ih] = 0 ; 00038 00039 switch( lim->kind ){ 00040 00041 case MRI_short:{ 00042 register short * shar = mri_data_pointer(lim) ; 00043 00044 for( ii=0 ; ii < npix ; ii++ ){ 00045 ih = sbin * (shar[ii]-hbot) ; 00046 if( ih >=0 && ih < nbin ) hist[ih]++ ; 00047 } 00048 } 00049 break ; 00050 00051 case MRI_float:{ 00052 register float * flar = mri_data_pointer(lim) ; 00053 00054 for( ii=0 ; ii < npix ; ii++ ){ 00055 ih = sbin * (flar[ii]-hbot) ; 00056 if( ih >=0 && ih < nbin ) hist[ih]++ ; 00057 } 00058 } 00059 break ; 00060 } 00061 00062 if( lim != im ) mri_free( lim ) ; /* toss temporary array */ 00063 EXRETURN ; 00064 } |