查看单个帖子
旧 2008-12-17, 11:33   #1
bohr1982
初级会员
 
注册日期: 2008-11-15
年龄: 42
帖子: 6
声望力: 0
bohr1982 正向着好的方向发展
默认 [求助]关于flood_fill算法的疑问

我下了一个flood_fill(种子染色算法)做填充。可是区域大点matlab就跳出来了。好像是堆栈溢出了。咋办呢?

function flood_fill(xc,yc,x,y,new,old,width,height)
% flood fills area of matrix
% (xc,yc) = start point of flood fill
% (x,y) = current test location
% new = new value to be filled
% old = old value to replace

global fill;
global call;

call = call + 1;

if (x<2 || x>=width)
x = xc;
end

if (y<2 || y>=height)
y = yc;
end

if (fill(y,x) == old)
fill(y,x) = new;
flood_fill(xc,yc,x+1,y,new,old,width,height);
flood_fill(xc,yc,x,y+1,new,old,width,height);
flood_fill(xc,yc,x-1,y,new,old,width,height);
flood_fill(xc,yc,x,y-1,new,old,width,height);
end


:ft:
bohr1982 当前离线   回复时引用此帖