码迷,mamicode.com
首页 > 其他好文 > 详细

cvGetCol与cvGetCols 获取列 cvGetSubRect获取图像的矩形区域

时间:2014-08-14 21:06:49      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:cvgetcol cvgetcols 获取列 cvgetsubrect获取图像的矩形区域 opencv

程序:

bubuko.com,布布扣

代码:

#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <iostream>
int GetCol(int argc,char** argv)
{
IplImage* src=cvLoadImage("e:\\picture\\4.jpg");
IplImage* dst1=cvCreateImage(cvSize(1,src->height),src->depth,src->nChannels);
cvZero(dst1);
IplImage* dst2=cvCreateImage(cvSize(20,src->height),src->depth,src->nChannels);
cvZero(dst2);
IplImage* dst3=cvCreateImage(cvSize(30,30),src->depth,src->nChannels);
cvZero(dst3);
cvGetCol(src,(CvMat*)dst1,10);  //获取第十列,注意这里并没有创建内存或者数据的复制,只是让dst1指向第十列
cvGetCols(src,(CvMat*)dst2,10,30);;
cvGetSubRect(src,(CvMat*)dst3,cvRect(10,10,30,30)); //获取图像的矩形区域
cvNamedWindow("src");
cvNamedWindow("dst1");
cvNamedWindow("dst2");
cvNamedWindow("dst3");
cvShowImage("src",src);
cvShowImage("dst1",dst1);
cvShowImage("dst2",dst2);
cvShowImage("dst3",dst3);
cvZero(dst2);            //由于只是让dst2指向源图像特定的列数,所以修改dst2也会修改原图像
cvNamedWindow("src2");
cvShowImage("src2",src);
cvWaitKey(0);
cvDestroyWindow("src");
cvDestroyWindow("dst1");
cvDestroyWindow("dst2");
cvDestroyWindow("dst3");
cvDestroyWindow("src2");
cvReleaseImage(&src);
cvReleaseImage(&dst1);
cvReleaseImage(&dst2);
cvReleaseImage(&dst3);
return 0;
}


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

cvGetCol与cvGetCols 获取列 cvGetSubRect获取图像的矩形区域,布布扣,bubuko.com

cvGetCol与cvGetCols 获取列 cvGetSubRect获取图像的矩形区域

标签:cvgetcol cvgetcols 获取列 cvgetsubrect获取图像的矩形区域 opencv

原文地址:http://flyclc.blog.51cto.com/1385758/1539956

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!