filter源码设计_编写filter

hacker|
150

文章目录:

求MATLAB中filter2函数的源代码。

若需要函数体,我可以传文件给你。下面是其代码function y = filter2(b,x,shape)

%FILTER2 Two-dimensional digital filter.

% Y = FILTER2(B,X) filters the data in X with the 2-D FIR

% filter in the matrix B. The result, Y, is computed

% using 2-D correlation and is the same size as X.

%

% Y = FILTER2(B,X,'shape') returns Y computed via 2-D

% correlation with size specified by 'shape':

% 'same' - (default) returns the central part of the

% correlation that is the same size as X.

% 'valid' - returns only those parts of the correlation

% that are computed without the zero-padded

% edges, size(Y) size(X).

% 'full' - returns the full 2-D correlation,

% size(Y) size(X).

%

% FILTER2 uses CONV2 to do most of the work. 2-D correlation

% is related to 2-D convolution by a 180 degree rotation of the

% filter matrix.

%

% Class support for inputs B,X:

% float: double, single

%

% See also FILTER, CONV2.% Copyright 1984-2004 The MathWorks, Inc.

% $Revision: 5.13.4.2 $ $Date: 2004/03/09 16:16:19 $error(nargchk(2,3,nargin));

if nargin3, shape = 'same'; endif (~isa(b,'float')), b = double(b); end

if (~isa(x,'float')), x = double(x); endcode = [shape,' ']; code = code(1);

if isempty(find(code=='svf'))

error('MATLAB:filter2:InvalidParam', 'Unknown shape parameter.');

end[mx,nx] = size(x);

stencil = rot90(b,2);

[ms,ns] = size(stencil);% 1-D stencil?

if (ms == 1)

y = conv2(1,stencil,x,shape);

elseif (ns == 1)

y = conv2(stencil,1,x,shape);

else

if (ms*ns mx*nx)

% The filter is bigger than the input. This is a nontypical

% case, and it may be counterproductive to check the

% separability of the stencil.

y = conv2(x,stencil,shape);

else

separable = false;

if all(isfinite(stencil(:)))

% Check rank (separability) of stencil

[u,s,v] = svd(stencil);

s = diag(s);

tol = length(stencil) * eps(max(s));

rank = sum(s tol);

separable = (rank ==1);

end

if separable

% Separable stencil

hcol = u(:,1) * sqrt(s(1));

hrow = conj(v(:,1)) * sqrt(s(1));

if (all(all((round(stencil) == stencil))) all(all((round(x) == x))))

% Output should be integer

y = round(conv2(hcol, hrow, x, shape));

else

y = conv2(hcol, hrow, x, shape);

end

else

% Nonseparable stencil

y = conv2(x,stencil,shape);

end

end

end

javax.servlet.Filter 中操作 javax.servlet.http.HttpServletRequest

doFilter(javax.servlet.ServletRequest arg0, javax.servlet.ServletResponse arg1, javax.servlet.FilterChain arg2) throws java.io.IOException, javax.servlet.ServletException;

这是Filter的源码。本身就有javax.servlet.ServletRequest 你将这个强转一下就获取到HttpServletRequest了。获取请求。request.getRequestURL() ,然后你判断一个这个是否是endwith("html"); 直接让FilterChain 跳转到jsp上就行了啊。

股票源码公式中的FILTER函数是未来函数吗?会有漂移吗?为什么加入后准确率大大提高?

filter不是未来函数,是在上一个信号出现后,在多长时间不再提示

比如kdj的金叉,如果今天金叉,用filter过滤5天,那5天内再出现金叉就不提示了。所以filter很安全

jQuery源码分析之实例find和filter方法的区别七问

filter()过滤DOM元素包装集,是指操作当前元素集,删除不匹配的元素,得到一个新的集合

$('div').filter('.div1');//选择div标签中class属性为div1的div元素

find()在当前选中元素的上下文中找到符合条件的后代,返回的是子元素

$('div').find('em');//选择div标签中的em标签的元素

filter()是对选中的元素集合操作,得到这些元素中符合条件的元素,而find()是得到选中元素 中符合条件的后代子元素。

1条大神的评论

  • avatar
    访客 2022-09-19 下午 12:06:48

    without the zero-padded% edges, size(Y) size(X).% 'full' - returns the full 2-D correlation, %

发表评论