function out = myCLAHE(I)
%ADAPTHISTEQ Contrast-limited Adaptive Histogram Equalization (CLAHE).
% ADAPTHISTEQ enhances the contrast of images by transforming the
% values in the intensity image I. Unlike HISTEQ, it operates on small
% data regions (tiles), rather than the entire image. Each tile's
% contrast is enhanced, so that the histogram of the output region
% approximately matches the specified histogram. The neighboring tiles
% are then combined using bilinear interpolation in order to eliminate
% artificially induced boundaries. The contrast, especially
% in homogeneous areas, can be limited in order to avoid amplifying the
% noise which might be present in the image.
%--------------------------- The algorithm ----------------------------------
%
% 1. Obtain all the inputs:
% * image
% * number of regions in row and column directions
% * number of bins for the histograms used in building image transform
% function (dynamic range)
% * clip limit for contrast limiting (normalized from 0 to 1)
% * other miscellaneous options
% 2. Pre-process the inputs:
% * determine real clip limit from the normalized value
% * if necessary, pad the image before splitting it into regions
% 3. Process each contextual region (tile) thus producing gray level mappings
% * extract a single image region
% * make a histogram for this region using the specified number of bins
% * clip the histogram using clip limit
% * create a mapping (transformation function) for this region
% 4. Interpolate gray level mappings in order to assemble final CLAHE image
% * extract cluster of four neighboring mapping functions
% * process image region partly overlapping each of the mapping tiles
% * extract a single pixel, apply four mappings to that pixel, and
% interpolate between the results to obtain the output pixel; repeat
% over the entire image
%
% See code for further details.
%
%-----------------------------------------------------------------------------
dimI = size(I);% 图像大小
% 'NumTiles' Two-element vector
图像处理---CLAHE(限制对比度自适应直方图均衡)算法MATLAB代码
于 2020-12-06 17:08:23 首次发布