Main Content

GenericImage

Read and write blocked image data as single image file

Since R2021a

Description

A GenericImage object is an adapter that reads and writes 2-D single-resolution blocked image data as a single image file.

When writing to disk, if the blocked image has any additional metadata in the UserData property, then the GenericImage object writes the data to a separate MAT file with the same file name.

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

adapter = images.blocked.GenericImage;
adapter.Extension = "jpg";

When reading from disk, the object reads all image data into memory as a single block. To access smaller blocks of image data, create a blockedImage object from the image file and specify a block size that is smaller than the full size of the image.

The table lists the support that the GenericImage 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 levelsNo
Process blocks in parallel using the apply functionNo
Resume block processing using the apply functionLimited. Only useful when processing an array of blockedImage objects.

Creation

Description

adapter = images.blocked.GenericImage creates a GenericImage object that reads and writes blocked image data as a single image file.

example

Properties

expand all

Preferred file format, specified as a string. The apply function of blockedImage uses this value when creating the output locations automatically.

Example: "jpg"

Examples

collapse all

Create a blocked image.

bim = blockedImage("tumor_091R.tif");

Write blocked image data to a PNG file using the write function. Create a GenericImage object as the adapter for the write function to use.

writeAdapter = images.blocked.GenericImage;
write(bim,"tumorL3.png","Adapter",writeAdapter,"Levels",3);

Create a blocked image from the PNG file that you just created. The blockedImage object automatically picks the appropriate adapter for the data.

bgi = blockedImage("tumorL3.png");  
disp(bgi.Adapter.Format)
png

Version History

Introduced in R2021a

expand all