Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

ind2gray

Convert indexed image to grayscale image

Syntax

I = ind2gray(X,map)

Description

I = ind2gray(X,map) converts the image X with colormap map to a grayscale image I. ind2gray removes the hue and saturation information from the input image while retaining the luminance.

Note

A grayscale image is also called a gray-scale, gray scale, or gray-level image.

Class Support

X can be of class uint8, uint16, single, or double. map is double. I is of the same class as X.

Examples

collapse all

Load an indexed image into the workspace.

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

Convert the image to grayscale using ind2gray.

I = ind2gray(X,map);

Display the indexed image and the converted grayscale image.

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

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

Algorithms

ind2gray converts the colormap to NTSC coordinates using rgb2ntsc, and sets the hue and saturation components (I and Q) to zero, creating a gray colormap. ind2gray then replaces the indices in the image X with the corresponding grayscale intensity values in the gray colormap.

Introduced before R2006a

Was this topic helpful?