本帖最后由 fuyunchao 于 2018-7-25 16:53 编辑
在运行一个FABEMD的程序,出现以下报错,其中se_rep是fabemd的一个子函数。网上也有很多类似的问题,但是程序不一样也看不懂,希望专家或者朋友或者老师们帮忙看看,谢谢
已达到最大递归限制 500。使用 set(0,'RecursionLimit',N) 可更改此限制。请注意,超出可用堆栈空间可能会使 MATLAB 和/或计算机崩溃。
出错 se_rep
运行程序如下:
A=imread('childern.tif');
H=fabemd(A);
出错函数是:
function r = se_rep(SE)
% se_rep - representation type of structuring element
% ---------------------------------------------------
%
% r = se_rep(SE)
%
% Input:
% ------
% SE - structuring element
%
% Output:
% -------
% r - representation type 'mat', 'vec', or ''
%--------------------------------
% Author: Harold Figueroa
%--------------------------------
% $Date: 2006-06-06 17:29:13 -0400 (Tue, 06 Jun 2006) $
% $Revision: 5169 $
%--------------------------------
[m, n] = size(SE);
if (n == 2) && all(round(SE(:)) == SE(:))
r = 'vec';
elseif rem(m, 2) && rem(n, 2) && all((SE(:) ~= 0) == SE(:))
r = 'mat';
else
r = ''; % not a structuring element
if ~nargout
warning('Input is not a structuring element.');
end
end
fabemd函数为:
function Y = fabemd(X, opt)
% fabemd - fast adaptive bidimensional EMD
% ----------------------------------------
%
% Y = fabemd(X, opt)
%
% Input:
% ------
% X - image
% opt - options
%
% Output:
% -------
% Y - BIMF array
% TODO: save intermediate computations, specifically extrema
% NOTE: consider a single coded image for extrema across iterations
%--
% handle input
%--
if nargin < 2
opt.type = 4;
opt.radial = false;
opt.verb = 1;
if ~nargin && nargout
Y = opt; return;
end
end
if ~nargout || opt.verb
figure; imagesc(X), colorbar; colormap(gray(256)); axis('image');
end
for k = 1:3
[L, U] = get_envelopes(X, opt);
Y(:, :, k) = X - 0.5 * (L + U);
X = X - Y(:, :, k);
end
Y(:, :, end + 1) = X;
if ~nargout || opt.verb
for k = 1:size(Y, 3), figure; imagesc(Y(:,:,k)), colorbar; cmap_real(129); axis image; end
end
%-----------------------
% GET_ENVELOPES
%-----------------------
% NOTE: this is essentially a method of the EMD computation
function [L, U, E] = get_envelopes(X, opt)
% get_envelopes - for image
% -------------------------
%
% [L, U, E] = get_envelopes(X, opt)
%
% Input:
% ------
% X - image
% opt - options, coming from parent
%
% Output:
% -------
% L, U - lower and upper envelopes
% E - extrema indicator
%--
% compute image extrema
%--
[E, count] = image_extrema(X); %#ok
% TODO: consider count before we move on
%--
% compute extrema distances and radius of operations given type
%--
[p(:, 1), p(:, 2)] = find(E == 1, 2000);
pd = fast_nearest(p'); pd = pd(:, 1);
[v(:, 1), v(:, 2)] = find(E == -1, 2000);
vd = fast_nearest(v'); vd = vd(:, 1);
switch opt.type
case 1 % min-min
r = min(min(pd), min(vd));
case 2 % max-min
r = max(min(pd), min(vd));
case 3 % min-max
r = min(max(pd), max(vd));
case 4 % max-max
r = max(max(pd), max(vd));
end
r = next_odd(r);
%--
% compute envelopes
%--
% NOTE: we should be able to make use of CUDA acceleration for all steps below
% TODO: improve filtering, improve filter
if opt.radial
SE = se_ball(r); F = SE / se_size(SE);
else
SE = ones(r); F = SE / r^2;
end
% NOTE: 'morph' functions decompose the structuring element, below we decompose the linear filter
L = morph_erode(X, SE); U = morph_dilate(X, SE);
L = box_filter(L, F) / r^2;
U = box_filter(U, F) / r^2;