Main Content

write

(To be removed) Write bigimage object content to new file

The write function of the bigimage object will be removed in a future release. Use the write function associated with the blockedImage object instead. For more information, see Version History.

Description

write(bigimg,filename) writes a formatted version of big image bigimg to a TIFF file named filename. This syntax does not preserve the spatial referencing information of the big image.

write(bigimg,filename,'TIFFCompression',compression) also specifies the compression scheme for writing a formatted version of big image bigimg to a TIFF file named filename. This syntax does not preserve the spatial referencing information of the big image.

write(bigimg,dirname) writes a formatted version of big image bigimg to the directory named dirname. This syntax preserves the spatial referencing information of the big image.

example

write(___,Name,Value) specifies additional options when writing categorical data using name-value pair arguments.

Examples

collapse all

Create a bigimage using a modified version of image "tumor_091.tif" from the CAMELYON16 data set. The original image is a training image of a lymph node containing tumor tissue. The original image has eight resolution levels, and the finest level has resolution 53760-by-61440. The modified image has only three coarse resolution levels. The spatial referencing of the modified image has been adjusted to enforce a consistent aspect ratio and to register features at each level.

bim = bigimage("tumor_091R.tif");

Create a mask image from the coarsest resolution level, 3. The mask is 1 (true) for each pixel whose grayscale value is less than 100.

mask = apply(bim,3,@(im)im2gray(im)<100);

Write the mask image to a directory called "maskDir". The directory must not already exist. Before writing the mask image, check if the directory already exists, and if it does, delete it.

imageDir = "maskDir";
if exist(imageDir,"dir")
    rmdir maskDir s;
end
write(mask,imageDir);

Load the mask image back into the workspace by creating a new bigimage from the data in the mask directory. The spatial referencing information of the mask is retained.

mask1 = bigimage("maskDir");

Display the original image.

figure
bigimageshow(bim);

Figure contains an axes object. The axes object contains an object of type bigimageshow.

Display the mask image. The spatial referencing matches the original image, bim.

figure
bigimageshow(mask1);

Figure contains an axes object. The axes object contains an object of type bigimageshow.

Input Arguments

collapse all

Big image, specified as a bigimage object.

File name of written big image data, specified as a string or character vector. Supported file extensions are '.tif' and '.tiff'.

Data Types: string

Directory name of written big image data, specified as a string or character vector.

Data Types: string

TIFF compression scheme, specified as one of the following.

Compression SchemeDescription
"LZW"Lempel-Ziv-Welch lossless compression
"PackBits"PackBits lossless compression
"Deflate"Adobe DEFLATE lossless compression
"JPEG"JPEG-based lossy compression
"None"No compression

Data Types: string

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: write(bigimg,filename,Classes=["sky" "vegetation" "building"],PixelLabelIDs=[1 2 3]) writes a categorical bigimage with three classes

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: write(bigimg,filename,'Classes',["sky" "vegetation" "building"],'PixelLabelIDs',[1 2 3]) writes a categorical bigimage with three classes

Class names of categorical data, specified as a string array or a cell array of character vectors. The default value is the value of the Classes property of the big image bigimg.

If a class has multiple pixel values in PixelLabelIDs, then write writes all instances of that class using the first pixel value.

Data Types: char | string

Pixel label IDs that map pixel label values to categorical class names, specified as one of the following.

  • d-element numeric vector, where d is the number of classes

  • d-by-3 numeric array of data type uint8. Each row contains a 3-element vector representing the RGB pixel value to associate with each class name. Use this format when the pixel label data is stored as an RGB image.

The data type of the written pixels matches the data type of PixelLabelIDs. The default value is the value of the PixelLabelIDs property of the big image bigimg.

If a class has multiple pixel values in PixelLabelIDs, then write writes all instances of that class using the first pixel value.

Pixel label value for the <undefined> categorical class and pixel values that do not exist in PixelLabelIDs, specified as a numeric scalar or a 1-by-3 numeric vector. Do not specify this value as any of the values in PixelLabelIDs. The default value is the value of the UndefinedID property of the big image bigimg.

Version History

Introduced in R2019b

expand all

R2024b: Warns

The write function issues a warning that it will be removed in a future release.