资源描述:
《图像处理C语言程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include"affine.h"main(){ intdriver=DETECT,mode,i; staticdoublex1[]={0.0,10.0,80.0,100.0,0.0}; staticdoubley1[]={0.0,50.0,50.0,0.0,0.0}; staticdoublex2[5],y2[5],x3[5],y3[5],x4[5],y4[5]; doublex,xx,yy,r; initgraph(&driver,&mode,""); axis(); for(i=0;i<=3;i++) {line(scx(x1[i]),scy(
2、y1[i]),scx(x1[i+1]),scy(y1[i+1])); } scale(2.0); for(i=0;i<=4;i++) {x2[i]=affinex(x1[i],y1[i],1.0); y2[i]=affiney(x1[i],y1[i],1.0); delay(30000); } for(i=0;i<=3;i++) {line(scx(x2[i]),scy(y2[i]),scx(x2[i+1]),scy(y2[i+1])); } r=60; rotate(r); for(i=0;i<=4;i++) {x3[i]=affinex(x2[
3、i],y2[i],1.0); y3[i]=affiney(x2[i],y2[i],1.0); delay(30000); } for(i=0;i<=3;i++) {line(scx(x3[i]),scy(y3[i]),scx(x3[i+1]),scy(y3[i+1])); } palert:el(50.0,-150.0); for(i=0;i<=4;i++) {x4[i]=affinex(x3[i],y3[i],1.0); y4[i]=affiney(x3[i],y3[i],1.0); delay(30000); } for(i=0;i<=
4、3;i++) {line(scx(x4[i]),scy(y4[i]),scx(x4[i+1]),scy(y4[i+1])); } getch(); closegraph();} 子程序affine.h:doublesin(),cos();doublexmax=639.0,ymax=399.0;doublef[3][3],xx,yy;scx(xj)doublexj;{intx; x=(int)(xj+xmax/2); return(x);}scy(yi)doubleyi;{inty; y=ymax-(int)(yi+(ymax/2)); return(y);}palert:el
5、(dx,dy)doubledx,dy;{f[0][0]=1.0;f[0][1]=0.0;f[0][2]=0.0; f[1][0]=0.0;f[1][1]=1.0;f[1][2]=0.0; f[2][0]=dx;f[2][1]=dy;f[2][2]=1.0;}rotate(theta)doubletheta;{doubleth; th=theta/180*3.1415927; f[0][0]=cos(th);f[0][1]=sin(th);f[0][2]=0.0; f[1][0]=-sin(th);f[1][1]=cos(th); f[2][0]=0.0;f[2][1]=0.0;f[2
6、][2]=1.0;}scale(ss)doubless;{f[0][0]=ss;f[0][1]=0.0;f[0][2]=0.0; f[1][0]=0.0;f[1][1]=ss;f[1][2]=0.0; f[2][0]=0.0;f[2][1]=0.0;f[2][2]=1.0;}axis(){line(scx(0),scy(-ymax/2),scx(0),scy(ymax/2)); line(scx(-xmax/2),scy(0.0),scx(xmax/2),scy(0.0));}affinex(x,y,d)doublex,y,d;{xx=x*f[0][0]+y*f[1][0]+d*f[
7、2][0]; return(xx);}affiney(x,y,d)doublex,y,d;{yy=x*f[0][1]+y*f[1][1]+d*f[2][1]; return(yy);}