Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Color from a number

4 views
Skip to first unread message

ivankappa

unread,
Feb 22, 2008, 5:22:57 AM2/22/08
to
Hi
I've looked for a function which gives me a color proporcional to
number, but I've not found. I mean, I could use the number but only to
set a color (eg in rgb [num 0.5 0.5]) but I would like to have a whole
set of color in function of the single number. Any idea?

TIA

Yumnam Kirani Singh

unread,
Feb 22, 2008, 7:21:03 AM2/22/08
to
It depends on which type of image your are using. For an rgb image, you have to set the color in that way only. If your image is an indexed image, then you can set the color by a single number which corresponds to the index of the colormap table.

ImageAnalyst

unread,
Feb 22, 2008, 8:14:58 AM2/22/08
to

How about just using one of the pre-defined colormaps that MATLAB
supplies, such as Jet? Plug in an index and you'll get an RGB color
from it.

Really, you need to supply more info. How do we know what color you
want? There are an infinite number of colors that could be generated
from an infinite number of functions. How can I know what function
you'd be happy with?
- ImageAnalyst

ivankappa

unread,
Feb 22, 2008, 10:14:23 AM2/22/08
to
On 22 Feb, 14:14, ImageAnalyst <imageanal...@mailinator.com> wrote:

Fundamentally, I would like to assign a color to a line proporcionally
to its length. The relation is not direct proportion because I've to
face lines with very different length. But, for example, I would like
that the max line is dark red, the 50% line is orange, the 25% is dark
yellow, and so on using all colours like an altimetric map, but they
could be others, as soon as I can put them in an explaining colorbar.

tnx

ImageAnalyst

unread,
Feb 22, 2008, 10:46:12 PM2/22/08
to
> tnx- Hide quoted text -
>
> - Show quoted text -
=========================================
Ivan:
This is pretty easy. You should have been able to figure it out. It
goes something like this:
myColorMap = hot; % Use the "hot" color map for example.
myLineLength = 0.5; % or whatever percentage you want.
myLineColor = myColorMap (int16(myLineLength *64),:); % Extracts a
single RGB color.
% Then plot your line with myLineColor.
If you don't like the hot color map, use autumn or whatever you like
by making up a custom one.
Regards,
ImageAnalyst

ivankappa

unread,
Feb 23, 2008, 6:35:55 AM2/23/08
to
On 23 Feb, 04:46, ImageAnalyst <imageanal...@mailinator.com> wrote:

Thanks man you solved it! I didn't undertand the use of colormap, but
that is what I need!
Regards

0 new messages