ind2rgb
Convert indexed image to RGB image
Syntax
Description
Examples
Convert Indexed Image to RGB
Read the first image in a sample indexed image file.
[A,map] = imread("corn.tif"); whos A map
Name Size Bytes Class Attributes A 415x312 129480 uint8 map 256x3 6144 double
The indexed image A
is a 415-by-312 matrix of type uint8
, and the colormap map
is a 256-by-3 matrix of type double
. The dimensions of map
indicate that the indexed image contains up to 256 colors.
Display the image.
imshow(A,map)
Convert the indexed image to an RGB image. The result is a 415-by-312-by-3 array of type double
.
RGB = ind2rgb(A,map);
Check that the values of the RGB
image are in the range [0, 1].
[minVal,maxVal] = bounds(RGB(:))
minVal = 0.0078
maxVal = 0.9765
Input Arguments
X
— Indexed image
m-by-n matrix of integers
Indexed image, specified as an m-by-n matrix of integers.
If you specify
X
as an array of integer data type, then the value 0 corresponds to the first color in the colormapmap
. For a colormap containing c colors, values of imageX
are clipped to the range [0, c-1].If you specify
X
as an array of data typesingle
ordouble
, then the value 1 corresponds to the first color in the colormap. For a colormap containing c colors, values of imageX
are clipped to the range [1, c].
Data Types: single
| double
| uint8
| uint16
map
— Colormap
c-by-3 matrix
Colormap associated with indexed image X
, specified as a
c-by-3 matrix with values in the range [0, 1]. Each row of
map
is a three-element RGB triplet that specifies the red, green,
and blue 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].
Data Types: double
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® 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 ind2rgb
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
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
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)