1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3//EN"> 2<HTML><HEAD> 3 <TITLE>User's Reference - Color</TITLE> 4 <META HTTP-EQUIV="keywords" CONTENT="GRAPHICS VISUALIZATION VISUAL PROGRAM DATA 5MINING"> 6 <meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"> 7</HEAD><BODY BGCOLOR="#FFFFFF" link="#00004b" vlink="#4b004b"> 8 <TABLE width=510 border=0 cellpadding=0 cellspacing=0> 9 <TR> 10 <TD><IMG src="../images/spacer.gif" width=80 height=1></TD> 11 <TD><IMG src="../images/spacer.gif" width=49 height=1></TD> 12 <TD><IMG src="../images/spacer.gif" width=24 height=1></TD> 13 <TD><IMG src="../images/spacer.gif" width=100 height=1></TD> 14 <TD><IMG src="../images/spacer.gif" width=3 height=1></TD> 15 <TD><IMG src="../images/spacer.gif" width=127 height=1></TD> 16 <TD><IMG src="../images/spacer.gif" width=6 height=1></TD> 17 <TD><IMG src="../images/spacer.gif" width=50 height=1></TD> 18 <TD><IMG src="../images/spacer.gif" width=71 height=1></TD> 19 </TR> 20 <TR> 21 <TD colspan=9><IMG src="../images/flcgh_01.gif" width=510 height=24 alt="OpenDX - Documentation"></TD> 22 </TR> 23 <TR> 24 <TD colspan=2><A href="../allguide.htm"><IMG src="../images/flcgh_02.gif" width=129 height=25 border="0" alt="Full Contents"></A></TD> 25 <TD colspan=3><A href="../qikguide.htm"><IMG src="../images/flcgh_03.gif" width=127 height=25 border="0" alt="QuickStart Guide"></A></TD> 26 <TD><A href="../usrguide.htm"><IMG src="../images/flcgh_04.gif" width=127 height=25 border="0" alt="User's Guide"></A></TD> 27 <TD colspan=3><B><A href="../refguide.htm"><IMG src="../images/flcgh_05d.gif" width=127 height=25 border="0" alt="User's Reference"></A></B></TD> 28 </TR> 29 <TR> 30 <TD><A href="refgu032.htm"><IMG src="../images/flcgh_06.gif" width=80 height=17 border="0" alt="Previous Page"></A></TD> 31 <TD colspan=2><A href="refgu034.htm"><IMG src="../images/flcgh_07.gif" width=73 height=17 border="0" alt="Next Page"></A></TD> 32 <TD><A href="../refguide.htm"><IMG src="../images/flcgh_08.gif" width=100 height=17 border="0" alt="Table of Contents"></A></TD> 33 <TD colspan=3><A href="refgu009.htm"><IMG src="../images/flcgh_09.gif" width=136 height=17 border="0" alt="Partial Table of Contents"></A></TD> 34 <TD><A href="refgu175.htm"><IMG src="../images/flcgh_10.gif" width=50 height=17 border="0" alt="Index"></A></TD> 35 <TD><A href="../srchindx.htm"><IMG src="../images/flcgh_11.gif" width=71 height=17 border="0" alt="Search"></A></TD> 36 </TR> 37 </TABLE> 38 <H3><A name="HDRCOLOR" ></A>Color</H3> 39 <A NAME="IDX417"></A><A NAME="IDX418"></A> 40<A NAME="IDX419"></A> 41<P><STRONG>Category</STRONG> 42<P> 43<A HREF="refgu008.htm#HDRCATTRN">Transformation</A> 44<A NAME="IDX420"></A> 45<A NAME="IDX421"></A> 46<P><STRONG>Function</STRONG> 47<P> 48Colors a field. 49<P><STRONG>Syntax</STRONG> 50<PRE><STRONG> 51colored</STRONG> = Color(<STRONG>input, color, opacity, component, delayed</STRONG>); 52</PRE> 53<P><STRONG>Inputs</STRONG> 54<BR> 55<TABLE BORDER> 56<TR> 57<TH ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">Name 58</TH><TH ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">Type 59</TH><TH ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">Default 60</TH><TH ALIGN="LEFT" VALIGN="TOP" WIDTH="40%">Description 61</TH></TR><TR> 62<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%"><TT><STRONG>input</STRONG></TT> 63</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">field 64</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">none 65</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="40%">field to be colored 66</TD></TR><TR> 67<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%"><TT><STRONG>color</STRONG></TT> 68</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">field or vector or string 69</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">no color added 70</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="40%">RGB color 71</TD></TR><TR> 72<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%"><TT><STRONG>opacity</STRONG></TT> 73</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">field or scalar 74</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">input dependent 75</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="40%">opacity 76</TD></TR><TR> 77<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%"><TT><STRONG>component</STRONG></TT> 78</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">string 79</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">"colors" 80</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="40%">component to be colored 81</TD></TR><TR> 82<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%"><TT><STRONG>delayed</STRONG></TT> 83</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">flag 84</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">0 85</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="40%"> 860: apply maps 87<BR> 881: delay applying color and 89 opacity maps (byte data 90 only) 91<BR></TD></TR></TABLE> 92<P><STRONG>Outputs</STRONG> 93<BR> 94<TABLE BORDER> 95<TR> 96<TH ALIGN="LEFT" VALIGN="TOP" WIDTH="25%">Name 97</TH><TH ALIGN="LEFT" VALIGN="TOP" WIDTH="25%">Type 98</TH><TH ALIGN="LEFT" VALIGN="TOP" WIDTH="50%">Description 99</TH></TR><TR> 100<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="25%"><TT><STRONG>colored</STRONG></TT> 101</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="25%">color field 102</TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="50%">color-mapped input field 103</TD></TR></TABLE> 104<P><STRONG>Functional Details</STRONG> 105<P> 106This module adds a specified color to a specified input object. 107<TABLE CELLPADDING="3"> 108<TR VALIGN="TOP"><TD><P><B><TT><STRONG>input</STRONG></TT> 109</B></TD><TD><P>is the field to be colored. 110</TD></TR><TR VALIGN="TOP"><TD><P><B><TT><STRONG>color</STRONG></TT> 111</B></TD><TD><P>specifies how the input field is to be colored. 112The specification can be the vector value of an RGB color, a string, or 113a color map. 114<P> 115If <TT><STRONG>color</STRONG></TT> is an RGB color, the value should be in 116the range of 0-1 (but see <A HREF="refgu048.htm#HDRCVOLRND">"Coloring Objects 117for Volume Rendering"</A>). 118 119The Convert module can convert HSV (hue, saturation, and value) colors 120to RGB. 121 122<P> 123If <TT><STRONG>color</STRONG></TT> is a string, that string should come from 124a lookup table, which can be specified by setting the DXCOLORS 125environment variable or by using the <TT>-colors</TT> flag 126with the <TT>dx</TT> command. 127If no table is specified, Data Explorer will search (in the order shown) for one 128of the following: 129<OL COMPACT> 130<LI>the file <TT>colors.txt</TT> in <TT>DXROOT/lib</TT> 131<LI>the same file in <TT><STRONG>/usr/local/dx/lib</STRONG></TT> (if this was 132not the setting for DXROOT). 133Note that the colors in this file correspond to the X Window System** 134color list, except that the Data Explorer colors are squared first (see 135<A HREF="usrgu077.htm#HDRINTCOLS">Appendix F. "Data Explorer Colors"</A> in 136<I>IBM Visualization Data Explorer User's Guide</I>). 137</OL> 138When entering the names of colors, note that the module: 139<UL COMPACT> 140<LI>accepts spaces in names. 141<LI>ignores capitalization. 142<LI>accepts the spellings <I>gray</I> and <I>grey</I>. 143</UL> 144<P> 145If <TT><STRONG>color</STRONG></TT> is a color map it can be the output of the 146Colormap Editor (the first output) or an imported color map. 147Note also that if this parameter is a color map (as opposed to a single 148color), then the <TT><STRONG>input</STRONG></TT> parameter must contain a 149"data" component; 150if the "data" component consists of vector data, the color and 151opacity mapping are based on the magnitude of the data. 152If this parameter is an imported .cm file (see <A 153HREF="refgu073.htm#HDRIMPORT">Import</A>), 154the color-map part of the color-opacity map is 155extracted and used. 156<P> 157Omitting the color specification allows you to change the opacity of an 158object without modifying its color (see <A HREF="#SPTWFCMAP">reference #3</A> 159for a description of a color map). 160<P> 161A well-formed color map should contain a 1-dimensional "positions" 162<A NAME="SPTWFCMAP"><I>(Ref #3.)</I></A> 163component and a 3-dimensional "data" component. 164 165As with any map in Data Explorer, the "positions" component represents the 166domain in which to look up values, and the "data" component 167represents the range, that is, the values which are associated with 168items in the "positions" component. 169<P> 170Color maps can specify either smoothly varying colors or 171constant colors across a set of ranges of data values. 172If the color map has position-dependent data, 173then linear interpolation 174will be used to derive colors for data values in the 175data field between those 176given in the "positions" component of the map (see 177<A HREF="#FIGCOLMAP">Figure 1</A>). 178<P><B><A NAME="FIGCOLMAP" HREF="../refguide.htm#FT_FIGCOLMAP">Figure 1. 179Position-dependent colormaps</A></B>. In this figure a diagram of a data field 180is shown. One of the data values, 3.5, has been indicated. The field structure 181is also shown, with "positions", "data", and "connections" components. When a 182color map is applied to this field using the Color module, the data value 3.5 is 183used as a lookup value into the "positions" component of the color map. The 184color map has a "data" component which is dependent on (in a one-to-one 185correspondence with) the "positions" component. The color map contains colors 186for the value 3 (the RGB value [0 1 1], or cyan) and for the value 4 187(the RGB value [0 0 0], or black). Data Explorer interpolates between 188these two colors to derive the color [0 .5 .5], or dark cyan, which is 189then placed in the "colors" component of the data field as the color 190corresponding to the data value 3.5. <B><BR><CENTER><IMG 191SRC="../images/colormap.gif" ALT="Figure colormap not 192displayed."></CENTER><BR></B><BR> 193If the colormap has 194connection-dependent data, then the color for any data value 195in the data field 196between two values in the "positions" component of the map 197will be constant (see <A HREF="#FIGCOLMAP1">Figure 2</A>). 198<P><B><A NAME="FIGCOLMAP1" HREF="../refguide.htm#FT_FIGCOLMAP1">Figure 2. 199Connection-dependent colormaps</A></B>. In this figure a diagram of a data field 200is shown. One of the data values, 3.5, has been indicated. The field structure 201is also shown, with "positions", "data", and "connections" components. When a 202color map is applied to this field using the Color module, the data value 3.5 is 203used as a lookup value into the "positions" component of the color map. The 204color map has a "data" component which is dependent on (in a one-to-one 205correspondence with) the "connections" component. The color map contains colors 206for the range 1 to 1.5 (the RGB value [1 1 0], or yellow), 207the range 1.5 to 3 (the RGB value [0 1 1], or cyan) and for 208the range 3 to 4 (the RGB value [0 0 1], or blue). Since 3.5 209lies in the range 3 to 4, Data Explorer looks up the color 210[0 0 1] and places it in the "colors" component of the data 211field as the color corresponding to the data value 3.5. <B><BR><CENTER><IMG 212SRC="../images/colomap1.gif" ALT="Figure colomap1 not 213displayed."></CENTER><BR></B><BR> 214In either case, the 215"connections" component of the map should be a set of lines connecting 216the positions. 217<P> 218The Colormap Editor puts out a well-formed colormap. 219The Construct module can also be used to create a color map. For 220example, you have 10 data values to which you want to apply particular 221colors. List those 10 data values as the first parameter to 222Construct. Then list the 10 colors (RGB vectors) as the 223last parameter to Construct. This will automatically create a 224position-dependent 225color map of the appropriate structure to use with the Color 226module. Alternatively, if you list only 9 colors (RGB vectors) 227as the last parameter to Construct, a connection-dependent 228color map will be created. 229<P> 230For surfaces, RGB colors in a color map 231 232should range between 0 and 1. Compute 233can be used to convert colors from the range of 0 to 255 to 234the range 0 to 1. 235To choose appropriate colors for volumes see <A 236HREF="refgu048.htm#HDRCVOLRND">"Coloring Objects for Volume Rendering"</A>. 237Note that if you have an HSV (hue, saturation, and value) color 238map, it can be converted to an RGB (red, blue, green) color map 239using the Convert module. 240 241</TD></TR><TR VALIGN="TOP"><TD><P><B><TT><STRONG>opacity</STRONG></TT> 242</B></TD><TD><P>can be a scalar value or a field specifying an opacity map. 243This map may be the output of the Colormap Editor (the second output) 244or an imported opacity map. 245If it is an imported .cm file (see <A HREF="refgu073.htm#HDRIMPORT">Import</A>), 246the opacity part of the color-opacity 247map will be extracted and used (see below for a 248description of an opacity map). 249<P> 250The input color or opacity can also be groups of color or of opacity 251maps, as long as the hierarchy of the group matches that of 252<TT><STRONG>input</STRONG></TT>. 253<P> 254For surfaces, the default value of <TT><STRONG>opacity</STRONG></TT> is 1.0; 255the valid range is 0-1. 256For volumes, the default value is 0.5. 257If the object to be colored is a volume with an aspect ratio much 258different from 1, it may appear dark from certain viewing 259directions. 260In that case, use the Compute module to multiply the contents of the 261data component of the opacity and color maps by a scale factor 262greater than 1 before using them as an input to the Color 263module. 264(If you are using delayed colors, modify the "color multiplier" 265and "opacity multiplier" attributes. 266See the <TT><STRONG>delayed</STRONG></TT> parameter, described below.) 267<P> 268A well-formed opacity map should contain a 1-dimensional 269"positions" component and a 1-dimensional 270"data" component representing 271opacities. 272 273For surfaces, valid opacities 274range between 0 (transparent) and 1 (opaque). 275To choose appropriate opacities for volumes see <A 276HREF="refgu048.htm#HDRCVOLRND">"Coloring Objects for Volume Rendering"</A>. 277Just as with a color map, the 278"data" component may be either position-dependent or 279connection-dependent. An opacity map can be created either 280with the Colormap Editor or using the Construct module as 281described for color maps. 282 283</TD></TR><TR VALIGN="TOP"><TD><P><B><TT><STRONG>component</STRONG></TT> 284</B></TD><TD><P>specifies the component to which the module adds colors. 285The default is the "colors" component, which applies to both the 286front and the back of the object, but you can specify "front 287colors" or "back colors" instead. 288Either one, if present, takes precedence over the "colors" 289component. 290If you specify <TT><STRONG>component</STRONG></TT> as "colors," the 291module deletes any existing "front colors" or 292"back colors" components. 293Which faces are "front" and which faces are "back" depends on 294how "connections" component of the faces is defined (see 295<A HREF="usrgu025.htm#HDRSTANCOM">"Standard Components"</A> in <I>IBM 296Visualization Data Explorer User's Guide</I>). 297</TD></TR><TR VALIGN="TOP"><TD><P><B><TT><STRONG>delayed</STRONG></TT> 298</B></TD><TD><P>causes Color to create "delayed colors." 299This option is valid only for byte data. 300When <TT><STRONG>delayed</STRONG></TT> = 1: 301<UL COMPACT> 302<LI>the "colors" component is a copy of the "data" component, 303and a "color map" component is created (i.e., a color lookup 304table with 256 entries representing the appropriate color for 305each of the 256 possible data values). 306<LI>(if <TT><STRONG>opacity</STRONG></TT> has been specified) the 307"opacities" component is a copy of the "data" 308component, and an opacity map with 256 entries 309is created. 310<LI>the module adds a "direct color map" attribute to the output 311object (see <A HREF="refgu048.htm#HDRUDCMPS">"Using Direct Color Maps"</A>). 312</UL> 313</TD></TR></TABLE> 314<P><STRONG>Components</STRONG> 315<P> 316Adds a "colors" component. 317An "opacities" component is added if <TT><STRONG>opacity</STRONG></TT> 318is less than 1 or the input data is a volume. 319If <TT><STRONG>delayed</STRONG></TT> = 1, the 320"colors" 321component is a copy of the 322"data" 323component and a 324"color map" 325component is created. 326Likewise, an 327"opacity map" 328component 329is created if 330<TT><STRONG>opacity</STRONG></TT> is less than one or the input is a volume. 331<P><STRONG>Example Visual Programs</STRONG> 332<P> 333Nearly every example visual program uses Color, including: 334<PRE> 335AlternateVisualizations.net 336Sealevel.net 337UsingColormaps.net 338SIMPLE/Color 339</PRE> 340<P><STRONG>See Also</STRONG> 341<P> 342 <A HREF="refgu016.htm#HDRAUTOCOL">AutoColor</A>, 343 <A HREF="refgu022.htm#HDRCAPTION">Caption</A>, 344 <A HREF="refgu040.htm#HDRCONVERT">Convert</A>, 345 <A HREF="refgu091.htm#HDRMAP">Map</A> 346 <P> 347 <HR> 348 <DIV align="center"> 349 <P><A href="../allguide.htm"><IMG src="../images/foot-fc.gif" width="94" height="18" border="0" alt="Full Contents"></A> <A href="../qikguide.htm"><IMG src="../images/foot-qs.gif" width="94" height="18" border="0" alt="QuickStart Guide"></A> <A href="../usrguide.htm"><IMG src="../images/foot-ug.gif" width="94" height="18" border="0" alt="User's Guide"></A> <A href="../refguide.htm"><IMG src="../images/foot-ur.gif" width="94" height="18" border="0" alt="User's Reference"></A></P> 350 </DIV> 351 <DIV align="center"> 352 <P><FONT size="-1">[ <A href="http://www.research.ibm.com/dx">OpenDX Home at IBM</A> | <A href="http://www.opendx.org/">OpenDX.org</A> ] </FONT></P> 353 <P></P> 354 </DIV> 355 <P></P> 356 </BODY></HTML> 357