GETRGB

Purpose:

Returns the separate RGB components of an image.

Syntax:

(r, g, b, alpha) = GETRGB(image, imbits)

image

-

An array, the input image.

imbits

-

Optional. An integer, the RGB value mode:

0:

return the current RGB values (default)

1:

Return the original RGB values

 

Returns:

Up to four arrays with the same size as the input.

 

(r, g, b) = GETRGB(image, imbits) returns the r, g, b values as three separate series.

 

(r, g, b, alpha) = GETRGB(image, imbits) returns the r, g, b and alpha transparency values as four separate series.

Example:

W1: readimage(".\data\mandrill.bmp");(r, g, b) = getrgb(w0);g *= 1.5

W2: rgbimage(r, g, b);

 

W2 contains a new RGB image formed by increasing the green component of W1 by 50%.

Example:

W1: readimage(gethome + "\data\mandrill.bmp")

W2: ((demean(xvals(W1))^2) + (demean(yvals(W1)')'^2)) > (50)^2;setplottype(2)

W3: (r, g, b, a) = getrgb(w1);rgbimage(r*w2, g*w2, b*w2, w2)

W4: gnorm(1000, 1);overlay(w3);focus(2);setxy(-50, 300, -60, 300)

 

W1 contains the original bitmap image.

 

W2 uses the X and Y values of the image to construct a circular region.

 

W3 creates a new image by masking the original RGB and alpha values with the circular mask, The image is formed with the masked components. The new image is the original image with a transparent "hole" at the center.

 

W4 displays a series overlayed with the new image. The series values appear in the transparent hole.

Example:

W1: readimage(gethome + "\data\kasha.jpg");rainbow

W2: (r1, g1, b1) = getrgb(w1);rgbimage(r1, g1, b1)

W3: (r2, g2, b2) = getrgb(w1, 1);rgbimage(r2, g2, b2)

 

W1 contains a 24 bit bitmap image shaded with the "rainbow" colormap.

 

W2 contains an RGB image obtain from the "rainbow" shading of the source image.

 

W3 contains an RGB obtained from the orignal RGB values of the source image.

Remarks:

An RGB image consists of three separate components of red, green and blue values. Each RGB value ranges from 0.0 to 1.0.

 

If the input is a scalar, GETRGB assumes the value is a 24 bit RGB value and returns the separate R, G, and B values ranging from 0 to 255.

 

An alpha value of 0 indicates full transparency and a value of 255 indicates full opacity.

 

If imbits is 0, the RGB values of the current shading are returned.

 

If imbits is 1, the original RGB values of the image are returned regardless of the image shading.

 

See RGBIMAGE to create an image from separate RGB values.

 

See COLORTORGB to convert a color index into separate RGB values.

See Also:

COLORTORGB

GETCOLORMAP

IMAGE24

READIMAGE

READBMP

RGBIMAGE