计算机图形学实验区域填充算法的实现.docx实验三区域填充算法的实现班级10信计2班学号 姓名 一、 实验目的和要求:1、 掌握区域填充算法基本知识2、 理解区域的表示和类型,能正确区分四连通和八连通的区域3、 了解区域填充的实现原理,利用MicrosoftVisualC++-TC实现区域种子填充的递归算法。二、 实验内容:1、 编程完成区域填色2、 利用画线函数,在屏幕上定义一个封闭区域。3、 利用以下两种种子填充算法,填充上述步骤中定义的区域边界表示的四连通区域种子填充的实现内点表示的四连通区域种子填充的实现4、 将上述算法作部分改动应用于八连通区域,构成八连通区域种子填充算法,并编程实现。三、实验结果分析四连通图的实现:程序代码:#include<graphics>h>#include<>#include<math<h>#include<time<h>voidBoundaryFill4(intx,intyjntBoundarycolor^intnewcolor){if(getpixel(x,y)!=newcolor&&getpixel(x,y)!=Boundarycolor){putpixel(x^newcolor);Sleep(l);BoundaryFin4(x-l9y,Boundarycolor,newcolor);BoundaryFill4(x,y+l,Boundarycolor,newcolor);BoundaryFill4(x+l^Boundarycolor,newcolor);BoundaryFill4(x,y-l,BoundarycoIor^newcolor);}}voidpolygon(intxOJntyO^inta,intn^floataf)intx,y,i;doubledtheta,theta;if(n<3)return;dtheta=;theta=af*;moveto(xO,yO);x=xO;y=yO;for(i=l;i<n;i++){x=x+a*cos(theta);y=y+a*sin(theta);o(x,y);theta=theta+dtheta;}o(x0,y0);}voidmain(){intx=50,y=75;inta,b,c,d,ij;intgraphdriver=DETECT;intgraphmode=0;initgraph(&graphdriver,&graphmode9n");cleardevice();setcolor(RGB(0,255,0));setfillstyle(WHITE);polygon(x,y,60,5,0.);a=100;b=100;c=RGB(0,255,0);d=RGB(255,0,255);BoundaryFill4(a,b,c,d);getch();closegraph();}实验结果■liantong4□—冈八连通的实现程序代码:#include<>#include<conio>h>#include<>#include<>#include<>#defineMaxSize100typedefstruct!intx;inty;}Seed,ElemType;typedefstruct{ElemT
计算机图形学实验区域填充算法的实现 来自淘豆网m.daumloan.com转载请标明出处.