Home > vbmeg > external > freesurfer > fscolor2rgb.m

fscolor2rgb

PURPOSE ^

takes integer values used in freesurfer annotation/label files and

SYNOPSIS ^

function rgb=fscolor2rgb(colorvector)

DESCRIPTION ^

 takes integer values used in freesurfer annotation/label files and
 converts them to rgb values (0-255,0-255,0-255)
 according to the calculation: r + g*2^8 + b*2^16
 [note]
   This is originally made by Jason Hubbard.
   https://github.com/jashubbard/matsurfer
   He kindly permitted us to use this code. Thanks Jason.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function rgb=fscolor2rgb(colorvector)
0002 % takes integer values used in freesurfer annotation/label files and
0003 % converts them to rgb values (0-255,0-255,0-255)
0004 % according to the calculation: r + g*2^8 + b*2^16
0005 % [note]
0006 %   This is originally made by Jason Hubbard.
0007 %   https://github.com/jashubbard/matsurfer
0008 %   He kindly permitted us to use this code. Thanks Jason.
0009 
0010 %converts freesurfer integer value back in to r,g,b
0011 b=idivide(int32(colorvector),2^16);
0012 resid=rem(int32(colorvector),2^16);
0013 g=idivide(int32(resid),2^8);
0014 r=rem(int32(resid),2^8);
0015 rgb=double(horzcat(r,g,b))./255;

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005