OpenCV学习笔记——imread、imwrite以及imshow

1、imread

Loads an image from a file. 从文件中读取图像。

C++: Mat imread(const string& filename, int flags=1 )

Parameters: 参数:

  • filename – Name of file to be loaded. 文件名
  • flags

    Flags specifying the color type of a loaded image:

    • >0 Return a 3-channel color image 返回一个三通道的图像
    • =0 Return a grayscale image 返回灰度图像
    • <0 Return the loaded image as is. Note that in the current implementation the alpha channel, if any, is stripped from the output image. For example, a 4-channel RGBA image is loaded as RGB if flags\ge0 .

2、imwrite

Saves an image to a specified file. 把图像保存到特定路径下。

C++: bool imwrite (const string& filename, InputArray image, const vector<int>& params=vector<int>() ) Parameters:
  • filename – Name of the file. 文件名
  • image – Image to be saved. 图像
  • params

    Format-specific save parameters encoded as pairs paramId_1, paramValue_1, paramId_2, paramValue_2, ... . The following parameters are currently supported:

    • For JPEG, it can be a quality ( CV_IMWRITE_JPEG_QUALITY ) from 0 to 100 (the higher is the better). Default value is 95. 对于JPEG,图像质量。
    • For PNG, it can be the compression level ( CV_IMWRITE_PNG_COMPRESSION ) from 0 to 9. A higher value means a smaller size and longer compression time. Default value is 3. 对于PNG,压缩等级。
    • For PPM, PGM, or PBM, it can be a binary format flag ( CV_IMWRITE_PXM_BINARY ), 0 or 1. Default value is 1.

3、imshow

Displays an image in the specified window. 在特定的窗口上显示图像。

C++: void imshow(const string& winname, InputArray image)

Parameters:

  • winname – Name of the window. 窗口名称。
  • image – Image to be shown. 要显示的图像。

[1] http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/core/mat%20-%20the%20basic%20image%20containe/mat%20-%20the%20basic%20image%20container.html#matthebasicimagecontainer

转载于:https://www.cnblogs.com/JJJanepp/p/5643790.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值