-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathadaptivefilt.m
More file actions
59 lines (50 loc) · 1.42 KB
/
adaptivefilt.m
File metadata and controls
59 lines (50 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
%% ADAPTIVEFILT - Perform adaptive filtering.
%
%% Syntax
% F = ADAPTIVEFILT(I, H, M);
%
%% Inputs
% *|I|* : a |(n1,n2)| input image.
%
% *|H|* : array of |m| kernels: it is a |(p1,p2,m)| matrix where each |H(:,:,k)|
% is a filter; |p1| and |p2| should be odd integers; note that during
% filtering, |H(:,:,k)| is automatically normalized to 1.
%
% *|m|* : a |(n1,n2)| matrix of integer in |{1,...,m}|, where |m(i,j)| is the
% index of the kernel to be used in pixel |(i,j)|.
%
%% Output
% *|F|* : a |(n1,n2)| filtered image.
%
%% See also
% Related:
% <CONVOLUTION.html |CONVOLUTION|>,
% <TENSANIFILT.html |TENSANIFILT|>,
% <TENSCALEDIRFILT.html |TENSCALEDIRFILT|>,
% <GEODESICFILT.html |GEODESICFILT|>,
% <MDLFILT.html |MDLFILT|>.
% Called:
% <ADAPTIVEFILT_BASE.html |ADAPTIVEFILT_BASE|>.
%% Function implementation
function F = adaptivefilt(I, H, m)
%%
% check if possible
if ~exist('adaptivefilt_mex','file')
error('adaptivefilt:missinglibrary', ...
'mex file adaptivefilt_mex not found');
end
error(nargchk(1, 3, nargin, 'struct'));
error(nargoutchk(1, 1, nargout, 'struct'));
if ~isnumeric(I)
error('adaptivefilt:inputparameter','a matrix is required in input');
end
%%
% main calculation
F = adaptivefilt_base(I, H, m);
%%
% display
if p.disp
figure, imagesc(rescale(F,0,1)), axis image off;
title('Adaptively filtered image'); if size(F,3)==1, colormap gray; end;
end
end % end of adaptivefilt