How to start with MATLAB? Basic Introduction
May 13, 2017
Artificial Intelligence Shaping Future of Energy
September 4, 2017

Image Processing In MATLAB

The Image Processing Toolbox is a collection of functions that extend the capability of the MATLAB ® numeric computing environment. The toolbox supports a wide range of image processing operations, including:

  • Geometric operations,
  • Neighborhood and block operations,
  • Linear filtering and filter design ,
  • Transforms Image analysis and enhancement
  • Binary image operations
  • Region of interest operations.

Many of the toolbox functions are MATLAB M ­files, series of MATLAB statements that implement specialized image processing algorithms. You can view the MATLAB code for these functions using the statement:

type function_ name

You can extend the capabilities of the Image Processing Toolbox by writing your own M­files, or by using the toolbox in combination with with other toolboxes, such as the Signal Processing Toolbox and the Wavelet Toolbox.

The basic data structure in MATLAB is the array, an ordered set of real or complex elements. This object is naturally suited to the representation of images, real­valued, ordered sets of color or intensity data. (MATLAB does not support complex­valued images.)

MATLAB stores most images as two-dimensional arrays (i.e., matrices), in which each element of the matrix corresponds to a single pixel in the displayed image. (Pixel is derived from picture element and usually denotes a single dot on a computer display.) For example, an image composed of 200 rows and 300 columns of different colored dots would be stored in MATLAB as a 200­by­300 matrix.

This convention makes working with images in MATLAB similar to working with any other type of matrix data, and makes the full power of MATLAB available for image processing applications. For example, you can select a single pixel from an image matrix using normal matrix subscripting:

I (2,15)

This command returns the value of the pixel at row 2, column 15 of the image I.

The Image Processing Toolbox supports four basic types of images:

  • Indexed images
  • Intensity images
  • Binary images
  • RGB images

This section discusses how MATLAB and the Image Processing Toolbox represent each of these image types.

Indexed Images

An indexed image consists of two arrays, an image matrix and a colormap. The colormap is an ordered set of values that represent the colors in the image. For each image pixel, the image matrix contains a value that is an index into the colormap. The colormap is an m­by­3 matrix of class double. Each row of the colormap matrix specifies the red, green, and blue (RGB) values for a single color:

color = [R G B]

R, G, and B are real scalars that range from 0 (black) to 1.0 (full intensity). The figure below illustrates the structure of an indexed image.


The pixels in the image are represented by integers, which are pointers (indices) to color values stored in the colormap. The relationship between the values in the image matrix and the colormap depends on whether the image matrix is of class double or uint8. If the image matrix is of class double, the value 1 points to the first row in the colormap, the value 2 points to the second row, and so on. If the image matrix is of class uint8, there is an offset; the value 0 points to the first row in the colormap, the value 1 points to the second row, and so on. The uint8 convention is also used in graphics file formats, and enables 8­bit indexed images to support up to 256 colors. In the image above, the image matrix is of class double, so there is no offset. For example, the value 5 points to the fifth row of the colormap.

Intensity Images

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, in which case it contains values in the range [0,1], or of class uint8, in which case the data range is [0,255]. The elements in the intensity matrix represent various intensities, or gray levels, where the intensity 0 represents black and the intensity 1 (or 255) represents full intensity, or white. This figure depicts an intensity image of class double.


Binary Images

In a binary image, each pixel assumes one of only two discrete values. Essentially, these two values correspond to on and off. A binary image is stored as a two ­dimensional matrix of 0’s (off pixels) and 1’s (on pixels). A binary image can be considered a special kind of intensity image, containing only black and white. Other interpretations are possible, however; you can also think of a binary image as an indexed image with only two colors. A binary image can be stored in an array of class double or uint8. However, a uint8 array is preferable, because it uses far less memory. In the Image Processing Toolbox, any function that returns a binary image returns it as a uint8 logical array. The toolbox uses the presence of the logical flag to signify that the data range is [0,1]. (If the logical flag is off, the toolbox assumes the data range is [0,255].) This figure shows an example of a binary image.


RGB Images

Like an indexed image, an RGB image represents each pixel color as a set of three values, representing the red, green, and blue intensities that make up the color. Unlike an indexed image, however, these intensity values are stored directly in the image array, not indirectly in a colormap.

In MATLAB, the red, green, and blue components of an RGB image reside in a single m­by­n­by­3 array. m and n are the numbers of rows and columns of pixels in the image, and the third dimension consists of three planes, containing red, green, and blue intensity values. For each pixel in the image, the red, green, and blue elements combine to create the pixel’s actual color. For example, to determine the color of the pixel (112,86), look at the RGB triplet stored in (112,86,1:3). Suppose (112,86,1) contains the value 0.1238, (112,86,2) contains 0.9874, and (112,86,3) contains 0.2543. The color for the pixel at (112,86) is: 0.1238 0.9874 0.2543

An RGB array can be of class double, in which case it contains values in the range [0,1], or of class uint8, in which case the data range is [0,255]. The figure below shows an RGB image of class double:


Contact our top Designers to get MATLAB Assignment Help and MATLAB Simulink Assignment Help

Leave a Reply

Your email address will not be published. Required fields are marked *