Theory: The histogram of an image with intensity levels in the range 0 to L-1, where L-1 is the last intensity value in an image(e.g. 255 in gray scale image) is a discrete function h(rk)=nk where rk is the kth intensity value and nk is the number of pixels in the image with intensity rk. It is common practice to normalize a histogram by dividing each of its components by the total number of pixels in the image, denoted by the product MN, where M and N are the row and column dimensions of the image. Thus a normalized histogram is given by p(rk)=nk/M*N, for k=0,1,2…,L-1. P(rk) is nothing but probability of occurrence of intensity level rk in the image. The sum of all components of a normalized histogram is equal to 1. Histogram processing: Global Processing: Histogram Equalization: Image enhancement techniques are used to improve an image, where "improve" is sometimes defined objectively (e.g., increase the signal-to-noise ratio), and sometimes subjectively (e.g., make certain features easier to see by modifying the colors or intensities). Intensity adjustment is an image enhancement technique that maps an image's intensity values to a new range. You can adjust the intensity values in an image using the imadjust function, where you specify the range of intensity values in the output image. this code increases the contrast in a low-contrast grayscale image by remapping the data values to fill the entire intensity range [0,255 in case of grayscale image].
The process of adjusting intensity values can be done automatically by the histeq function. histeq performs histogram equalization, which involves transforming the intensity values so that the histogram of the output image approximately matches a specified histogram. By default, histeq tries to match a flat histogram with 64 bins, but you can specify a different histogram instead. In, general if r is original variable and s