當前位置: 首頁>>代碼示例>>Python>>正文


Python Imath.Channel方法代碼示例

本文整理匯總了Python中Imath.Channel方法的典型用法代碼示例。如果您正苦於以下問題:Python Imath.Channel方法的具體用法?Python Imath.Channel怎麽用?Python Imath.Channel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Imath的用法示例。


在下文中一共展示了Imath.Channel方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: writeEXR

# 需要導入模塊: import Imath [as 別名]
# 或者: from Imath import Channel [as 別名]
def writeEXR(img, file):
    try:
        img = np.squeeze(img)
        sz = img.shape
        header = OpenEXR.Header(sz[1], sz[0])
        half_chan = Imath.Channel(Imath.PixelType(Imath.PixelType.HALF))
        header['channels'] = dict([(c, half_chan) for c in "RGB"])
        out = OpenEXR.OutputFile(file, header)
        R = (img[:,:,0]).astype(np.float16).tostring()
        G = (img[:,:,1]).astype(np.float16).tostring()
        B = (img[:,:,2]).astype(np.float16).tostring()
        out.writePixels({'R' : R, 'G' : G, 'B' : B})
        out.close()
    except Exception as e:
        raise IOException("Failed writing EXR: %s"%e)


# Read training data (HDR ground truth and LDR JPEG images) 
開發者ID:gabrieleilertsen,項目名稱:hdrcnn,代碼行數:20,代碼來源:img_io.py

示例2: _WriteMixedDatatypesExr

# 需要導入模塊: import Imath [as 別名]
# 或者: from Imath import Channel [as 別名]
def _WriteMixedDatatypesExr(filename):
  header = OpenEXR.Header(64, 64)
  header['channels'] = {
      'uint': Imath.Channel(Imath.PixelType(Imath.PixelType.UINT)),
      'half': Imath.Channel(Imath.PixelType(Imath.PixelType.HALF))
  }
  channel_data = {
      'uint': np.zeros([64, 64], dtype=np.uint32).tobytes(),
      'half': np.zeros([64, 64], dtype=np.float16).tobytes()
  }
  output = OpenEXR.OutputFile(filename, header)
  output.writePixels(channel_data)
  output.close() 
開發者ID:tensorflow,項目名稱:graphics,代碼行數:15,代碼來源:exr_test.py

示例3: write_exr

# 需要導入模塊: import Imath [as 別名]
# 或者: from Imath import Channel [as 別名]
def write_exr(filename, values, channel_names):
  """Writes the values in a multi-channel ndarray into an EXR file.

  Args:
    filename: The filename of the output file
    values: A numpy ndarray with shape [height, width, channels]
    channel_names: A list of strings with length = channels

  Raises:
    TypeError: If the numpy array has an unsupported type.
    ValueError: If the length of the array and the length of the channel names
      list do not match.
  """
  if values.shape[-1] != len(channel_names):
    raise ValueError(
        'Number of channels in values does not match channel names (%d, %d)' %
        (values.shape[-1], len(channel_names)))
  header = OpenEXR.Header(values.shape[1], values.shape[0])
  try:
    exr_channel_type = Imath.PixelType(_np_to_exr[values.dtype.type])
  except KeyError:
    raise TypeError('Unsupported numpy type: %s' % str(values.dtype))
  header['channels'] = {
      n: Imath.Channel(exr_channel_type) for n in channel_names
  }
  channel_data = [values[..., i] for i in range(values.shape[-1])]
  exr = OpenEXR.OutputFile(filename, header)
  exr.writePixels(
      dict((n, d.tobytes()) for n, d in zip(channel_names, channel_data)))
  exr.close() 
開發者ID:tensorflow,項目名稱:graphics,代碼行數:32,代碼來源:exr.py


注:本文中的Imath.Channel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。