You are on page 1of 6

- 1 -Seagate Crystal Reports SUBJECT

Page 1 4/15/200911111 TITLE

Digital Image & Speech Processing

Introduction to Image processing using MATLAB


DOC.CODE: AITS/ECD/EXPT/ REV. NO. : 2.00/2009

EXPERIMENT NO.1

DATE :

Digital Image An image can be defined as a two-dimensional function, f(x,y), where x and y are spatial coordinates, and the amplitude of f at any pair of coordinates (x,y) is called the intensity or gray level of the image at that point. When x,y and the amplitude values of f are all finite, discrete quantities, the image is called a digital image. A digital image represents the subject using a finite set of numerical values called picture elements or pixels. A pixel is basically a small dot of color that in combination with other pixels forms a digital image. An image is digitized to convert it to a form that can be stored to a computer or a memory storage device that can analyze and display them. The number of pixels being used to represent an image determines the resolution or the amount of detail in an image. Images can be represented in various formats such as black and white, grayscale or color. To do so, each pixel of an image is assigned a number or a set of numbers that represents its color. Images as Matrices
In MATLAB, most images are stored as two-dimensional matrices, in which each element of the matrix corresponds to a single pixel in the image. In the general case we say that an image is

of size m-by-n if it is composed of m pixels in the vertical direction and n pixels in the horizontal direction.

However, unlike the coordinate convention, the matrix coordinates in MATLAB originate at (r,c) = (1,1). Furthermore, some images, such as true color RGB images, require a three-dimensional matrix, ie, intensity values of red, green and blue at each pixel.

Atmiya Institute of Technology & Science, Rajkot

- 2 -Seagate Crystal Reports SUBJECT

Page 2 4/15/200911112 TITLE

Digital Image & Speech Processing

Introduction to Image processing using MATLAB


DOC.CODE: AITS/ECD/EXPT/ REV. NO. : 2.00/2009

EXPERIMENT NO.1

DATE :

Image formats supported by MATLAB The following image formats are supported by MATLAB TIFF PNG HDF BMP JPEG GIF PCX XWD CUR I Tagged Image File Format Portable Network Graphics Hierarchical Data Format Windows Bitmap Joint Photographic Experts Group Graphics Interchange Format Pacific Exchange X window Dump Cursor image Icon image

Image data classes in MATLAB The values of pixels of an image represented in MATLAB can be from various data classes mentioned below. uint8 uint16 uint32 int8 int16 int32 0 to 255 0 to 65,535 0 to 4,294,967,295 -128 to 127 -32,768 to 32,767 -2,147,483,648 to 2,147,483,647 -1038 to 1038 -10308 to 10308 Unsigned 8-bit integer Unsigned 16-bit integer Unsigned 32-bit integer Signed 8-bit integer Signed 16-bit integer Signed 32-bit integer 1 Byte 2 Byte 4 Byte 1 Byte 2 Byte 4 Byte

Single Double

Single precision floating point number Double precision floating point number

4 Byte 8 Byte

logical

0 or 1

1 Byte

Atmiya Institute of Technology & Science, Rajkot

- 3 -Seagate Crystal Reports SUBJECT

Page 3 4/15/200911113 TITLE

Digital Image & Speech Processing

Introduction to Image processing using MATLAB


DOC.CODE: AITS/ECD/EXPT/ REV. NO. : 2.00/2009

EXPERIMENT NO.1

DATE :

All the numeric computations in MATLAB are done using double quantities. Image can be processed being expressed in given data class or it may be required to change their data class. In built functions are available in MATLAB for converting between data class. Image Types in MATLAB MATLAB supports four types of images 1. Binary Images In MATLAB, a binary image is of class logical. Binary images contain only 0's and 1's. Pixels with the value 0 are displayed as black; pixels with the value 1 are displayed as white.

2. Intensity Images (Gray scale image) An intensity image is a data matrix, whose values represent intensities within some range. MATLAB stores an intensity image as a single matrix, with each element of the matrix corresponding to one image pixel. The matrix can be of class double (scaled values in the range [0,1]), uint8 (values in the range [0,255]), or uint16 (values in the range [0,65535]).

Atmiya Institute of Technology & Science, Rajkot

- 4 -Seagate Crystal Reports SUBJECT

Page 4 4/15/200911114 TITLE

Digital Image & Speech Processing

Introduction to Image processing using MATLAB


DOC.CODE: AITS/ECD/EXPT/ REV. NO. : 2.00/2009

EXPERIMENT NO.1

DATE :

3. RGB images The color of each pixel is generated using a combination of red, green and blue with varying intensities. Images are stored as an m-by-n-by-3 array, where m is the number of rows and n is the number of columns. This is a 3-dimensional array with each dimension representing the values of each of the primary colors being used to generate the color of that particular pixel.

4. Indexed images This is a way of representing color images. An indexed image stores an image as two matrices. The first matrix has the same size as the image and one number for each pixel. The second matrix is called the color map. The colormap matrix is an m-by-3 array of class double containing floatingpoint values in the range [0,1]. Each row of map specifies the red, green, and blue components of a single color. The numbers in the first matrix is an index of what number to use in the color map matrix.

Atmiya Institute of Technology & Science, Rajkot

- 5 -Seagate Crystal Reports SUBJECT

Page 5 4/15/200911115 TITLE

Digital Image & Speech Processing

Introduction to Image processing using MATLAB


DOC.CODE: AITS/ECD/EXPT/ REV. NO. : 2.00/2009

EXPERIMENT NO.1

DATE :

Image processing Toolbox Basics 1. Reading Images Images are normally in from of files (eg. .jpg), for processing it they have to be read into the MATLAB environment. This can be done using function
imread(filename)

If the file is present in the current directory no path information is required, otherwise full path information as to be specified instead of just the file name. 2. Displaying Images Images can be displayed using function
imshow(f)

where, f is an image array. 3. Writing Images The processed image can be converted back to the file using the function
imwrite(f,filename)

where, f is an image array and the image will be saved with name as string contained in filename. File name should have recognized file format extension. 4. Information about image For getting information about the image file following function can be used
imfinfo(filename)

This gives various information about file like file size, format, dimensions, color type etc.
5.

Image format conversion

Atmiya Institute of Technology & Science, Rajkot

- 6 -Seagate Crystal Reports SUBJECT

Page 6 4/15/200911116 TITLE

Digital Image & Speech Processing

Introduction to Image processing using MATLAB


DOC.CODE: AITS/ECD/EXPT/ REV. NO. : 2.00/2009

EXPERIMENT NO.1

DATE :

6. Converting images in different data class


I=im2double(I);

converts an image named I from uint8 to double.


I=im2uint8(I);

converts an image named I from double to uint8.

Atmiya Institute of Technology & Science, Rajkot

You might also like