Linear combination of color channels
Y = imapplymatrix(M,X)
Y = imapplymatrix(M,X,C)
Y = imapplymatrix(...,output_type)
M— Weighting coefficients for each color channel
Weighting coefficients for each color channel, specified as
a numeric array. If
X is size m-by-n-by-p,
be size q-by-p, where q is
in the range [1,p].
X— Input image
Input image, specified as a numeric array of size m-by-n-by-p.
C— Constant to add to each channel
Constant to add to each channel during the linear combination,
specified as a numeric vector of length q, where q is
number of rows in
output_type— Output data type
Output data type, specified as one of the following character
This example shows how to create a grayscale image by computing the linear combination of three colors channels.
Read a truecolor image into the workspace.
RGB = imread('peppers.png');
Create a coefficient matrix
M = [0.30, 0.59, 0.11];
Compute the linear combination of the RGB channels using the coefficient matrix.
gray = imapplymatrix(M, RGB);
Display the original image and the grayscale conversion.