当前位置: 首页>>代码示例>>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;未经允许,请勿转载。