Thread Subject: Addressing HSV individual components

Subject: Addressing HSV individual components

From: Luca Balbi

Date: 17 Apr, 2009 06:21:02

Message: 1 of 6

Hello everyone,
I looked around but found apparently no answer to my question.

I have a vector quantity (with components, say, vx, vy and vz)to be plotted in a pseudo-color representation.
I would like to make a pcolor plot, with colors given by:

H = function_defining_hue(vx, vy, vz)
S = function_defining_saturation(vx, vy, vz)
V = function_defining_value(vx, vy, vz)

where the functions can be arbitrary.

How can I do that? Using the HSV colormap only enalbes me to change the hue component, I would like to change all 3 HSV components using my data.

Many thanks to everyone!

Subject: Addressing HSV individual components

From: Daniel Armyr

Date: 17 Apr, 2009 07:31:02

Message: 2 of 6

I am not sure I understand what you are asking so I will rephrase it as I understand it:
You want to plot data and define an arbitrary relationship between the values of the datapoint and the color displayed.

To do this, you just implement your functions as you propose. Then you convert your colors to RGB (http://en.wikipedia.org/wiki/HSL_color_space). Finally, you use the color argument that most plotting functions in matlab allow you to supply to get the right color on the right point. Don't bother about colormaps. They are far too blunt for what I think you are trying to do.

--DA

Subject: Addressing HSV individual components

From: Luca Balbi

Date: 17 Apr, 2009 08:20:03

Message: 3 of 6

DA,
that sounds terribly reasonable and I think it's exactly what I need.
So thank you!
As I'm not very confident with this kind of argument, once I have the colors I want I could simply use the 'image' command to display that, right?

Subject: Addressing HSV individual components

From: Daniel Armyr

Date: 17 Apr, 2009 09:17:02

Message: 4 of 6

You could, but that would assume that vx, vy and vz are monotnically increasing linear functions.

What you want to do is:
%calculate a matrix C of color values
c = (...)

%Do a mesh or surf plot
mesh( vx, vy, vz, C );
or
surf ( vx, vy, vz, C );

Subject: Addressing HSV individual components

From: rych

Date: 28 Apr, 2009 17:14:10

Message: 5 of 6

On Apr 17, 8:31=A0am, "Daniel Armyr" <firstn...@lastname.se> wrote:

>
> ...Finally, you use the color argument that most plotting functions in ma=
tlab allow you to supply to get the right color on the right point. Don't b=
other about colormaps. They are far too blunt for what I think you are tryi=
ng to do.
>
No Daniel, unfortunately, we can't avoid using colormaps when
supplying a C matrix as in surf ( vx, vy, vz, C ): "The scaled color
values are used as indices into the current colormap". Or am I missing
something? I would too like to supply my own RGB color matrix, but I
don't see how to do it with the standard surf.
Igor

Subject: Addressing HSV individual components

From: Daniel Armyr

Date: 29 Apr, 2009 08:25:05

Message: 6 of 6

> No Daniel, unfortunately, we can't avoid using colormaps when
> supplying a C matrix as in surf ( vx, vy, vz, C ): "The scaled color
> values are used as indices into the current colormap". Or am I missing
> something?

I think you are wrong, but I have not verified it. Look in the help files for "Surfaceplot Properties" and ceck out the section "CData".

--
CData: matrix

Vertex colors. A matrix containing values that specify the color at every point in ZData. If you set the FaceColor property to texturemap, CData does not need to be the same size as ZData. In this case, MATLAB maps CData to conform to the surfaceplot defined by ZData.

You can specify color as indexed values or true color. Indexed color data specifies a single value for each vertex. These values are either scaled to map linearly into the current colormap (see caxis) or interpreted directly as indices into the colormap, depending on the setting of the CDataMapping property. Note that any non-texture data passed as an input argument must be of type double.

True color defines an RGB value for each vertex. If the coordinate data (XData, for example) are contained in m-by-n matrices, then CData must be an m-by-n-by-3 array. The first page contains the red components, the second the green components, and the third the blue components of the colors.
--

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
surfaceplot Daniel Armyr 29 Apr, 2009 04:30:07
surface Daniel Armyr 29 Apr, 2009 04:30:07
texture Daniel Armyr 29 Apr, 2009 04:30:07
colormap Luca Balbi 17 Apr, 2009 02:25:06
dec Luca Balbi 17 Apr, 2009 02:25:06
hsv Luca Balbi 17 Apr, 2009 02:25:06
rssFeed for this Thread

Contact us at files@mathworks.com