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  

mri_histoshort.c

Go to the documentation of this file.
00001 #include "mrilib.h"
00002 
00003 /*** 7D SAFE ***/
00004 
00005 #define NUM_SHORT 65536
00006 #define OFF_SHORT 32768
00007 
00008 /*-------- for this one, declare 'int hist[65536]' --------*/
00009 
00010 void mri_histoshort_all( MRI_IMAGE * im , int * hist )
00011 {
00012    register int ih , npix , ii ;
00013    short * sar ;
00014 
00015 ENTRY("mri_histoshort_all") ;
00016 
00017    if( im == NULL || im->kind != MRI_short || hist == NULL ) EXRETURN ;
00018 
00019    npix = im->nvox ;
00020    sar  = MRI_SHORT_PTR(im) ;
00021 
00022    for( ih=0 ; ih < NUM_SHORT ; ih++ ) hist[ih] = 0 ;
00023 
00024    for( ii=0 ; ii < npix ; ii++ )
00025       hist[ sar[ii]+OFF_SHORT ] ++ ;
00026 
00027    EXRETURN ;
00028 }
00029 
00030 /*-------- for this one, declare 'int hist[32768]' --------*/
00031 
00032 void mri_histoshort_nonneg( MRI_IMAGE * im , int * hist )
00033 {
00034    register int ih , npix , ii ;
00035    short * sar ;
00036 
00037 ENTRY("mri_histoshort_nonneg") ;
00038 
00039    if( im == NULL || im->kind != MRI_short || hist == NULL ) EXRETURN ;
00040 
00041    npix = im->nvox ;
00042    sar  = MRI_SHORT_PTR(im) ;
00043 
00044    for( ih=0 ; ih < OFF_SHORT ; ih++ ) hist[ih] = 0 ;
00045 
00046    for( ii=0 ; ii < npix ; ii++ )
00047       if( sar[ii] >= 0 ) hist[ sar[ii] ] ++ ;
00048 
00049    EXRETURN ;
00050 }
 

Powered by Plone

This site conforms to the following standards: