**Digital Image Representation**

1. An image is a two dimensional function, f(x,y), where x and y are spatial

coordinates.

2. Amplitude of f at any pair of coordinates (x,y) is called intensity or gray

level of the image at that point.

3. The intensity of monochrome images is referred to as gray level.

4. Individual 2D images are combined to form the color images.

5. For example, in RGB color system, three individual component images

are constituted to form a color image.

6. Due to this, many of the techniques developed for monochrome images

can be extended to color images by processing the three component

images individually.

7. An image may be continuous with respect to the x- and y- coordinates,

and also in amplitude.

8. So converting such an image to digital form requires that the

coordinates, as well as the amplitude, be digitized.

9. Digitizing the coordinate values is called sampling; digitizing the

amplitude values is called quantization.

10. Thus, when x, y, and f are all finite, discrete quantities, the image is said

to be a digital image.

**Reading Images**

1. Images can be read by using imread function.

2. Syntax to read the image from current directory is:

imread (‘filename’)

3. If the file that has to be read is stored in a specified directory then

include a full or relative path to that directory in filename.

Reading Images

4. The row and column dimensions of an image are given by using size

function.

5. The additional information about an array is displayed by using whos

function.

**Displaying Images**

1. imshow function is used to display the images on the MATLAB desktop.

2. Syntax:

imshow (f)

3. Function pixval is used to display the intensity values of the individual

pixels interactively.

**Writing Images**

1. imwrite function is used to write the image to the disk.

2. Syntax:

imwrite (f, ‘filename’)

3. A more general syntax for JPEG image is:

imwrite (f, ‘filename.jpg’, ‘quality’, q)

4. imfinfo function is used to get an idea of image compression achieved

and to obtain other details of an image.

5. Syntax:

imfinfo filename

6. A more general syntax for tif image is:

imwrite (g, ‘filename.tif’, ‘compression’, ‘parameter’, …

‘resolution’, [colres rowres])

7. The contents of figure window can be exported to the disk in two ways.

a. Use the File pull down menu in the figure window and then

choose Export and then select a location, filename, and format.

b. Use the print command, as:

print -fno -dfileformat -rresno filename

**Image Formats Supported by imread & imwrite**

**Data Classes**

**Image Types**

1. Intensity images

a. It is a data matrix whose values have been scaled to represent

intensities.

2. Binary images

a. It is a logical array of 0s and 1s.

b. If A is a numeric array, logical array B can be created as

B = logical (A)

c. islogical function is used to test if an array is logical:

islogical (C)

3. Indexed images

a. It has two components: a data matrix of integers, X, and a

colormap matrix, map.

b. It is displayed as:

imshow (X, map)

c. Indexed image can also be displayed as:

image (X)

colormap (map)

4. RGB images

a. An RGB color image is an M N 3 array of color pixels.

b. Each pixel is a triplet corresponding to the red, green, and blue

components of an RGB image at a specific spatial location.

**Converting between Data Classes**

1. The general syntax is:

B = data_class_name (A)

where, data_class_name is one of the names of the data types.

**Converting between Image Classes and Types**

**Array Indexing**

1. Vector Indexing

a. An array of dimension 1 N is called a row vector.

b. The elements of such a vector are accessed using

one-dimensional indexing.

c. The elements of a vector are enclosed by square brackets and

are separated by spaces or by commas.

d. A row vector is converted to column vector by using transpose

operator (.’).

e. The colon notation is used to access blocks of elements.

f. Function linspace generates a row vector, x, of elements, n,

linearly spaced between and including elements, a and b, whose

syntax is

x = linspace (a,b,n)

g. A vector can be used as index into another vector.

2. Matrix Indexing

a. Matrices can be represented as a sequence of row vectors

enclosed by square brackets and separated by semicolons.

b. Elements can be selected in matrices just as in vectors, but two

indices can be needed: one to establish row location and the

other for the corresponding column.

c. The colon notation is used in matrix indexing to select a

two-dimensional block of elements out of a matrix.

3. Selecting array dimensions

a. Operations of the form

operation (A,dim)

where operation denotes an applicable operation, A is an array, and

dim is a scalar.

b. Function ndims gives the number of dimensions of an array,

syntax:

d = ndims (A)

**Some Important Standard Arrays**

1. zeros(M,N) generates an M N matrix of 0s of class double.

2. ones(M,N) generates an M N matrix of 1s of class double.

3. true(M,N) generates an M N logical matrix of 1s.

4. false (M,N) generates an M N logical matrix of 0s.

5. magic(M) generates an M M “magic square”.

6. rand(M,N) generates an M N matrix whose entries are uniformly

distributed random numbers in interval [0,1].

7. randm(M,N) generates an M N matrix whose numbers are normally

distributed random numbers with mean 0 and variance 1.