write

Write bigimage content to new file

Description

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

example

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

Examples

collapse all

Create a bigimage. This examples uses 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 true for each pixel whose grayscale (luminance) value is less than 100.

mask = apply(bim,3,@(im)rgb2gray(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 and the mask image. The spatial referencing matches the original image, bim.

figure
bigimageshow(bim);
figure
bigimageshow(mask1);

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

Tips

  • If you write a bigimage by specifying a filename, then write writes the TIFF files using the LZW lossless compression scheme.

Introduced in R2019b