function varargout = histmatch(image,matchhist,mapl)
% HISTMATCH 直方图规定化函数
% matchhist为规定直方图,规定图像的灰度级N<=M
% 没有该参数输入,默认为执行直翻图均衡化
% mapl只有有matchhist参数时才具有意义,为映射规则
% 可以取值为SML和GML,默认为SML
% 无输出默认输出原始图像、原始直方图、规定图像、规定图像直方图
% $Author: lskyp $Data: 2009.08.18
error(nargchk(1,3,nargin));
% 没有规定直方图输入,即输入参数只有一个,执行直方图均衡化
if nargin == 1
if nargout == 0
histeq_my(image);
else
[imageeq,grayx,histeq,hist] = histeq_my(image);
varargout = {imageeq,grayx,histeq,hist};
end
else
if nargin == 2
mapl = 'GML';
end
if ~ (strcmp(mapl,'GML') || strcmp(mapl,'SML'))
error('错误的映射规则')
end
if ndims(matchhist) > 2 |