hsv2rgb
Convert HSV colors to RGB
Description
Examples
Convert HSV Matrix to a Colormap
Create a three-column HSV matrix that specifies five shades of blue. In this case, hue and value are constant, while saturation varies between 1.0
and 0.0
.
hsv = [.6 1 1; .6 .7 1; .6 .5 1; .6 .3 1; .6 0 1];
Convert the HSV matrix to a colormap by calling hsv2rgb
. Then use that colormap in a surface plot.
rgb = hsv2rgb(hsv); surf(peaks); colormap(rgb); colorbar
Convert 3-D HSV Array to a Truecolor Image
Create a 2-by2-by-3 HSV array that specifies four shades of blue.
hsv(:,:,1) = ones(2,2)*.6; hsv(:,:,2) = [1 .7; .3 0]; hsv(:,:,3) = ones(2,2);
Convert the HSV array to a truecolor image using hsv2rgb
. Then display the image.
rgb = hsv2rgb(hsv); image(rgb);
Input Arguments
HSV
— HSV image
m-by-n-by-3 numeric array
HSV image, specified as an
m-by-n-by-3 numeric array with values
in the range [0, 1]. The third dimension of HSV
defines
the hue, saturation, and value for each pixel, respectively, as described in
the table.
Attribute | Description |
---|---|
Hue | Value from 0 to
1 that corresponds to the color’s
position on a color wheel. As hue increases from
0 to 1 , the
color transitions from red to orange, yellow, green,
cyan, blue, magenta, and finally back to red. |
Saturation | Amount of hue or departure from neutral.
0 indicates a neutral shade,
whereas 1 indicates maximum
saturation. |
Value | Maximum value among the red, green, and blue components of a specific color. |
Data Types: double
| single
| logical
hsvmap
— HSV colormap
c-by-3 numeric matrix
HSV colormap, specified as a c-by-3 numeric matrix with
values in the range [0, 1]. Each row of hsvmap
is a
three-element HSV triplet that specifies the hue, saturation, and value
components of a single color of the colormap.
Data Types: double
Output Arguments
RGB
— RGB image
m-by-n-by-3 numeric array
RGB image, returned as an
m-by-n-by-3 numeric array with values
in the range [0, 1]. The third dimension of RGB
defines
the red, green, and blue intensity of each pixel, respectively. The image
has the same data type as the HSV image, HSV
.
Data Types: double
| single
rgbmap
— RGB colormap
c-by-3 numeric matrix
RGB colormap, returned as a c-by-3 numeric matrix with
values in the range [0, 1]. Each row of rgbmap
is a
three-element RGB triplet that specifies the ref, green, and blue components
of a single color of the colormap. The colormap has the same data type as
the HSV colormap, hsvmap
.
Data Types: double
| single
References
[1] Smith, A. R. “Color Gamut Transform Pairs”. SIGGRAPH 78 Conference Proceedings. 1978, pp. 12–19.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
The hsv2rgb
function
fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray
(Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)