comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Create an array of color name
items: Re: Create an array of color name

Create an array of color name
type: item
description: I am using the coyote library. I need to create an array of different color names. Is there any convenient way to do that? The colors should be best distributed across the loaded color table. I don't know whether it is practicable to name all of these colors within the color table. If not, what is the optional way to produce a set of distinct color names?
creator: changliao1025
date: 2015-01-02T02:11:04-00:00

Re: Create an array of color name
type: item
description: changliao1025@gmail.com writes: > I am using the coyote library. > I need to create an array of different color names. > Is there any convenient way to do that? > The colors should be best distributed across the loaded color table. I don't know whether it is practicable to name all of these colors within the color table. If not, what is the optional way to produce a set of distinct color names? I can't think of any reason why you would have to do this. Why do you need an array of color names? Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.dfanning.com/ Sepore ma de ni thue. ("Perhaps thos speakest truth.")
creator: David Fanning
date: 2015-01-02T03:40:35-00:00

Re: Create an array of color name
type: item
description: On Thursday, January 1, 2015 8:40:40 PM UTC-7, David Fanning wrote: > changliao1025@gmail.com writes: > >> I am using the coyote library. >> I need to create an array of different color names. >> Is there any convenient way to do that? >> The colors should be best distributed across the loaded color table. I don't know whether it is practicable to name all of these colors within the color table. If not, what is the optional way to produce a set of distinct color names? > > I can't think of any reason why you would have to do this. Why do you > need an array of color names? > > Cheers, > > David > -- > David Fanning, Ph.D. > Fanning Software Consulting, Inc. > Coyote's Guide to IDL Programming: http://www.dfanning.com/ > Sepore ma de ni thue. ("Perhaps thos speakest truth.") I'm with David on this. Not every RGB triplet of the 1.6 million possible has its own name, at least in the world of IDL. Thank goodness. But if you're interested in matching RGB triplets against names that IDL knows about from the WC3 definitions, which total only 147, the following function may be of use to you. These are defined in the system variable !color. function triplettoname, rgb names = tag_names(!color) outname = strarr(rgb.length/3) foreach name, names, colorindex do begin d = lonarr(outname.length) for rgbindex = 0, outname.length - 1 do begin if (total(abs(rgb[*, rgbindex] - long(!color.(colorindex)))) eq 0) then begin outname[rgbindex] = name break endif endfor endforeach return, outname end Here's an example, which shows the futility of the task for one of the popular color tables in IDL. IDL> LOADCT, 15 ; Stern Special! IDL> TVLCT, R, G, B, /GET IDL> names = triplettoname(transpose([[r],[g],[b]])) IDL> where(names ne '') 0 255 IDL> names BLACK WHITE This means that of the 256 colors in the Stern Special color table, only two have RGB triplets that exactly match the list of color names known to IDL. The code could be modified to find the "closest" match, but you'd need to define …
creator: Jim Pendleton
date: 2015-01-02T17:04:19-00:00