欢迎来到天天文库
浏览记录
ID:10009399
大小:36.50 KB
页数:7页
时间:2018-05-20
《图形旋转的c语言源程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、图形旋转的C语言源程序/*****************************************************************//*CONVOLVE.C-TurboC2.0implementationofimageconvolution*//*----------byWesleyG.Faler.Allcodeis"asis".There*//*isNOcopyright.Usethiscodeasyouwill,andifyoumake*//*moneyatit,goodforyou.*//****************
2、*************************************************/#include#include#include#include#includeintload_cut(char*fname);intload_convolution_matrix(char*fname);intconvolve_image(void);intswap_pictures(void);intminx,maxx,miny,maxy;intLOA
3、DPAGE=0;intENHANCEPAGE=1;int*cmat,*pmat,*vmat;intcmx,cmy,cmnum;structpalettetypepalette,newpal;intdriver,mode;intcleancut=-1;intinit_graphics(void){driver=DETECT;mode=0;detectgraph(&driver,&mode);if(driver==VGA)mode=VGAMED;initgraph(&driver,&mode,"");getpalette(&palette);getpal
4、ette(&newpal);}intcleanup_image(void){inti,j,num,x,y,k;if(cleancut<0)return;setactivepage(LOADPAGE);setvisualpage(ENHANCEPAGE);for(x=minx;x5、if(num>cleancut){k=getpixel(x,y);setactivepage(ENHANCEPAGE);putpixel(x,y,k);setactivepage(LOADPAGE);}}}k=ENHANCEPAGE;ENHANCEPAGE=LOADPAGE;LOADPAGE=k;}voidshow_test_image(void){inti;minx=cmx;miny=cmy;maxx=100+minx;maxy=100+miny;setcolor(1);moveto(minx,miny);randomize();for(i=0;i6、<20;i++)lineto(random(100)+minx,random(100)+miny);for(i=0;i<10;i++)fillellipse(random(50)+25+minx,random(50)+25+miny,random(25),random(25));}main(){charfname[50];intflag=0;load_convolution_matrix("matrix.dat");printf(".CUTfile(1)ortestimage(0)?");scanf("%d",&flag);flag=flag?1:07、;if(flag){fflush(stdin);printf("filenametoprocess:");gets(fname);}printf("Deletepixelswithxorfewerneighbors.x=");scanf("%d",&cleancut);if(cleancut>8)cleancut=8;init_graphics();setactivepage(1);cleardevice();setactivepage(0);cleardevice();setactivepage(LOADPAGE);setvisualpage(LO8、ADPAGE);if(flag)load_cut(fname);elseshow_test_image();
5、if(num>cleancut){k=getpixel(x,y);setactivepage(ENHANCEPAGE);putpixel(x,y,k);setactivepage(LOADPAGE);}}}k=ENHANCEPAGE;ENHANCEPAGE=LOADPAGE;LOADPAGE=k;}voidshow_test_image(void){inti;minx=cmx;miny=cmy;maxx=100+minx;maxy=100+miny;setcolor(1);moveto(minx,miny);randomize();for(i=0;i
6、<20;i++)lineto(random(100)+minx,random(100)+miny);for(i=0;i<10;i++)fillellipse(random(50)+25+minx,random(50)+25+miny,random(25),random(25));}main(){charfname[50];intflag=0;load_convolution_matrix("matrix.dat");printf(".CUTfile(1)ortestimage(0)?");scanf("%d",&flag);flag=flag?1:0
7、;if(flag){fflush(stdin);printf("filenametoprocess:");gets(fname);}printf("Deletepixelswithxorfewerneighbors.x=");scanf("%d",&cleancut);if(cleancut>8)cleancut=8;init_graphics();setactivepage(1);cleardevice();setactivepage(0);cleardevice();setactivepage(LOADPAGE);setvisualpage(LO
8、ADPAGE);if(flag)load_cut(fname);elseshow_test_image();
此文档下载收益归作者所有