Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!d70g2000hsb.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: custom color map
Date: Wed, 6 Feb 2008 17:06:33 -0800 (PST)
Organization: http://groups.google.com
Lines: 38
Message-ID: <70f57474-2aa9-456e-bbd4-9f7a8dfbeb49@d70g2000hsb.googlegroups.com>
References: <fodjtc$hcn$1@fred.mathworks.com>
NNTP-Posting-Host: 75.186.67.199
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1202346393 8643 127.0.0.1 (7 Feb 2008 01:06:33 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 7 Feb 2008 01:06:33 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: d70g2000hsb.googlegroups.com; posting-host=75.186.67.199; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 
Xref: news.mathworks.com comp.soft-sys.matlab:449768



On Feb 6, 7:38=A0pm, "David Doria" <daviddo...@gmail.com> wrote:
> Is there a way to interpolate between RGB values? I have a
> set of values that I want to map (linearly or otherwise) to
> colors from a color_min to color_max. =A0Since RGB is not
> "incrementable", how would I do this?
>
> I'd like to actually write the function instead of using
> some kind of built in thing because this code is most likely
> going to be ported to c++ at some point.
>
> Any suggestions would be great!
>
> Thanks,
>
> David


=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
David:
Yes, you can interpolate in RGB space if you want.  It depends on what
you want to do.  You could just define certain node colors (say, 5 of
them to define a path through the space), and then interpolate the in-
between values.  There's nothing to say that interpolation in RGB-
space is an inherently "wrong" approach.

However, you might find that using a different color space would be
easier and give a more natural progression of the colors.  For
example, define your path in HSV space (say keeping the same
saturation and just changing the hue), and then converting the values
back to RGB space which is what colormap in MATLAB requires.  Or
define a constant hue and just change the saturation values.

See http://www.easyrgb.com/math.html for more info plus lots of
useful, yet simple, equations.  There is also a newsgroup called
"sci.engr.color" if you're interested.
Regards,
ImageAnalyst