Main Content

GenericImageBlocks

Read and write blocks of blocked image data as image files

Since R2021a

Description

The GenericImageBlocks object is an adapter that reads and writes 2-D blocked image data as image files.

When writing to disk, the object creates an individual image file for each block and saves the image files in a folder. For multiresolution images, the object creates one subfolder for each resolution level. The object also creates and saves a MAT file with information about the blocked image, including the image size, block size, and data type.

By default, the object writes images as PNG files. To use a different file format, create the object and then change the file format using the BlockFormat property. For example, to write images as JPG files, use this code.

adapter = images.blocked.GenericImageBlocks;
adapter.BlockFormat = "jpg";

The table lists the support that the GenericImageBlocks object has for various blockedImage capabilities.

CapabilitiesSupport
Data types

This object supports 2-D images only:

  • Binary images of size m-by-n with data type logical

  • Grayscale images of size m-by-n with data type uint8

  • Truecolor (RGB) images of size m-by-n-by-3 with data type uint8

Multiple resolution levelsYes
Process blocks in parallel using the apply functionYes
Resume block processing using the apply functionYes

Creation

Description

example

adapter = images.blocked.GenericImageBlocks creates a GenericImageBlocks object that reads and writes blocked image data as image files, with one image file per block.

Properties

expand all

Image file format for each block of data, specified as a string that identifies one of the formats supported by imwrite.

Example: "tif"

Data Types: string

Examples

collapse all

Create blocked image.

bim = blockedImage('tumor_091R.tif');

Write image data to files. Specify the images.blocked.GenericImageBlocks adapter.

wa = images.blocked.GenericImageBlocks();
wa.BlockFormat = "tif";
write(bim, "dirOfTIFFs", "Adapter", wa);

Create a blocked image from the folder of images. The blockedImage object automatically picks the appropriate adapter.

bt = blockedImage("dirOfTIFFs");
disp(bt.Adapter)
  GenericImageBlocks with properties:

    BlockFormat: "tif"

Version History

Introduced in R2021a