1D and 2D Histograms
• hist2d(M, N, n)—Returns a two-dimensional histogram with n bins on equal-sized matrices M and N.
• imhist(M, n)—Returns an n bin histogram of M for values between 0 and 255 (ignores values outside this range).
• imhist2(M, n)—Returns an n bin histogram of M over its entire range of values, including those outside the 0–255 range.
These functions show the intensity levels in an image, divided into n bins. Histograms show concentrations of gray levels or colors in an image. They can be used to determine the type of image, or to find an appropriate threshold for filtering or equalization. Two-dimensional histograms show the degree of similarity (in intensity or texture) between two images.
Arguments
• M, N are image matrices of the same size.
• n is a positive integer representing the number of bins into which the intensities are partitioned.
Additional Information
• The one-dimensional histogram functions return a vector, n elements long, containing the number of intensity levels in each bin.
• The two-dimensional histogram function returns an n x n matrix, which contains an entry i,j, the number of pixels in corresponding locations which are in bin i in image M and bin j in image N.
A two-dimensional histogram starts by calculating the one-dimensional histogram for each input image. Like the imhist function, hist2d divides the range 0 to 255 into n bins.
• For imhist, the n bins are spaced between intensity levels of 0 and 255, and for imhist2 they are spaced in the actual range of intensities in the matrix.
• hist2d generates a two-dimensional histogram of two images M and N, creating n bins in each dimension. M and N must be the same size. If the two images have similar numbers of pixels at similar intensities, the output matrix from hist2d has a strong diagonal.