资源简介
matlab开发-floodfillscanline。在matlab中使用洪泛填充或绘制桶工具,如imfill、scanline算法和动画。

代码片段和文件信息
function ms=flood_fill(Irtol)
% flood fill scan line algoritm
% ms=flood_fill(Irtol)
% ms - pixels numbers that flooded
% numbering: number=y+szy*(x-1) x y - pixels coordinaties
% szx szy - image size
% I - RGB image
% r- first point of selection
% tol - tolerance
R=int32(I(::1));
G=int32(I(::2));
B=int32(I(::3));
[szy szx]=size(R); % image size
% stek where seed will be stored:
stm=10000;
st=zeros(stm2‘int32‘);
st(11)=r(1);
st(12)=r(2); % r - is start seed
stL=1; % stack length
% hp=plot(11‘.k‘);
%
% set(hp‘XData‘st(1:stL1)‘YData‘st(1:stL2));
% drawnow;
% found pixel store:
ms0m=1e6; % margin
ms0=zeros(ms0m1‘int32‘); % predifined array to increase speed
ms0L=0; % 0 points initially
% initial point color:
R0=R(r(2)r(1));
G0=G(r(2)r(1));
B0=B(r(2)r(1));
% to pixel number
tn=@(xxyy) yy+szy*(xx-1);
while true;
% get seed from stack:
xt=st(stL1);
yt=st(stL2);
stL=stL-1;
% line:
% to right
sku=false; % seed key true if seed added up
skd=false; % same for down
sku1=false; % this key is need to prewnt extra seed when move to left up
skd1=false; % same for left
for xtt=xt:szx
if max(abs([(R(ytxtt)-R0) (G(ytxtt)-G0) (B(ytxtt)-B0)]))<=tol
% add pixel
ms0L=ms0L+1;
ms0(ms0L)=tn(xttyt);
else
break;
end
% try to add seed up:
if yt~=szy
if max(abs([(R(yt+1xtt)-R0) (G(yt+1xtt)-G0) (B(yt+1xtt)-B0)]))<=tol
if ~sku
if all(tn(xttyt+1)~=ms0(1:ms0L)) % if free space
% add to stack
stL=stL+1;
st(stL1)=xtt;
st(stL2)=yt+1;
sku=true;
end
end
else
sku=false;
end
if xtt==xt
sku1=sku; % memorize will be used when to left
end
end
% try to add down
if yt~=1
if max(abs([(R(yt-1xtt)-R0) (G(yt-1xtt)-G0) (B(yt-1xtt)-B0)]))<=tol
if ~skd
if all(tn(xttyt-1)~=ms0(1:ms0L)) % if free space
% add to stack
stL=stL+1;
st(stL1)=xtt;
st(stL2)=yt-1;
skd=true;
end
end
else
skd=false;
end
if xtt==xt
skd1=skd; % memorize will be used when to left
end
end
end
% to left
%sku=false; % seed key true if seed added
%skd=false;
sku=sku1;
skd=skd1;
if xt~=1
for xtt=(xt-1):-1:1
if max(abs([(R(ytxtt)-R0) (G(ytxtt)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 19264 2010-09-15 01:01 explane.png
文件 4628 2010-09-15 14:47 flood_fill.m
文件 590 2010-09-04 00:40 smile.png
文件 5372 2010-09-15 01:53 zz_flood_fill_movie.m
文件 411 2010-09-15 14:48 zz_flood_fill_test.m
文件 210 2010-09-15 01:18 zz_flood_fill_test_movie.m
文件 1532 2014-02-12 13:15 license.txt
相关资源
- matlab开发-能带计算
- matlab开发-FlockingAlgorithm
- matlab开发-MuellerStokesJonesCalculus
- matlab开发-HX711的自定义数据库
- matlab开发-SMOTEBoost
- matlab开发-果蝇优化算法第二版
- matlab开发-多变量决策树
- matlab开发-水轮发电机模型
- matlab开发-交通警告标志识别标签代码
- matlab开发-RUSBoost
- matlab开发-基于遗传算法的机器人运动
- matlab开发-MPU6050加速度陀螺仪
- matlab开发-功率曲线FAsmallscalewindturbi
- matlab开发-NASAJPLDE405开发星历表
- matlab开发-SortinoRatio
- matlab开发-永磁TDC并联电机数学模型
- matlab开发-3相SPWM整流器
- matlab开发-Kilobotswarm控制Matlabarduino
- matlab开发-简单音频播放
- matlab开发-记录文件的绘图仪加速度、
- matlab开发-永磁同步电机PMSM动态数学模
- matlab开发-多目标优化差分进化算法
- matlab开发-随机微分方程解算
- matlab开发-波长调制光谱的二次谐波模
- matlab开发-仿制药生物生理学基础药动
- matlab开发-使用svmrfe选择功能
- matlab开发-KDTreeNearestNeighborandRangeSear
- matlab开发-stlread
- matlab开发-三维图像堆栈查看器
- matlab开发-动态电压恢复器故障dvr
评论
共有 条评论