Image Types in MATLAB

Image Types

The toolbox supports four types of images:

·Grayscale Image

·Binary Image

·Indexed Image

·RGB Image

The processing operations for most monochrome images are carried out using binary or grayscale images, so we will first focus on these two types of images. The indexed image and RGB color image will be discussed in Chapter 6.

1. Grayscale Image

A grayscale image is a data matrix where the values represent the intensity of gray. When the elements of a grayscale image are of the uint8 or uint16 class, they have integer values ranging from [0,255] or [0,65535], respectively. If the image is of double or single class, the values are floating-point numbers. The values of double or single grayscale images are usually normalized to a range of [0,1], but values from other ranges can also be used.

2. Binary Image

A binary image has a very special meaning in MATLAB. A binary image is a logical array that only takes values of 0 and 1. Therefore, an array that only contains 0 and 1 data types, such as uint8, is not considered a binary image in MATLAB. The logical function can convert a numeric array into a binary image. Thus, if A is a numeric array consisting of 0 and 1, the following statement can be used to create a logical array B:

B = logical (A)

If A contains elements other than 0 and 1, using the logical function will convert all non-zero values to logical 1 and all 0 values to logical 0. Logical arrays can also be obtained using relational and logical operators. You can use the function islogical to test if an array is of logical type:

islogical (c)

If C is a logical array, this function will return 1; otherwise, it will return 0. Using the usual class conversion syntax, a logical array can be converted to a numeric array:

B = class_name (A)

where class_name is im2uint8, im2uint16 in2double im2single or mat2gray. The toolbox function mat2gray can convert an image to an array of double class normalized to the range of [01]. The syntax for calling is:

B = mat2gray(A, [Amin, Amax)]

where the output g has values ranging from 0 (black) to 1 (white). Specific parameters Amin and Amax ensure that values in A less than Amin become 0 in g; while values in A greater than Amax become 1 in g. The syntax is:

g = mat2gray (A)

Setting the values of Amin and Amax to the actual maximum and minimum values in A, the second syntax of mat2gray is a very useful tool because it can normalize the entire input value range to [01] independent of the input class. This eliminates the clipping step.

End

Leave a Comment