mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-10 10:13:06 +08:00
Move the tifffile wrapper to tiff plugin
This commit is contained in:
@@ -5,7 +5,7 @@ from six import string_types
|
||||
from PIL import Image
|
||||
|
||||
from ...util import img_as_ubyte, img_as_uint
|
||||
from ...external.tifffile import TiffFile, imsave as tif_imsave
|
||||
from .tifffile import imread as tif_imread, imsave as tif_imsave
|
||||
|
||||
|
||||
def imread(fname, dtype=None, img_num=None, **kwargs):
|
||||
@@ -41,9 +41,7 @@ def imread(fname, dtype=None, img_num=None, **kwargs):
|
||||
if hasattr(fname, 'lower') and dtype is None:
|
||||
kwargs.setdefault('key', img_num)
|
||||
if fname.lower().endswith(('.tiff', '.tif')):
|
||||
with open(fname, 'rb') as f:
|
||||
tif = TiffFile(f)
|
||||
return tif.asarray(**kwargs)
|
||||
return tif_imread(fname, **kwargs)
|
||||
|
||||
if isinstance(fname, string_types):
|
||||
with open(fname, 'rb') as f:
|
||||
|
||||
@@ -1 +1,28 @@
|
||||
from ...external.tifffile import imread, imsave
|
||||
from ...external.tifffile import TiffFile, imsave
|
||||
|
||||
|
||||
def imread(fname, dtype=None, **kwargs):
|
||||
"""Load a tiff image from file.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
fname : str or file
|
||||
File name or file-like-object.
|
||||
dtype : numpy dtype object or string specifier
|
||||
Specifies data type of array elements (Not currently used).
|
||||
kwargs : keyword pairs, optional
|
||||
Addition keyword arguments to pass through (see `tifffile`'s `imread` function).
|
||||
|
||||
Notes
|
||||
-----
|
||||
Provided by Christophe Golhke's tifffile.py [1]_, and supports many
|
||||
advanced image types including multi-page and floating point.
|
||||
|
||||
References
|
||||
----------
|
||||
.. [1] http://www.lfd.uci.edu/~gohlke/code/tifffile.py
|
||||
|
||||
"""
|
||||
with open(fname, 'rb') as f:
|
||||
tif = TiffFile(f)
|
||||
return tif.asarray(**kwargs)
|
||||
|
||||
Reference in New Issue
Block a user