Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
pmi432 / LR07 / 2read / image processing toolbox guide.pdf
Скачиваний:
166
Добавлен:
18.03.2015
Размер:
18.08 Mб
Скачать

Getting Information about Image Pixel Values and Image Statistics

Plot of Intensity Values Along a Line Segment in an RGB Image

Displaying a Contour Plot of Image Data

You can use the toolbox function imcontour to display a contour plot of the data in a grayscale image. A contour is a path in an image along which the image intensity values are equal to a constant. This function is similar to the contour function in MATLAB, but it automatically sets up the axes so their orientation and aspect ratio match the image.

This example displays a grayscale image of grains of rice and a contour plot of the image data:

11-7

11 Analyzing and Enhancing Images

1Read a grayscale image and display it.

I = imread('rice.png'); imshow(I)

2Display a contour plot of the grayscale image. figure, imcontour(I,3)

You can use the clabel function to label the levels of the contours. See the description of clabel in the MATLAB Function Reference for details.

11-8

Getting Information about Image Pixel Values and Image Statistics

Creating an Image Histogram Using imhist

An image histogram is a chart that shows the distribution of intensities in an indexed or grayscale image. You can use the information in a histogram to choose an appropriate enhancement operation. For example, if an image histogram shows that the range of intensity values is small, you can use an intensity adjustment function to spread the values across a wider range.

To create an image histogram, use the imhist function. This function creates a histogram plot by making n equally spaced bins, each representing a range of data values. It then calculates the number of pixels within each range.

The following example displays an image of grains of rice and a histogram based on 64 bins. The histogram shows a peak at around 100, corresponding to the dark gray background in the image. For information about how to modify an image by changing the distribution of its histogram, see “Adjusting Intensity Values to a Specified Range” on page 11-38.

1Read image and display it.

I = imread('rice.png'); imshow(I)

2Display histogram of image. figure, imhist(I)

11-9

11 Analyzing and Enhancing Images

Getting Summary Statistics About an Image

You can compute standard statistics of an image using the mean2, std2, and corr2 functions. mean2 and std2 compute the mean and standard deviation of the elements of a matrix. corr2 computes the correlation coefficient between two matrices of the same size.

These functions are two-dimensional versions of the mean, std, and corrcoef functions described in the MATLAB Function Reference.

Computing Properties for Image Regions

You can use the regionprops function to compute properties for image regions. For example, regionprops can measure such properties as the area, center of mass, and bounding box for a region you specify. See the reference page for regionprops for more information.

11-10

Соседние файлы в папке 2read