opencv 笔记 00Begin
来源:互联网 发布:害怕异性亲密关系 知乎 编辑:程序博客网 时间:2024/05/17 07:45
Load and Display an Image
Mat image;image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the filenamedWindow( "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),用于保存转换图像。
- 附加参数,用于指定转换的类型
- opencv 笔记 00Begin
- linux学习笔记(begin)
- BEGIN...
- Begin!
- begin
- Begin
- Begin!
- begin
- BEGIN
- Begin
- Begin
- begin!
- begin
- Begin
- begin
- begin
- Begin
- begin
- 第四次C程序上机报告
- 关于火星坐标系统
- gawk 使用详解
- QT入门-一个简单的计算器程序
- 有一个南北向的桥,只能容纳一个人,现桥的两边分别有10人和12人,编制一个多线程序让这些人到达对岸,每个人用一个线程表示,桥为共享资源。在过桥的过程中显示谁在过桥及其走向。
- opencv 笔记 00Begin
- ssh框架下 对数据库的增删改查
- 生活需要奋斗
- linux下查询进程命令 ps 详细分析
- 抽象工厂模式——Head First Design Patterns
- 腾讯2011.10.15校园招聘会笔试题
- BufferedImage与byte[]互转
- 设计模式在android中的应用——适配器模式
- 学习Gtkmm系列之六