opencv基本图像操作
2013-11-24 11:16
302 查看
// Basic_OpenCV_2.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> #include "cv.h" #include "highgui.h" using namespace std; void SmoothImage(IplImage* image)//平滑函数 { cvNamedWindow("Smooth_in"); cvNamedWindow("Smooth_out"); cvShowImage("Smooth_in",image); IplImage* out = cvCreateImage(cvGetSize(image),IPL_DEPTH_8U,3); cvSmooth(image,out,CV_BLUR,32,32);//平滑函数,后面两个参数是窗口大小 cvShowImage("Smooth_out",out); cvReleaseImage(&out); cvWaitKey(0); cvDestroyAllWindows(); } void doPyrDown(IplImage* in, int filter = IPL_GAUSSIAN_5x5)//图像缩小为一半 { //Best to make sure input image is divisible by two. assert(in->width%2 == 0 && in->height%2 == 0); IplImage* out = cvCreateImage(cvSize(in->width/2 , in->height/2) , in->depth , in->nChannels); cvPyrDown(in , out); cvNamedWindow("PyrDown_out"); cvShowImage("PyrDown_out",out); cvReleaseImage(&out); cvWaitKey(0); cvDestroyAllWindows(); //return out; } void doCanny(IplImage* in , double lowThresh , double highThresh , double aperture) { IplImage* out = cvCreateImage(cvSize(in->width,in->height) , IPL_DEPTH_8U , 1); if(in->nChannels != 1) { //cout<<"error! unsupported format or combination of formats() in unknown function"<<endl; //return;//canny only handles gray scale image //若不是灰度图,直接转化成灰度图 IplImage* gray = cvCreateImage(cvGetSize(in), IPL_DEPTH_8U, 1); cvCvtColor(in, gray, CV_BGR2GRAY); out = gray; } cvCanny(in , out , lowThresh , highThresh , aperture ); cvNamedWindow("Canny_out"); cvShowImage("Canny_out",out); cvReleaseImage(&out); cvWaitKey(0); cvDestroyAllWindows(); } int _tmain(int argc, _TCHAR* argv[]) { IplImage* image = cvLoadImage("lena.jpg"); //SmoothImage(image); //doPyrDown(image); doCanny(image ,10 , 100 , 3 ); system("pause"); return 0; }
相关文章推荐
- OpenCV从入门到放弃系列之——图像的基本操作
- opencv学习笔记1:矩阵和图像基本操作
- Opencv2系列学习笔记1(图像的基本操作)
- Python-OpenCV 处理图像基本操作
- OpenCV之imgproc 模块. 图像处理(1)图像平滑处理 腐蚀与膨胀(Eroding and Dilating) 更多形态学变换 图像金字塔 基本的阈值操作
- OpenCV 编程简介(矩阵/图像/视频的基本读写操作)
- OpenCV 编程简介(矩阵/图像/视频的基本读写操作)
- python opencv入门 基本图像操作(6)
- 【OpenCV学习笔记】1.2图像的基本操作
- OpenCV 编程简介(矩阵/图像/视频的基本读写操作)
- OpenCV 编程简介(矩阵/图像/视频的基本读写操作)
- opencv基本图像操作
- opencv2.3图像基本操作
- opencv-图像处理1 图像基本操作
- opencv对遥感图像基本操作
- opencv图像基本操作
- opencv基本图像操作
- Python-OpenCV 处理图像(一):基本操作
- 图像的属性,利用OpenCV进行图像的基本操作
- Opencv笔记——图像的部分基本操作(待补充)