日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python opencv imwrite()方法 cv :: ImwriteFlags (写入图片、保存图片)

發布時間:2025/3/19 python 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python opencv imwrite()方法 cv :: ImwriteFlags (写入图片、保存图片) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

from init.py:
opencv版本4.1.0,不同版本也許doc稍有不同

def imwrite(filename, img, params=None): # real signature unknown; restored from __doc__"""imwrite(filename, img[, params]) -> retval. @brief Saves an image to a specified file. 將圖像保存到指定文件. . The function imwrite saves the image to the specified file. The image format is chosen based on the. filename extension (see cv::imread for the list of extensions). In general, only 8-bit. single-channel or 3-channel (with 'BGR' channel order) images. can be saved using this function, with these exceptions:· imwrite函數將圖像保存到指定文件。 圖像格式是根據文件擴展名選擇的(擴展名列表請參見cv :: imread)。 · 通常,使用此功能只能保存8位單通道或3通道(具有“ BGR”通道順序)圖像,但以下情況除外:. - 16-bit unsigned (CV_16U) images can be saved in the case of PNG, JPEG 2000, and TIFF formats. - 32-bit float (CV_32F) images can be saved in PFM, TIFF, OpenEXR, and Radiance HDR formats;· 對于PNG,JPEG 2000和TIFF格式,可以保存16位無符號(CV_16U)圖像;· 可以PFM,TIFF,OpenEXR和Radiance HDR格式保存32位浮點(CV_32F)圖像;. 3-channel (CV_32FC3) TIFF images will be saved using the LogLuv high dynamic range encoding. (4 bytes per pixel). - PNG images with an alpha channel can be saved using this function. To do this, create. 8-bit (or 16-bit) 4-channel image BGRA, where the alpha channel goes last. Fully transparent pixels. should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535 (see the code sample below).· 使用LogLuv高動態范圍編碼(每像素4個字節)將保存3通道(CV_32FC3)TIFF圖像-使用此功能可以保存具有alpha通道的PNG圖像。 · 為此,創建8位(或16位)4通道圖像BGRA,其中alpha通道位于最后。 · 完全透明的像素應將alpha設置為0,完全不透明的像素應將alpha設置為255/65535(請參見下面的代碼示例)。. . If the format, depth or channel order is different, use. Mat::convertTo and cv::cvtColor to convert it before saving. Or, use the universal FileStorage I/O. functions to save the image to XML or YAML format.· · 如果格式,深度或通道順序不同,請在保存之前使用Mat :: convertTo和cv :: cvtColor進行轉換。 · 或者,使用通用的FileStorage I / O功能將圖像保存為XML或YAML格式。. . The sample below shows how to create a BGRA image and save it to a PNG file. It also demonstrates how to set custom. compression parameters:· 下面的示例演示如何創建BGRA圖像并將其保存到PNG文件。 它還演示了如何設置自定義壓縮參數:. @include snippets/imgcodecs_imwrite.cpp. @param filename Name of the file. 文件名。. @param img Image to be saved. 要保存的圖像。. @param params Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags特定格式的參數編碼為對(paramId_1,paramValue_1,paramId_2,paramValue_2等)。請參見cv :: ImwriteFlags"""pass

Doc中所指cv :: ImwriteFlags:鏈接

參考文章:OpenCV筆記1:用imwrite函數來保存圖片

總結

以上是生活随笔為你收集整理的python opencv imwrite()方法 cv :: ImwriteFlags (写入图片、保存图片)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。