python opencv imwrite()メソッド



Python Opencv Imwrite Method



から 初期化 .py:

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. Save the image to the 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 function saves the image to the specified file. The image format is (see cv :: imread list of extensions) based on the file extension selected. * Typically, this function can only hold 8-bit single channel or channel 3 (having a 'BGR' channel order) images, with the following exceptions: . - 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 • For PNG, JPEG 2000 and TIFF format, you can save 16-bit unsigned (CV_16U) image • You can PFM, TIFF, OpenEXR and Radiance HDR format to save 32-bit floating point (CV_32F) image . 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). Use LogLuv high dynamic range coding (4 bytes per pixel) to save channel 3 (CV_32FC3) TIFF images - use this feature to save PNG image with an alpha channel. · To this end, create an 8-bit (or 16-bit) in BGRA 4-channel image, the alpha channel in which is located last. Fully transparent pixels should be set to alpha 0, alpha completely opaque pixel should be set to 255/65535 (see sample code below). . . 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. · If a different format, depth or channel order, use Mat :: convertTo before saving and cv :: cvtColor conversion. · Or, use common FileStorage I / O function saves images as XML or YAML format. . . 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: · The following example shows how to create BGRA image and save it to a PNG file. It also demonstrates how to set up a custom compression parameters: . @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 ''' pass