Skip to main content

convenience wrapper for libtiff

Project description

Why?

Compared to PIL and some other tiff related projects, this package is more for scientific imaging.

Features exposed from libtiff:

  1. responds to

    1. pixel bit depth

    2. number of channels

    3. compression scheme

  2. sequential and random access to frames in multi-frame tiff

  3. query length of multi-frame tiff

Open

from tiffreader import TiffReader
tif = TiffReader.open("file_path.tif")

Random Access

tif.seek(10)
frame = tif.read_current()  # gives a 2D numpy array

is equivalent to

frame = tif[10]

Sequential Access

example for an average image of the 10th to 20th frames:

tif.seek(10)
result = np.zeros(tif.shape, dtype=np.uint64)
for frame in zip(tif, range(10)):
    result += frame
result /= 10

Additionally

from tiffreader import save_tiff
array = np.array([[1, 2, 3, 4], [5, 6, 7, 8]], dtype=np.uint8)
save_tiff(array, "tif_path.tif")
tif.length  # length of multi-frame tiff stack
tif.shape   # shape of one frame
tiffinfo("tif_path.tif", ["width", "height"])  # wraps tiffinfo to query for additional tags

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tiffreader-0.1.1.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file tiffreader-0.1.1.tar.gz.

File metadata

  • Download URL: tiffreader-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for tiffreader-0.1.1.tar.gz
Algorithm Hash digest
SHA256 742da4aabfeab2c4515f1abb442001f17d80bae3863ab9f2adedb7eee377ef14
MD5 d818c9ee31b8e5b62ff8a495023be1ad
BLAKE2b-256 9a6c61a7c528ccb9908a16d19171f0f34088e14c873811a37ab78f3c00686241

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page