本文整理汇总了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
示例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'
示例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
示例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()
示例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