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 File Reference

#include "mrilib.h"

Go to the source code of this file.


Functions

MRI_IMAGEmri_colorsetup (int ngray, int nrr, int ngg, int nbb)

Function Documentation

MRI_IMAGE* mri_colorsetup int    ngray,
int    nrr,
int    ngg,
int    nbb
 

Definition at line 7 of file mri_colorsetup.c.

References rgbyte::b, rgbyte::g, mri_new(), MRI_RGB_PTR, and rgbyte::r.

Referenced by ISQ_saver_CB().

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: