资源描述:
《实验一 熟悉opencv环境和基本操作》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实验一熟悉OpenCV环境和基本操作一、实验目的:熟悉OpenCV运行环境和了解图像的基本操作。二、实验内容:1.OpenCV的安装与配置。2.了解了OpenCV,尤其是core模块、核心功能、imgproc模块和highgui模块、高层GUI和媒体I/O。3.利用OpenCV实现了读入一个图像文件并将其显示在屏幕上;图像创建、保存和复制;图像边界的求取。三、实验作业:1·实验内容的结果i.读入一个图像文件并将其显示在屏幕上,结果如下图1:图1读入图片并显示ii.图像创建、保存和复制,结果如下图2:图2创建、保存复制图像ot
2、herstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwes
3、tOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecretary,Ministersandi.图像边界的求取,结果如下图3:图3Sobel算子求边界2·试举几个图像处理应用的例子图像处理的应用包括:压缩、编码、传输、存储、显示和识别等方面3·试查阅OpenCV库函数,利
4、用Sobel算子求图像边界#include"cv.h"#include"highgui.h"#include"stdio.h"#include"stdlib.h"intmain(intargc,char**argv){IplImage*src,*dst;src=cvLoadImage("c:\lena.jpg");dst=cvCreateImage(cvGetSize(src),IPL_DEPTH_16S,3);cvNamedWindow("src",0);cvShowImage("src",src);cvNamedWin
5、dow("sobel",0);cvSobel(src,dst,0,1,5);//利用Sobel算子求边界cvShowImage("sobel",dst);cvWaitKey(0);cvReleaseImage(&src);cvReleaseImage(&dst);return0;}得到的边界如下:otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommi
6、tteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecret
7、aryandrecorderoftheCountypartyCommitteeSecretary,Ministersand图4sobel算子求图像边界4·利用OpenCV产生一个图像,尺寸为200*240,三通道,其中某一块为黄色,其他皆为黑色。#include"cv.h"#include"highgui.h"#include#includecharwndname[]="DrawingDemo";intmain(intargc,char**argv){CvPointpt1,pt2;CvP
8、ointptt[6];CvPoint*pt[2];intarr[2];CvRNGrng;intwidth=240,height=200;intwidth3=width*3,height3=height*3;intymin=0;//LoadthesourceimageIplImage*ima