IMAGE_RGB_TO_GRAY
Grayscale Version of RGB Image


IMAGE_RGB_TO_GRAY is a MATLAB function which creates a grayscale version of an RGB image.

An RGB image is an (M,N,3) array.

A grayscale image is an (M,N) array.

A grayscale version of an RGB image can be made by averaging the RGB components of each pixel.

A more sophisticated approach uses the luminance function:

        GRAY = 0.2126 * R + 0.7152 * G + 0.0722 * B
      
which attempts to better model the contributions to brightness of the different colors.

Usage:

function gray = rgb_to_gray ( rgb, equal )
where

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Related Data and Programs:

IMAGE_CONTRAST, a MATLAB program which applies image processing techniques to increase the contrast in an image.

IMAGE_DENOISE, a MATLAB program which applies image processing techniques to remove noise from an image.

IMAGE_EDGE, a MATLAB program which demonstrates a simple technique for edge detection in an image.

IMAGE_NOISE, MATLAB programs which add noise to an image.

IMAGE_QUANTIZATION, a MATLAB library which demonstrates how the KMEANS algorithm can be used to reduce the number of colors or shades of gray in an image.

IMAGE_THRESHOLD, a MATLAB library which creates a black and white version of a grayscale image by specifying a single threshold value; pixels below this value become black, and above this value they are white.

Reference:

MathWorks documentation for the Image Processing Toolbox is available at http://www.mathworks.com/access/helpdesk/help/pdf_doc/images/images_tb.pdf.

Source Code:

Examples and Tests:

CONJUNCTION is an astronomical image.

STAR_FIELD is an astronomical image.

You can go up one level to the MATLAB source codes.


Last revised on 26 February 2011.