Pixel Statistics
Pixel Statistics
Video and Image Processing Blockset contains blocks that can provide
information ab ou t the data values that make up an im age. Blocks f rom the
Statistics library, such as the 2-D Maximum and 2-D Autocorrelation blocks,
can help you determine this information.
This section includes the following topic:
• “Finding the Histogram of an Image” on page 7-59 — Use the 2-D Histogram
block to calculate the histogram of the R, G, and B values in an image
Finding the Histogram of an Image
The 2-D Histogram block computes the frequency distribution of the elements
in each input image by sorting the elements into a specified number of
discrete bins. You can u se the 2-D Histogram block to calculate the histogram
of th e R, G, and/or B va lues in an image. This example shows you how to
accomplish this task:
1 DefineanRGBimageintheMATLABworkspace. ToreadinanRGB
image from a PNG file, at the MATLAB command prompt, type
I= im2double(imread('peppers.png'));
I is a 486-by-732-by-3 array of double-precision floating-point values.
Each plane of the array represents the red, green, or blue color values
of the image.
2 To view the image this matrix represents, at the MATLAB command
prompt, type
imshow(I)
7-59
Comments to this Manuals