rgb2gray matlab codes, Study notes of Telecommunication electronics

matlab codes rgb2gray

Typology: Study notes

2014/2015

Uploaded on 06/27/2015

asim188
asim188 🇵🇰

1 document

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
rgb2gray
Convert RGB image or colormap to grayscale
collapse all in page
Syntax
I = rgb2gray(RGB)
newmap = rgb2gray(map)
gpuarrayB = rgb2gray(gpuarrayA)
Description
I = rgb2gray(RGB) converts the truecolor image RGB to the grayscale intensity image
I. rgb2gray converts RGB images to grayscale by eliminating the hue and saturation information while retaining
the luminance.
newmap = rgb2gray(map) returns a grayscale colormap equivalent to map.
gpuarrayB = rgb2gray(gpuarrayA) performs the operation on a GPU. gpuarrayA can be either
an RGB image or a colormap. gpuarrayB is a gpuArray of the same type as gpuarrayA. This syntax requires
the Parallel Computing Toolbox™
Note: A grayscale image is also called a gray-scale, gray scale, or gray-level image.
Class Support
If I is an RGB image, it can be of class uint8, uint16, single, or double. The output image I is of the
same class as the input image. If I is a colormap, the input and output colormaps are both of class double.
If gpuarrayA is an RGB gpuArray image, it can be uint8, uint16, single, or double. The output
gpuArray imagegpuarrayB has the same class as the input image. If gpuarrayA is a colormap, the input and
output colormaps are gpuArrays of class double.
Examples
Convert an RGB image to a grayscale image.
I = imread('board.tif');
J = rgb2gray(I);
figure, imshow(I), figure, imshow(J);
Convert an RGB image to a grayscale image on a GPU.
I = gpuArray(imread('board.tif'));
J = rgb2gray(I);
figure, imshow(I), figure, imshow(J);
Convert the colormap to a grayscale colormap.
[X,map] = imread('trees.tif');
gmap = rgb2gray(map);
figure, imshow(X,map), figure, imshow(X,gmap);
pf2

Partial preview of the text

Download rgb2gray matlab codes and more Study notes Telecommunication electronics in PDF only on Docsity!

rgb2gray

Convert RGB image or colormap to grayscale collapse all in page

Syntax

I = rgb2gray(RGB) newmap = rgb2gray(map) gpuarrayB = rgb2gray(gpuarrayA) Description I = rgb2gray(RGB) converts the truecolor image RGB to the grayscale intensity image I. rgb2gray^ converts RGB images to grayscale by eliminating the hue and saturation information while retaining the luminance. newmap = rgb2gray(map) returns a grayscale colormap equivalent to map. gpuarrayB = rgb2gray(gpuarrayA) performs the operation on a GPU. gpuarrayA can be either an RGB image or a colormap. gpuarrayB^ is a gpuArray of the same type as^ gpuarrayA. This syntax requires the Parallel Computing Toolbox™ Note: A grayscale image is also called a gray-scale, gray scale, or gray-level image. Class Support If I is an RGB image, it can be of class uint8, uint16, single , or double. The output image I is of the same class as the input image. If I^ is a colormap, the input and output colormaps are both of class^ double^. If gpuarrayA^ is an RGB gpuArray image, it can be^ uint8,^ uint16,^ single^ , or^ double^. The output gpuArray imagegpuarrayB^ has the same class as the input image. If^ gpuarrayA^ is a colormap, the input and output colormaps are gpuArrays of class double^. Examples Convert an RGB image to a grayscale image. I = imread('board.tif'); J = rgb2gray(I); figure, imshow(I), figure, imshow(J); Convert an RGB image to a grayscale image on a GPU. I = gpuArray(imread('board.tif')); J = rgb2gray(I); figure, imshow(I), figure, imshow(J); Convert the colormap to a grayscale colormap. [X,map] = imread('trees.tif'); gmap = rgb2gray(map); figure, imshow(X,map), figure, imshow(X,gmap);

Convert the colormap to a grayscale colormap on a GPU. Note how the example pass the colormap to the gpuArray function. [X,map] = imread('trees.tif');

% Pass colormap to gpuArray gmap = rgb2gray(gpuArray(map)); figure, imshow(X,map), figure, imshow(X,gmap);