首页 > 代码库 > 边界填充 cvCopyMakeBorder

边界填充 cvCopyMakeBorder

核心函数:cvCopyMakeBorder

程序:

wKioL1PsLkXxBITUAAE36zLbFfU065.jpg

代码:

#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <iostream>
int CopyMakeBorder(int argc,char** argv)
{
IplImage* src=http://www.mamicode.com/cvLoadImage("e:\\picture\\4.jpg");
IplImage* dst1=cvCreateImage(cvSize(src->width+40,src->height+40),src->depth,src->nChannels);
IplImage* dst2=cvCreateImage(cvSize(src->width+40,src->height+40),src->depth,src->nChannels);
cvZero(dst1);
cvZero(dst2);
cvCopyMakeBorder(src,dst1,cvPoint(20,20),IPL_BORDER_REPLICATE); //用边界像素的值填充,replicate为复制,原图放在目标图像作为为(20,20)的位置
cvCopyMakeBorder(src,dst2,cvPoint(20,20),IPL_BORDER_CONSTANT,cvScalar(0,0,255)); //用固定指定像素填充,constant为不变的,恒定的
cvNamedWindow("src");
cvNamedWindow("dst1");
cvNamedWindow("dst2");
cvShowImage("src",src);
cvShowImage("dst1",dst1);
cvShowImage("dst2",dst2);
cvWaitKey(0);
cvDestroyWindow("src");
cvDestroyWindow("dst1");
cvDestroyWindow("dst2");
cvReleaseImage(&src);
cvReleaseImage(&dst1);
cvReleaseImage(&dst2);
return 0;
}


本文出自 “flyclc” 博客,请务必保留此出处http://flyclc.blog.51cto.com/1385758/1539826