Thread Subject: custom color map

Subject: custom color map

From: David Doria

Date: 7 Feb, 2008 00:38:04

Message: 1 of 4

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. Since 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

Subject: custom color map

From: ImageAnalyst

Date: 7 Feb, 2008 01:06:33

Message: 2 of 4

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

Subject: custom color map

From: David Doria

Date: 7 Feb, 2008 03:16:03

Message: 3 of 4

Perfect! I just fix S and V and increment H, then convert
the hsv to rgb and get exactly the effect I was going for.
I suppose that you just have to be careful and not go
completely around the cone because then your high values
will be red just like the low values! Is there a commonly
used min and max angle to use on the hsv cone?

Thanks for the help!

Dave

ImageAnalyst <imageanalyst@mailinator.com> wrote in message
<70f57474-2aa9-456e-bbd4-9f7a8dfbeb49@d70g2000hsb.googlegroups.com>...
> 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

Subject: custom color map

From: ImageAnalyst

Date: 9 Feb, 2008 14:13:29

Message: 4 of 4

On Feb 6, 10:16=A0pm, "David Doria" <daviddo...@gmail.com> wrote:
> Perfect! I just fix S and V and increment H, then convert
> the hsv to rgb and get exactly the effect I was going for.
> I suppose that you just have to be careful and not go
> completely around the cone because then your high values
> will be red just like the low values! =A0Is there a commonly
> used min and max angle to use on the hsv cone?
>
> Thanks for the help!
>
> Dave
>
> ImageAnalyst <imageanal...@mailinator.com> wrote in message
>
> <70f57474-2aa9-456e-bbd4-9f7a8dfbe...@d70g2000hsb.googlegroups.com>...
>
>
>
> > On Feb 6, 7:38=3DA0pm, "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. =3DA0Since 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
>
> =3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3=
D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=AD=3D
>
>
>
> > =3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=
=3D3D=3D3D=3D3D
> > David:
> > Yes, you can interpolate in RGB space if you want. =A0It
> depends on what
> > you want to do. =A0You could just define certain node colors
> (say, 5 of
> > them to define a path through the space), and then
> interpolate the in-
> > between values. =A0There'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. =A0For
> > 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. =A0Or
> > define a constant hue and just change the saturation values.
>
> > Seehttp://www.easyrgb.com/math.htmlfor more info plus
> lots of
> > useful, yet simple, equations. =A0There is also a newsgroup
> called
> > "sci.engr.color" if you're interested.
> > Regards,
> > ImageAnalyst- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

=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
For hue-only variation, I guess that it's fairly common to have the
low values be blue, then higher values be green, then on through
yellow and orange and ending up with read as the highest values.
Sometimes they go on to interpolate in-between red and white so that
white has the highest values.
Regards,
ImageAnalyst

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com