opencv 笔记 00Begin
2013-04-08 22:59
183 查看
Load and Display an Image
Mat image; image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display. imshow( "Display window", image ); // Show our image inside it.
You’ll almost always end up using the:
core section, as here are defined the basic building blocks of the library
highgui module, as this contains the functions for input and output operations
imread function which loads the image name
specified by the first argument (argv[1]). The second argument specifies the format in what we want the image. This may be:
CV_LOAD_IMAGE_UNCHANGED (<0) loads the image as is (including the alpha channel if present)
CV_LOAD_IMAGE_GRAYSCALE ( 0) loads the image as an intensity one
CV_LOAD_IMAGE_COLOR (>0) loads the image in the RGB format
namedWindow ,For
this you need to specify its name and how it should handle the change of the image it contains from a size point of view. It may be:
CV_WINDOW_AUTOSIZE is the only supported one if you do not use the Qt backend. In this case the window size will take up the size of the image it shows. No resize permitted!
CV_WINDOW_NORMAL on Qt you may use this to allow window resize. The image will resize itself according to the current window size. By using the | operator you also need to specify if
you would like the image to keep its aspect ratio (CV_WINDOW_KEEPRATIO) or not (CV_WINDOW_FREERATIO).
imshow function.
Specify the OpenCV window name to update and the image to use during this operation:
读取、修改、保存图像
Mat image; image = imread( imageName, CV_LOAD_IMAGE_COLOR); Mat gray_image; cvtColor( image, gray_image, CV_BGR2GRAY ); imwrite( "../../images/Gray_Image.jpg", gray_image );
cvtColor 的参数为:
源图像 (image) 。
目标图像 (gray_image),用于保存转换图像。
附加参数,用于指定转换的类型
imwrite该函数,将图像写入到指定的文件夹下,程序执行时需保证该文件夹存在
相关文章推荐
- OpenCV笔记(十)
- opencv开发笔记(十):线性滤波之方框滤波、均值滤波、高斯滤波
- 【OpenCV学习笔记】二、OpenCV例程赏析
- opencv安装(WinXp平台下,Qt环境)笔记之二—测试opencv库安装成功
- VS2010+Opencv2.3.1,例程实现 笔记之模板匹配
- OpenCV学习笔记(28)KAZE 算法原理与源码分析(二)非线性尺度空间构建
- OpenCV 2 学习笔记(8): 利用邻域处理图像与简单的算术图像处理算法:图像滤波与加权和
- 机器学习初探:OpenCV K均值代码笔记
- openCV笔记:图像处理基础
- OpenCV学习笔记(21)OpenCV的Rect矩形类用法
- 关于opencv基础的设置的笔记
- opencv学习笔记-入门(7)单通道的图像数据访问
- 笔记2:win7下 OpenCv2.4.3+Qt5.0.1版本的配置
- OpenCV 2 学习笔记(10): 算法的基本设计模式<1>:策略模式(strategy pattern)
- opencv 2.x学习笔记(五)关于Mat
- opencv3笔记一 滑动条的创建与使用
- OpenCV学习笔记(一)——OpenCV3.1.0+VS2015开发环境配置
- OpenCV学习笔记-读取摄像头
- OpenCV学习笔记[5]FLANN特征匹配
- OpenCV学习笔记-图像分割