docstr: Save image by cv2 module.
  Args:
      path (str): output filename
      img (numpy.ndarray): Image array to save. Image shape is considered as (height, width, channel) by default.
      channel_first:
          This argument specifies the shape of img is whether (height, width, channel) or (channel, height, width).
          Default value is False, which means the img shape is (height, width, channel)
      as_uint16 (bool):
          If True, save image as uint16.
      auto_scale (bool) :
          Whether upscale pixel values or not.
          If you want to save float image, this argument must be True.
          In cv2 backend, all below are supported.
              - float ([0, 1]) to uint8 ([0, 255])  (if img.dtype==float and auto_scale==True and as_uint16==False)
              - float to uint16 ([0, 65535]) (if img.dtype==float and auto_scale==True and as_uint16==True)
              - uint8 to uint16 are supported (if img.dtype==np.uint8 and auto_scale==True and as_uint16==True)
docstr_tok: ["Save","image","by","cv2","module",".","Args",":","path","(","str",")",":","output","filename","img","(","numpy.ndarray",")",":","Image","array","to","save",".","Image","shape","is","considered","as","(","height",",","width",",","channel",")","by","default",".","channel_first",":","This","argument","specifies","the","shape","of","img","is","whether","(","height",",","width",",","channel",")","or","(","channel",",","height",",","width",")",".","Default","value","is","False",",","which","means","the","img","shape","is","(","height",",","width",",","channel",")","as_uint16","(","bool",")",":","If","True",",","save","image","as","uint16",".","auto_scale","(","bool",")",":","Whether","upscale","pixel","values","or","not",".","If","you","want","to","save","float","image",",","this","argument","must","be","True",".","In","cv2","backend",",","all","below","are","supported",".","-","float","(","[","0",",","1","]",")","to","uint8","(","[","0",",","255","]",")","(","if","img.dtype==float","and","auto_scale==True","and","as_uint16==False",")","-","float","to","uint16","(","[","0",",","65535","]",")","(","if","img.dtype==float","and","auto_scale==True","and","as_uint16==True",")","-","uint8","to","uint16","are","supported","(","if","img.dtype==np.uint8","and","auto_scale==True","and","as_uint16==True",")"]
code: def imsave(
      self,
      path,
      img,
      channel_first=False,
      as_uint16=False,
      auto_scale=True,
  ):
      """
      Save image by cv2 module.
      Args:
          path (str): output filename
          img (numpy.ndarray): Image array to save. Image shape is considered as (height, width, channel) by default.
          channel_first:
              This argument specifies the shape of img is whether (height, width, channel) or (channel, height, width).
              Default value is False, which means the img shape is (height, width, channel)
          as_uint16 (bool):
              If True, save image as uint16.
          auto_scale (bool) :
              Whether upscale pixel values or not.
              If you want to save float image, this argument must be True.
              In cv2 backend, all below are supported.
                  - float ([0, 1]) to uint8 ([0, 255])  (if img.dtype==float and auto_scale==True and as_uint16==False)
                  - float to uint16 ([0, 65535]) (if img.dtype==float and auto_scale==True and as_uint16==True)
                  - uint8 to uint16 are supported (if img.dtype==np.uint8 and auto_scale==True and as_uint16==True)
      """
  
      img = _imsave_before(img, channel_first, auto_scale)
  
      if auto_scale:
          img = upscale_pixel_intensity(img, as_uint16)
  
      img = check_type_and_cast_if_necessary(img, as_uint16)
  
      # revert channel order to opencv`s one.
      if len(img.shape) == 3:
          if img.shape[-1] == 3:
              img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
          elif img.shape[-1] == 4:
              img = cv2.cvtColor(img, cv2.COLOR_RGBA2BGRA)
  
      cv2.imwrite(path, img)
  
file_path: nnabla/python/src/nnabla/utils/image_utils/backend_events/cv2_backend.py
imports: from __future__ import absolute_import, division
  import cv2
  import numpy
  from nnabla.logger import logger
  from .common import upscale_pixel_intensity, check_type_and_cast_if_necessary, _imread_before, _imread_after, _imsave_before, _imresize_before, _imresize_after
  from .image_utils_backend import ImageUtilsBackend
label_desc: Use image node_id 9 for calling the Cv2Backend obj's underlying member method code with example usage: obj.imsave(path, img, channel_first, as_uint16, auto_scale) without return types