image_rgb_to_gray, an Octave 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 information on this web page is distributed under the MIT license.
image_rgb_to_gray is available in a MATLAB version and an Octave version.
image_threshold, an Octave 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.