资源描述:
《实验一 熟悉 opencv 环境和基本操作》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实验一熟悉OpenCV环境和基本操作一、实验目的熟悉OpenCV运行环境和了解图像的基本操作。二、实验内容1.利用OpenCV读入一个图像文件,并将其显示到屏幕上实验结果:2.图像创建、保存和复制举例otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,Secreta
2、ryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecretary,Ministersand3.一个简单的图像处理例子,求图像的边界。4.试举几个图像处理应用的例子。(1)图像的二值化
3、:实验代码:#include"stdafx.h"#include"iostream"usingnamespacestd;#include"opencv2/opencv.hpp"IplImage*pGrayImage=NULL;IplImage*pBinaryImage=NULL;otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasre
4、corderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecretary,Ministersandconstc
5、har*pImagePath="D:\test.jpg";constchar*pGrayWindowsTitle="原图";constchar*pBinaryWindowsTitle="二值图";constchar*pWindowsToolBarTitle="阀值";voidonCallBack(intpos){//changeintobinaryimagecvThreshold(pGrayImage,pBinaryImage,pos,255,CV_THRESH_BINARY);cvShowImage(pBinaryWindowsTitle,pBinaryImage);}intm
6、ain(){//loadsrcouseimagefromfile//IplImage*pImage=cvLoadImage(pImagePath,CV_LOAD_IMAGE_UNCHANGED);//loadgrayimagefromsrcoucefileimage//pGrayImage=cvLoadImage(pImagePath,CV_LOAD_IMAGE_GRAYSCALE);//直接从原图获取灰度图//cvCvtColor(pImage,pGrayImage,CV_BGR2GRAY);//间接转化为灰度图IplImage*pImage=cvLoadImage(pImage
7、Path,CV_LOAD_IMAGE_UNCHANGED);pGrayImage=cvCreateImage(cvGetSize(pImage),IPL_DEPTH_8U,1);cvCvtColor(pImage,pGrayImage,CV_BGR2GRAY);pBinaryImage=cvCreateImage(cvGetSize(pGrayImage),IPL_DEPTH_8U,1);//createwindowandshoworialimagecvNamedWi