PACS 图象尺寸缩小时的优化算法.docVIP

  • 3
  • 0
  • 约4.9千字
  • 约 3页
  • 2020-02-26 发布于陕西
  • 举报
CHISC.NET - 全国医疗信息化联盟 ,为全国医疗信息化人员提供最全面的资料下载平台 这个不仅能放大还能缩小用指针写的速度很快。是一种很简单的插值算法。 ========================================================================= BOOL COXDIB::ChangeDIB(int cx, int cy) { int width=GetWidth(); int height=GetHeight(); if((cx==width)(cy==height)) return FALSE; TRACE(width=%d,height=%d\n,width,height); COXDIB bmp; bmp.CreateEmptyDIB(24,cx,cy); for(int k=0;kcx;k++) for(int n=0;ncy;n++) bmp.SetPixel(k,n,RGB(255,255,255)); int tempcy,tempcx,startcx,startcy; double sx,sy,smin; //x和y方向的比例系数 sx=double(cx)/(double)width; sy=double(cy)/(double)height; smin=(sxsy)?sy:sx; tempcy=(int)(smin*height); tempcx=(int)(smin*width); startcx=(cx-tempcx)/2; startcy=(cy-tempcy)/2; // endcx=(cx+tempcx)/2; // endcy=(cy+tempcy)/2; int i,j; for(i=0;itempcx;i++) { for(j=0;jtempcy;j++) { double x,y; x=(double)i/smin; y=(double)j/smin; if(x=0)x=0; if(x=width-1)x=width-1; if(y=0)y=0; if(y=height-1)y=height-1; if( ((int)x==0)||((int)x==width-1)||((int)y==0)||((int)y==height-1) ) { COLORREF color1=GetPixel((int)x,(int)y); bmp.SetPixel(i+startcx,j+startcy,color1); }

文档评论(0)

1亿VIP精品文档

相关文档