当前位置: 首页>>代码示例>>Python>>正文


Python Format.open_file方法代码示例

本文整理汇总了Python中dxtbx.format.Format.Format.open_file方法的典型用法代码示例。如果您正苦于以下问题:Python Format.open_file方法的具体用法?Python Format.open_file怎么用?Python Format.open_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dxtbx.format.Format.Format的用法示例。


在下文中一共展示了Format.open_file方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: understand

# 需要导入模块: from dxtbx.format.Format import Format [as 别名]
# 或者: from dxtbx.format.Format.Format import open_file [as 别名]
  def understand(image_file):
    '''See if this looks like an RAXIS format image - clue is first
    5 letters of file should be RAXIS.'''

    if Format.open_file(image_file).read(5) == 'RAXIS':
      return True

    return False
开发者ID:keitaroyam,项目名称:cctbx_fork,代码行数:10,代码来源:FormatRAXIS.py

示例2: _start

# 需要导入模块: from dxtbx.format.Format import Format [as 别名]
# 或者: from dxtbx.format.Format.Format import open_file [as 别名]
  def _start(self):
    self._header_bytes = Format.open_file(self._image_file).read(1024)

    if self._header_bytes[812:822].strip() in ['SGI', 'IRIS']:
      self._f = '>f'
      self._i = '>i'
    else:
      self._f = '<f'
      self._i = '<i'
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:11,代码来源:FormatRAXIS.py

示例3: read_basic_tiff_header

# 需要导入模块: from dxtbx.format.Format import Format [as 别名]
# 或者: from dxtbx.format.Format.Format import open_file [as 别名]
def read_basic_tiff_header(filename):
  '''Read the TIFF header (assuming for the moment a 4k header...) and
  return ... something.'''

  # things we hope to learn from the vanilla TIFF header

  image_width = None
  image_height = None
  image_depth = None
  header_size = None
  byte_order = None

  # OK then let's get started - and let's assume that the size is > 1 kb

  byte_order = tiff_byte_order(filename)
  tiff_header = Format.open_file(filename, 'rb').read(1024)

  if byte_order == LITTLE_ENDIAN:
    _I = '<I'
    _H = '<H'
  else:
    _I = '>I'
    _H = '>H'

  offset = struct.unpack(_I, tiff_header[4:8])[0]

  ntags = struct.unpack(_H, tiff_header[offset:offset + 2])[0]
  start = offset + 2

  for j in range(ntags):
    type_desc = struct.unpack(_H, tiff_header[start:start + 2])[0]
    start += 2
    type_type = struct.unpack(_H, tiff_header[start:start + 2])[0]
    start += 2
    type_size = struct.unpack(_I, tiff_header[start:start + 4])[0]
    start += 4
    if type_type == 4:
      type_offset_or_value = struct.unpack(
          _I, tiff_header[start:start + 4])[0]
      start += 4
    elif type_type == 3:
      type_offset_or_value = struct.unpack(
          _H, tiff_header[start:start + 2])[0]
      start += 4

    if type_desc == 256:
      image_width = type_offset_or_value
    elif type_desc == 257:
      image_height = type_offset_or_value
    elif type_desc == 258:
      image_depth = type_offset_or_value
    elif type_desc == 273:
      header_size = type_offset_or_value

  return image_width, image_height, image_depth, header_size, byte_order
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:57,代码来源:FormatTIFFHelpers.py

示例4: _start

# 需要导入模块: from dxtbx.format.Format import Format [as 别名]
# 或者: from dxtbx.format.Format.Format import open_file [as 别名]
  def _start(self):
    self._header_bytes = Format.open_file(self._image_file).read(1024)

    if self._header_bytes[812:822].strip() in ['SGI', 'IRIS']:
      self._f = '>f'
      self._i = '>i'
    else:
      self._f = '<f'
      self._i = '<i'

    from iotbx.detectors.raxis import RAXISImage
    self.detectorbase = RAXISImage(self._image_file)
    self.detectorbase.readHeader()
开发者ID:keitaroyam,项目名称:cctbx_fork,代码行数:15,代码来源:FormatRAXIS.py

示例5: tiff_byte_order

# 需要导入模块: from dxtbx.format.Format import Format [as 别名]
# 或者: from dxtbx.format.Format.Format import open_file [as 别名]
def tiff_byte_order(filename):
  '''Determine the byte order for the file from the magic numbers at the
  very start of the file.'''

  four_bytes = Format.open_file(filename, 'rb').read(4)

  if 'II' in four_bytes[:2]:
    assert(struct.unpack('<H', four_bytes[2:])[0] == 42)
    return LITTLE_ENDIAN
  elif 'MM' in four_bytes[:2]:
    assert(struct.unpack('>H', four_bytes[2:])[0] == 42)
    return BIG_ENDIAN

  raise RuntimeError, '%s not recognised as TIFF' % filename
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:16,代码来源:FormatTIFFHelpers.py


注:本文中的dxtbx.format.Format.Format.open_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。