Owning Class: support
Requires: MathScript RT Module
b = rgb_to_grayscale(a)
Legacy Name: rgb2gray
Converts an RGB image to grayscale.
| Name | Description |
|---|---|
| a | Specifies a real matrix. |
| Name | Description |
|---|---|
| b | Returns the grayscale representation of the image. b is the same size as a. |
[X, Y] = meshgrid2d(-1:0.01:1);
R = (2-X.^2-Y.^2)*255/2;
G = cos(X*pi/2).*255;
B = cos(Y*pi/2).*255;
image = R*255*255+G*255+B;
fwrite_image(image, 'ImageTest.bmp', 'BMP');
gray = rgb_to_grayscale(image);
surface(gray);
colormap([0, 0, 0; 1, 1, 1]);