Read and write blocked image data as single TIFF file
TIFF object is an adapter that reads and writes 2-D blocked
image data as a single TIFF file.
When writing to disk, the TIFF format requires block sizes to be a multiple of 16. If the
blocked image has any additional metadata in the
UserData property, then
TIFF object writes the data to a separate MAT-file with the same file
The object supports lossy and lossless compression. By default, the object uses
Lempel-Ziv-Welch lossless compression. To use a different compression scheme, create the
object and then change the compression scheme using the
property. You can also use this property to turn off compression. For example, to use
JPEG-based lossy compression, use this code.
adapter = images.blocked.TIFF; adapter.Compression = JPEG;
The table lists the support that the
TIFF object has for various
This object supports 2-D images only:
|Multiple resolution levels||Yes|
|Process blocks in parallel using the ||No|
|Resume block processing using the ||No|
adapter = images.blocked.TIFF creates a
object that reads and writes blocked image data as a single TIFF file.
Compression — TIFF compression scheme
"LZW" (default) |
TIFF compression scheme, specified as one of the following.
|Lempel-Ziv-Welch lossless compression|
|PackBits lossless compression|
|Adobe DEFLATE lossless compression|
|JPEG-based lossy compression|
Extension — Preferred file extension
"tiff" (default) | character vector | string scalar
Preferred file extension, specified as a string scalar or character vector.
Save Two Images as Single Multiresolution TIFF file
Create a blocked image.
bim = blockedImage('tumor_091R.tif');
Create two separate images.
bim.BlockSize = [512 512 3]; bo1 = apply(bim, @(bs)im2gray(bs.Data)); bo3 = apply(bim, @(bs)im2gray(bs.Data), "Level", 3);
Create a single multiresolution TIFF file from the two images. You specify additional resolution levels using the
wa = images.blocked.TIFF(); % Specify the TIFF adapter wa.Compression = Tiff.Compression.JPEG; % Specify compression in the adapter write(bo1, "tumor_091RGray.tif", "LevelImages", bo3, "Adapter", wa);
Introduced in R2021a