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_colorsetup.c

Go to the documentation of this file.
00001 #include "mrilib.h"
00002 
00003 /*----- set up an RGB color table, with ngray level of gray,
00004         and a color "cube" nrr X ngg X nbb color cells on a side;
00005         total number of cells is ngray+nrr*ngg*nbb-1 [05 Oct 2004] -----*/
00006 
00007 MRI_IMAGE * mri_colorsetup( int ngray , int nrr , int ngg , int nbb )
00008 {
00009    MRI_IMAGE *im ;
00010    rgbyte *ar ;
00011    int rr,gg,bb , nn ;
00012    float rac,gac,bac ;
00013 
00014    im = mri_new( ngray + nrr*ngg*nbb - 1 , 1 , MRI_rgb ) ;
00015    ar = (rgbyte *) MRI_RGB_PTR(im) ;
00016 
00017    gac = 255.9f / ngray ; nn = 0 ;          /* actually, ngray+1 levels */
00018    for( gg=0 ; gg <= ngray ; gg++,nn++ ){
00019      ar[nn].r = ar[nn].g = ar[nn].b = (byte)(gac*gg) ;
00020    }
00021 
00022    rac = 255.9f/(nrr-1) ; gac = 255.9f/(ngg-1) ; bac=255.9f/(nbb-1) ;
00023 
00024    for( bb=0 ; bb < nbb ; bb++ ){    /* skip the all black and */
00025     for( gg=0 ; gg < ngg ; gg++ ){   /* the all white colors   */
00026       for( rr=0 ; rr < nrr ; rr++ ){
00027         if( rr==0     && gg==0     && bb==0     ) continue ;
00028         if( rr==nrr-1 && gg==ngg-1 && bb==nbb-1 ) continue ;
00029         ar[nn].r = (byte)(rac*rr) ;
00030         ar[nn].g = (byte)(gac*gg) ;
00031         ar[nn].b = (byte)(bac*bb) ; nn++ ;
00032    } } }
00033 
00034    return im ;
00035 }
 

Powered by Plone

This site conforms to the following standards: