Usage of ind2gray function in Matlab

table of Contents

ind2gray converts indexed image to grayscale image

syntax

description

example

Convert indexed image to grayscale

Input parameters

Output parameters

Algorithm


ind2gray converts indexed image to grayscale image

syntax

I = ind2gray(X,cmap)

description

I = ind2gray(X,cmap) Convert Xan indexed image with a color map to cmapa grayscale image I. This  ind2grayfunction removes hue and saturation information from the input image while maintaining brightness.

example

Convert indexed image to grayscale

Load the indexed image into the workspace.

[X,map] = imread('trees.tif');

 

Use to convert the image to grayscale ind2gray.

I = ind2gray(X,map);

Display the index image and the converted grayscale image.

imshow(X,map)
title('Indexed Image')

 

figure
imshow(I)
title('Converted Grayscale Image')

 

 
 

Input parameters

X—Index image
number array

Index image, specified as a numeric array of any size and dimensions.

Data type:single  |  doubleuint8|uint16

cmap-Color map-
cby-3 digital array

The color map X associated with the indexed image is specified as can array of -by-3 numbers, where cis the number of colors.

Data type: double

Output parameters

I—Gray image
digital array

Grayscale image, specified as an array of numbers. IHas the same size, size and category X.

Algorithm

ind2grayUse to convert the color map to NTSC coordinates rgb2ntsc, and set the hue and saturation components ( I and Q ) to zero to create a gray color map. ind2grayThen replace the index in the image with the corresponding gray intensity value in the X gray color map.

Guess you like

Origin blog.csdn.net/jk_101/article/details/111957515