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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM