function img_new=ahe(img,grid,limit)
%AHE局部直方图均衡
img_new=img; %img_new is the img after AHE
[m,n]=size(img);
%ECR
grid_cols=grid;
grid_rows=grid;
grid_width=int32(fix(m/grid_cols));
grid_height=int32(fix(n/grid_rows));
map=zeros(grid_cols,grid_rows,256);
%for each grid,we create their mapping function
for i=1:grid_cols
for j=1:grid_rows
map(i,j,:)=MakeHistogram(img,1+(i-1)*grid_width,1+(j-1)*grid_height,grid_width,grid_height,limit);
end
end
%interpolate
%boundary cases I followed the Karel Zuiderveld's implement(C version)
xi = 1;
for i = 1:grid_cols+1
if i == 1
subx = grid_width/2;
xu = 1;
xd = 1;
elseif i == grid_cols+1
subx = grid_width/2;
xu = grid_cols;
xd = grid_cols;
else
subx = grid_width;
xu = i - 1;
xd = i;
end
yi = 1;
for j = 1:grid_rows+1
if j == 1
suby = grid_height/2;
yl = 1;
yr = 1;
elseif j == grid_rows+1
suby = grid_height/2;
yl = grid_rows;
yr = grid_rows;
else
suby = grid_height;
yl = j - 1;
yr = j;
end
UL = map(xu,yl,:);
UR = map(xu,yr,:);
DL = map(xd,yl,:);
DR = map(xd,yr,:);
subimg = img(xi:xi+subx-1,yi:yi+suby-1);
subimg = Interpolate(subimg,UL,UR,DL,DR,subx,suby);
img_new(xi:xi+subx-1,yi:yi+suby-1) = subimg;
yi = yi + suby;
end
xi = xi + subx;
end
end
Matlab科研辅导帮
- 粉丝: 3w+
- 资源: 7814
最新资源
- MATLAB界面版本-疲劳专注度检测系统.zip
- MATLAB界面版本-疲劳检测GUI设计.zip
- MATLAB界面版本-苹果水果分级.zip
- MATLAB界面版本-脐橙水果分级.zip
- MATLAB界面版本-漂浮物识别.zip
- MATLAB界面版本-人脸门禁系统.zip
- MATLAB界面版本-人脸考勤设计.zip
- MATLAB界面版本-人脸购物系统.zip
- MATLAB界面版本-人脸识别.zip
- MATLAB界面版本-手势控制系统.zip
- MATLAB界面版本-人脸识别系统.zip
- MATLAB界面版本-手势识别设计.zip
- MATLAB界面版本-手势识别.zip
- MATLAB界面版本-手势识别系统.zip
- MATLAB界面版本-数字信号处理.zip
- MATLAB界面版本-数字信号处理GUI设计.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈