A class for easy manipulation of tiff files
Project description
tiff_utils
This class is a simple way of working with tiff files
## Import
from`tiff_utils import tiff
-During reads, all tags are collected and resolution is extracted in microns
-
by default, specifying a file name loads the image, tags and resolution information.
myImage =`tiff(fileName.tif) print(myImage.shape) print(myImage.image.dtype) print(myImage.y_resolution, myImage.x_resolution) print(myImage.tags)
-
loadImage=False can be specified when instantiating the class to load only tags and resolution information.
myImage = tiff(fileName.tiff, loadImage = False)
-
An image can be loaded manually by calling class method: .loadImage()
myImage.loadImage()
-During writes, the class.write() method will automatically:
-
Determine if BigTiff is required (currently files >= 2GB)
myImage.write() # Automatically determines whether BigTiff is required myImage.write(bigTiff=True) # Force the writer to use BigTiff
-
Manage compression (currently defaults to 'zlib')
myImage.write() # Defaults to zlib compression myImage.write(compression=0) # No compression
-
Manage tiled-tiff writes (currently defaults to (512,512))
myImage.write() myImage.write(tile=None) myImage.write(tile=(1024,1024))
CAUTION: be careful when calling .write() because it will overwrite the original image if the file name was not changed.
-Class methods enable easy:
-
Replacement of image with a different np.array: .newImage(array)
myImage =`tiff(fileName.tif) myImage.newImage(array = np.random.random((10,1024,1024),dtype=np.uint16))
-
Assign a new file name: .newFileName(fileNameString)
myImage.newFileName('/a/new/place/to/store/my/file.tif')
-
Conversion of dtype:
myImage.to8bit() myImage.to16bit() myImage.toFloat() myImage.toFloat32() myImage.toFloat64() myImage.toDtype(np.uint16) myImage.toDtype(np.uint8) myImage.toDtype(np.float)
-
Assigning of new resolution in microns: .newResolution((yres,xres))
myImage.newResolution((0.5,0.5))
-
Resizing of image to a specified resolution in microns: .resizeImage((x_res,y_res)) or .resizeImage(int)
myImage.resizeImage((25,25)) #Resize to 25 microns y,x
-
Clone an image class: newClass = currentClass.clone(newFilePath=None, array=None, newResolutionMicrons=None)
newImageClass = myImage.clone()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tiff_utils-0.1.0.tar.gz
.
File metadata
- Download URL: tiff_utils-0.1.0.tar.gz
- Upload date:
- Size: 218.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1af3301dde63c86db1218c62716b4db0cf461d94ed3735cd92c44b6a080a032d |
|
MD5 | 00ca791eb23ba157c42c2a5cf9d834da |
|
BLAKE2b-256 | 4e7a794336a044e9b8f59a000261bfa740f6da9b4b0c73c94d03ae6bebf08be4 |
File details
Details for the file tiff_utils-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: tiff_utils-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9db2cde214bf1cb97c04cced2f15e07e831faae8b9e2050b3b9058f2291b16cd |
|
MD5 | a5bd86cbdad7e78ceed52bb783926afb |
|
BLAKE2b-256 | 72190ab01d40aa10ffc6fd38c00167c8dfefcf6ef1d1b249fb3ff0d878174190 |