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.
Syntax
Description
write(
also specifies the compression scheme for writing a formatted version of big image
bigimg
,filename
,'TIFFCompression',compression
)bigimg
to a TIFF file named filename
. This
syntax does not preserve the spatial referencing information of the big image.
write(___,
specifies
additional options when writing categorical data using name-value pair arguments.Name,Value
)
Examples
Write Big Image Data to Disk
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);
Display the mask image. The spatial referencing matches the original image, bim
.
figure bigimageshow(mask1);
Input Arguments
bigimg
— Big image
bigimage
object
Big image, specified as a bigimage
object.
filename
— File name
string | character vector
File name of written big image data, specified as a string or character vector.
Supported file extensions are '.tif'
and
'.tiff'
.
Data Types: string
dirname
— Directory name
string | character vector
Directory name of written big image data, specified as a string or character vector.
Data Types: string
compression
— TIFF compression scheme
"LZW"
(default) | "PackBits"
| "Deflate"
| "JPEG"
| "None"
TIFF compression scheme, specified as one of the following.
Compression Scheme | Description |
---|---|
"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
Classes
— Class names
string array | cell array of character vectors
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
PixelLabelIDs
— Pixel label IDs
d-element numeric vector | d-by-3 numeric array of data type
uint8
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.
UndefinedID
— Pixel label value for <undefined>
categorical class
0
(default) | numeric scalar | 1-by-3 numeric vector
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 R2019bR2024b: Warns
The write
function issues a warning that it will be removed
in a future release.
R2023b: To be removed
The bigimage
object and this function will be removed in a future
release. Use the write
function
of the blockedImage
object instead.
To update your code, first create a blockedImage
object to read your
image data. Then, follow these steps:
If you want to apply TIFF compression, create a
TIFF
adapter and set theCompression
property of the adapter using dot notation. If you want to write categorical data, then instead use aMATBlocks
adapter.Replace the first input argument of the
write
function with theblockedImage
object. Specify the optional adapter using theAdapter
name-value argument.
Discouraged Usage | Recommended Replacement |
---|---|
This example uses the filename = "tumor_091R.tif"; bigIm = bigimage(filename); newFilename = "tumor_091R_copy.tif"; write(bigIm,newFilename); | Here is equivalent code using a filename = "tumor_091R.tif"; blockedIm = blockedImage(filename); newFilename = "tumor_091R_copy.tif"; write(blockedIm,newFilename); |
This example writes the file with TIFF compression. write(bigIm,newFilename,"TIFFCompression","None"); | Here is equivalent code using a adaptor = images.blocked.TIFF; adaptor.Compression = Tiff.Compression.None; write(blockedIm,newFilename,Adapter=adapter); |
R2021a: write
function is not recommended
The write
function of the bigimage
object is not
recommended. Use the write
function
of the blockedImage
object instead. The
blockedImage
object offers several advantages including extension to N-D
processing, a simpler interface, and custom support for reading and writing nonstandard image
formats.
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)