1 #include "mrilib.h"
2
3 /*** 7D SAFE ***/
4
5 #define NUM_SHORT 65536
6 #define OFF_SHORT 32768
7
8 /*-------- for this one, declare 'int hist[65536]' --------*/
9
mri_histoshort_all(MRI_IMAGE * im,int * hist)10 void mri_histoshort_all( MRI_IMAGE *im , int *hist )
11 {
12 register int ih , npix , ii ;
13 short *sar ;
14
15 ENTRY("mri_histoshort_all") ;
16
17 if( im == NULL || im->kind != MRI_short || hist == NULL ) EXRETURN ;
18
19 npix = im->nvox ;
20 sar = MRI_SHORT_PTR(im) ;
21
22 for( ih=0 ; ih < NUM_SHORT ; ih++ ) hist[ih] = 0 ;
23
24 for( ii=0 ; ii < npix ; ii++ )
25 hist[ sar[ii]+OFF_SHORT ] ++ ;
26
27 EXRETURN ;
28 }
29
30 /*-------- for this one, declare 'int hist[32768]' --------*/
31
mri_histoshort_nonneg(MRI_IMAGE * im,int * hist)32 void mri_histoshort_nonneg( MRI_IMAGE *im , int *hist )
33 {
34 register int ih , npix , ii ;
35 short *sar ;
36
37 ENTRY("mri_histoshort_nonneg") ;
38
39 if( im == NULL || im->kind != MRI_short || hist == NULL ) EXRETURN ;
40
41 npix = im->nvox ;
42 sar = MRI_SHORT_PTR(im) ;
43
44 for( ih=0 ; ih < OFF_SHORT ; ih++ ) hist[ih] = 0 ;
45
46 for( ii=0 ; ii < npix ; ii++ )
47 if( sar[ii] >= 0 ) hist[ sar[ii] ] ++ ;
48
49 EXRETURN ;
50 }
51