function Y = vanherk(X,N,TYPE,varargin)
% VANHERK Fast max/min 1D filter
%
% Y = VANHERK(X,N,TYPE) performs the 1D max/min filtering of the row
% vector X using a N-length filter.
% The filtering type is defined by TYPE = 'max' or 'min'. This function
% uses the van Herk algorithm for min/max filters that demands only 3
% min/max calculations per element, independently of the filter size.
%
% If X is a 2D matrix, each row will be filtered separately.
%
% Y = VANHERK(...,'col') performs the filtering on the columns of X.
%
% Y = VANHERK(...,'shape') returns the subset of the filtering specified
% by 'shape' :
% 'full' - Returns the full filtering result,
% 'same' - (default) Returns the central filter area that is the
% same size as X,
% 'valid' - Returns only the area where no filter elements are outside
% the image.
%
% X can be uint8 or double. If X is uint8 the processing is quite faster, so
% dont't use X as double, unless it is really necessary.
%
% Initialization
[direc, shape] = parse_inputs(varargin{:});
if strcmp(direc,'col')
X = X';
end
if strcmp(TYPE,'max')
maxfilt = 1;
elseif strcmp(TYPE,'min')
maxfilt = 0;
else
error([ 'TYPE must be ' char(39) 'max' char(39) ' or ' char(39) 'min' char(39) '.'])
end
% Correcting X size
fixsize = 0;
addel = 0;
if mod(size(X,2),N) ~= 0
fixsize = 1;
addel = N-mod(size(X,2),N);
if maxfilt
f = [ X zeros(size(X,1), addel) ];
else
f = [X repmat(X(:,end),1,addel)];
end
else
f = X;
end
lf = size(f,2);
lx = size(X,2);
clear X
% Declaring aux. mat.
g = f;
h = g;
% Filling g & h (aux. mat.)
ig = 1:N:size(f,2);
ih = ig + N - 1;
g(:,ig) = f(:,ig);
h(:,ih) = f(:,ih);
if maxfilt
for i = 2 : N
igold = ig;
ihold = ih;
ig = ig + 1;
ih = ih - 1;
g(:,ig) = max(f(:,ig),g(:,igold));
h(:,ih) = max(f(:,ih),h(:,ihold));
end
else
for i = 2 : N
igold = ig;
ihold = ih;
ig = ig + 1;
ih = ih - 1;
g(:,ig) = min(f(:,ig),g(:,igold));
h(:,ih) = min(f(:,ih),h(:,ihold));
end
end
clear f
% Comparing g & h
if strcmp(shape,'full')
ig = [ N : 1 : lf ];
ih = [ 1 : 1 : lf-N+1 ];
if fixsize
if maxfilt
Y = [ g(:,1:N-1) max(g(:,ig), h(:,ih)) h(:,end-N+2:end-addel) ];
else
Y = [ g(:,1:N-1) min(g(:,ig), h(:,ih)) h(:,end-N+2:end-addel) ];
end
else
if maxfilt
Y = [ g(:,1:N-1) max(g(:,ig), h(:,ih)) h(:,end-N+2:end) ];
else
Y = [ g(:,1:N-1) min(g(:,ig), h(:,ih)) h(:,end-N+2:end) ];
end
end
elseif strcmp(shape,'same')
if fixsize
if addel > (N-1)/2
disp('hoi')
ig = [ N : 1 : lf - addel + floor((N-1)/2) ];
ih = [ 1 : 1 : lf-N+1 - addel + floor((N-1)/2)];
if maxfilt
Y = [ g(:,1+ceil((N-1)/2):N-1) max(g(:,ig), h(:,ih)) ];
else
Y = [ g(:,1+ceil((N-1)/2):N-1) min(g(:,ig), h(:,ih)) ];
end
else
ig = [ N : 1 : lf ];
ih = [ 1 : 1 : lf-N+1 ];
if maxfilt
Y = [ g(:,1+ceil((N-1)/2):N-1) max(g(:,ig), h(:,ih)) h(:,lf-N+2:lf-N+1+floor((N-1)/2)-addel) ];
else
Y = [ g(:,1+ceil((N-1)/2):N-1) min(g(:,ig), h(:,ih)) h(:,lf-N+2:lf-N+1+floor((N-1)/2)-addel) ];
end
end
else % not fixsize (addel=0, lf=lx)
ig = [ N : 1 : lx ];
ih = [ 1 : 1 : lx-N+1 ];
if maxfilt
Y = [ g(:,N-ceil((N-1)/2):N-1) max( g(:,ig), h(:,ih) ) h(:,lx-N+2:lx-N+1+floor((N-1)/2)) ];
else
Y = [ g(:,N-ceil((N-1)/2):N-1) min( g(:,ig), h(:,ih) ) h(:,lx-N+2:lx-N+1+floor((N-1)/2)) ];
end
end
elseif strcmp(shape,'valid')
ig = [ N : 1 : lx];
ih = [ 1 : 1: lx-N+1];
if maxfilt
Y = [ max( g(:,ig), h(:,ih) ) ];
else
Y = [ min( g(:,ig), h(:,ih) ) ];
end
end
if strcmp(direc,'col')
Y = Y';
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [direc, shape] = parse_inputs(varargin)
direc = 'lin';
shape = 'same';
flag = [0 0]; % [dir shape]
for i = 1 : nargin
t = varargin{i};
if strcmp(t,'col') & flag(1) == 0
direc = 'col';
flag(1) = 1;
elseif strcmp(t,'full') & flag(2) == 0
shape = 'full';
flag(2) = 1;
elseif strcmp(t,'same') & flag(2) == 0
shape = 'same';
flag(2) = 1;
elseif strcmp(t,'valid') & flag(2) == 0
shape = 'valid';
flag(2) = 1;
else
error(['Too many / Unkown parameter : ' t ])
end
end
没有合适的资源?快使用搜索试试~ 我知道了~
暗通道先验和CLAHE算法
共68个文件
jpg:41个
m:26个
asv:1个
需积分: 50 26 下载量 99 浏览量
2019-05-16
16:21:20
上传
评论 3
收藏 4.31MB ZIP 举报
温馨提示
基于暗通道先验的去雾算法:2009CVPR+导向滤波+容差控制 基于CLAHE限制自适应直方图去雾算法
资源推荐
资源详情
资源评论
收起资源包目录
1a zj.zip (68个子文件)
1a zj
image
2.jpg 91KB
1.jpg 12KB
3.jpg 64KB
4.jpg 66KB
2 Dark_Channel_He
2.jpg 91KB
1.jpg 12KB
3.jpg 64KB
boxfilter.m 931B
ex_darkchannel_guildfilter.m 2KB
vanherk.m 5KB
4.jpg 66KB
guidedfilter.m 1KB
minfilt2.m 2KB
add foggy
2.jpg 737KB
1.jpg 1.18MB
2222.jpg 13KB
2222222222.jpg 11KB
3.jpg 986KB
11.jpg 11KB
10.jpg 12KB
30.jpg 12KB
AddFog.m 2KB
31.jpg 10KB
2 Dark_Channel_He - 副本
2.jpg 66KB
1.jpg 64KB
boxfilter.m 931B
ex_darkchannel_guildfilter.m 2KB
vanherk.m 5KB
maxfilt2.m 2KB
guidedfilter.m 1KB
guidedfilter_color.m 2KB
ex_darkchannel_guildfilter.asv 2KB
minfilt2.m 2KB
1 CLAHE
2.jpg 91KB
My_clip_histogram.m 2KB
1.jpg 12KB
My_adapthisteq.m 4KB
My_map_histogram.m 759B
3.jpg 64KB
Run_me.m 692B
4.jpg 66KB
3 test
2-4.jpg 46KB
test.m 700B
my_gradient.m 308B
4-4.jpg 39KB
2.jpg 32KB
1.jpg 12KB
2-7.jpg 43KB
3.jpg 27KB
4-6.jpg 32KB
4-7.jpg 44KB
1-4.jpg 16KB
1-7.jpg 16KB
4.jpg 27KB
3-6.jpg 33KB
2-6.jpg 39KB
1-6.jpg 15KB
3-4.jpg 35KB
3-7.jpg 43KB
my_ssim.m 2KB
4 Dark_Channel_My
My_darkchannel.m 681B
My_estimateA.m 1KB
2.jpg 91KB
1.jpg 41KB
My_cumulative_sum.m 1KB
Run_me.m 2KB
My_guidedfilter.m 1KB
My_minfilter.m 973B
共 68 条
- 1
资源评论
枫桥夜泊_knit
- 粉丝: 167
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 徐州市区shp边界文件
- 简易数字频率计设计(原理图、PCB、源码、分析报告)
- 20225207038罗丽文财管专2201班.rar
- Golang:通过Gin框架+Redis+责任链,实现一个简单的钉钉机器人,进行消息处理 ps:多应用版
- 基于cnn和AlexNet的铝材缺陷检测内含数据集和demo原型2种方法
- 2023年各城市PM2.5, PM10, SO2, NO2等环境空气质量数据
- go 语言 实现的 使用modbus 协议 通过DTU tcp 链接 采集数据
- SHELL脚本(全是干货)
- Windows屏幕录屏软件
- 2022年各城市PM2.5, PM10, SO2, NO2等环境空气质量数据
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功