image_rgb_to_gray, a MATLAB code 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 * Bwhich attempts to better model the contributions to brightness of the different colors.
function gray = rgb_to_gray ( rgb, equal )where
The computer code and data files described and made available on this web page are distributed under the MIT license
image_rgb_to_gray is available in a MATLAB version.
image_boundary, a MATLAB code which reports the pixels which form the boundary between the black and white regions of a simple image.
image_contrast, a MATLAB code which applies image processing techniques to increase the contrast in an image.
image_decimate, a MATLAB code which compresses an image by dropping the even rows and columns of data.
image_denoise, a MATLAB code which applies image processing techniques to remove noise from an image.
image_double, a MATLAB code which doubles the height and width of an image by repeating each row and column.
image_edge, a MATLAB code which demonstrates a simple technique for edge detection in an image.
image_noise, MATLAB codes which add noise to an image.
image_quantization, a MATLAB code 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 code 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.
MathWorks documentation for the Image Processing Toolbox is available at https://www.mathworks.com/access/helpdesk/help/pdf_doc/images/images_tb.pdf.