3.3 Local Histogram Equalization
The global histogram equalization technique is easily adaptable to local histogram equalization. The
procedure is to define a square or rectangular window (neighborhood) and move the center of the window
from pixel to pixel. At each location, the histogram of the points inside the window is computed and a
histogram equalization transformation function is obtained. This function is finally used to map the intensity
level of the pixel centered in the neighborhood to create a corresponding (processed) pixel in the output
image. The center of the neighborhood region is then moved to an adjacent pixel location and the procedure
is repeated. Since only one new row or column of the neighborhood changes during a pixel-to-pixel
translation of the region, updating the histogram obtained in the previous location with the new data
introduced at each motion step is possible. This approach has obvious advantages over repeatedly
computing the histogram over all pixels in the neighborhood region each time the region is moved one pixel
location.
Write an M-function for performing local histogram equalization. Your function should have the following
specifications.
function g = localhisteq(f, m, n)
% LOCALHISTEQ Local histogram equalization.
% G = LOCALHISTEQ(F, M, N) performs local histogram equalization
on input image F using a window of (odd) size M-by-N to produce
the processed image, G. To handle border effects, image F is
extended by using the symmetric option in function padarray.
The amount of extension is determined by the dimensions of the
local window. If M and N are omitted, they default to
3. If N is omitted, it defaults to M. Both must be odd.
This function accepts input images of class uint8, uint16, or
double. However, all computations are done using 8-bit intensity
values to speed-up computations. If F is of class double its
values should be in the range [0 1]. The class of the output
image is the same as the class of the input.