Doxygen Source Code Documentation
mri_entropy16.c File Reference
#include "mrilib.h"
Go to the source code of this file.
Defines | |
#define | SNUM 65536 |
#define | BNUM 256 |
Functions | |
double | mri_entropy16 (MRI_IMAGE *im) |
double | mri_entropy8 (MRI_IMAGE *im) |
Define Documentation
|
Definition at line 39 of file mri_entropy16.c. Referenced by mri_entropy8(). |
|
Definition at line 6 of file mri_entropy16.c. Referenced by mri_entropy16(). |
Function Documentation
|
Definition at line 8 of file mri_entropy16.c. References calloc, ENTRY, free, l, mri_data_pointer(), MRI_IMAGE::nvox, MRI_IMAGE::pixel_size, RETURN, and SNUM. Referenced by ISQ_statify_one().
00009 { 00010 register int *scount , snum , ii ; 00011 register unsigned short *sar ; 00012 register double sum ; 00013 00014 ENTRY("mri_entropy16") ; 00015 00016 if( im == NULL ) RETURN(0.0l) ; 00017 00018 sar = (unsigned short *) mri_data_pointer( im ) ; 00019 if( sar == NULL ) RETURN(0.0l) ; 00020 00021 snum = (im->nvox * im->pixel_size) / 2 ; if( snum < 2 ) RETURN(0.0l) ; 00022 scount = (int *) calloc( sizeof(int),SNUM ) ; 00023 00024 for( ii=0 ; ii < snum ; ii++ ) scount[sar[ii]]++ ; 00025 00026 sum = 0.0 ; 00027 for( ii=0 ; ii < SNUM ; ii++ ) 00028 if( scount[ii] > 0 ) sum += scount[ii] * log((double)scount[ii]) ; 00029 00030 free( (void *)scount ) ; 00031 00032 sum = -(sum - snum*log((double)snum)) / ( log(2.0l) * snum ) ; 00033 RETURN(sum) ; 00034 } |
|
Definition at line 41 of file mri_entropy16.c. References bnum, BNUM, calloc, ENTRY, free, l, mri_data_pointer(), MRI_IMAGE::nvox, MRI_IMAGE::pixel_size, and RETURN. Referenced by ISQ_statify_one().
00042 { 00043 register int *bcount , bnum , ii ; 00044 register byte *bar ; 00045 register double sum ; 00046 00047 ENTRY("mri_entropy8") ; 00048 00049 if( im == NULL ) RETURN(0.0l) ; 00050 00051 bar = (byte *) mri_data_pointer( im ) ; 00052 if( bar == NULL ) RETURN(0.0l) ; 00053 00054 bnum = (im->nvox * im->pixel_size) ; if( bnum < 2 ) RETURN(0.0l) ; 00055 bcount = (int *) calloc( sizeof(int),BNUM ) ; 00056 00057 for( ii=0 ; ii < bnum ; ii++ ) bcount[bar[ii]]++ ; 00058 00059 sum = 0.0 ; 00060 for( ii=0 ; ii < BNUM ; ii++ ) 00061 if( bcount[ii] > 0 ) sum += bcount[ii] * log((double)bcount[ii]) ; 00062 00063 free( (void *)bcount ) ; 00064 00065 sum = -(sum - bnum*log((double)bnum)) / ( log(2.0l) * bnum ) ; 00066 RETURN(sum) ; 00067 } |