本文整理匯總了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