write
Description
write(
writes the blocked image data bim,destination)bim to the location specified by
destination.
write(
specifies additional options for writing the blocked image data using name-value
arguments.bim,destination,Name,Value)
Examples
Create a blocked image and view the value of the Size property.
bim = blockedImage('cameraman.tif');
disp(bim.Size)256 256
Resize the blocked image using the blocked image apply object function to call imresize.
bsub1 = bim.apply(@(bs)imresize(bs.Data,0.5));
Create the new resolution level for the image.
write(bim, "pyramid2.tif", "LevelImages", bsub1, "BlockSize", [ 32 32]);
Create a new, multiresolution blocked image and display the Size property.
bpyramid = blockedImage("pyramid2.tif");
disp(bpyramid.Size)256 256 128 128
Create a blocked image and view the value of the Size property.
bim = blockedImage('tumor_091R.tif');
disp(bim.Size) 5000 5358 3
1250 1340 3
625 670 3
Write only two levels from a three level image. Write to a folder where each block is a saved in a separate PNG file.
write(bim, "lev1_and_3", "Levels", [1 3], "Adapter", images.blocked.PNGBlocks); bim2 = blockedImage("lev1_and_3"); disp(bim2.Size)
5000 5358 3
625 670 3
Inspect the output folder structure, using the Image Browser app, or view a montage of the images in the folders lev1_and_3/L1 and lev1_and_3/L2.
figure; montage(imageDatastore('lev1_and_3/L1'), 'BorderSize', 5);

View a montage of the images in the folder lev1_and_3/L2.
figure; montage(imageDatastore('lev1_and_3/L2'), 'BorderSize', 5);

Create a blocked image.
bim = blockedImage('tumor_091R.tif');Write the data from the three resolution levels of the blocked image to an H5 file. Specify the blocked image adapter for HDF5 files and the compression level when you write the data.
wadapter = images.blocked.H5; wadapter.GZIPLevel = 5; write(bim, "tumor_091.h5", "Adapter", wadapter);
Display information about the HDF5 image that was created.
h5disp("tumor_091.h5");HDF5 tumor_091.h5
Group '/'
Group '/blockedImage'
Attributes:
'Size': 3x3 H5T_FLOAT
'IOBlockSize': 3x3 H5T_FLOAT
'Datatype': 'uint8', 'uint8', 'uint8'
Dataset 'L1'
Size: 5000x5358x3
MaxSize: 5000x5358x3
Datatype: H5T_STD_U8LE (uint8)
ChunkSize: 1024x1024x3
Filters: deflate(5)
FillValue: 0
Dataset 'L2'
Size: 1250x1340x3
MaxSize: 1250x1340x3
Datatype: H5T_STD_U8LE (uint8)
ChunkSize: 1024x1024x3
Filters: deflate(5)
FillValue: 0
Dataset 'L3'
Size: 625x670x3
MaxSize: 625x670x3
Datatype: H5T_STD_U8LE (uint8)
ChunkSize: 625x670x3
Filters: deflate(5)
FillValue: 0
Input Arguments
Blocked image, specified as a blockedImage object.
Location to place writable data, specified as a character vector or string scalar.
Data Types: char | 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.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
Example: "Levels",[1 3]
Adapter used for writing blocked image data, specified as one of the adapter objects in the table.
| Adapter | Description |
|---|---|
BINBlocks | Store each block as a binary file in a folder |
GenericImage
| Store blocks in a single image |
GenericImageBlocks | Store each block as an image file in a folder |
H5 | Store blocks in a single HDF5 image |
H5Blocks | Store each block as an HDF5 file in a folder |
InMemory | Store blocks in a variable in main memory |
JPEGBlocks | Store each block as a JPEG file in a folder |
MATBlocks | Store each block as a MAT file in a folder |
PNGBlocks | Store each block as a PNG file in a folder |
TIFF | Store blocks in a single TIFF file |
You can also specify a custom adapter that performs custom writing operations. For
more information, see images.blocked.Adapter.
You must specify a value for the OutputLocation property for
all adapters except InMemory. If you do not specify a value for the
OutputLocation property, write uses
InMemory as the default adapter. Otherwise, the default adapter
is BINBlocks for numeric and logical data and
MATBlocks for struct and categorical
data.
Output block size, specified as 1-by-D vector of positive
integers, where D is the value of the
NumDimensions property of the blocked image
bim. The default block size is equal to the
BlockSize property of bim.
Display wait bar, specified as true or
false. When set to true, the
write object function displays a wait bar for long-running
operations. If you cancel the wait bar, the write function returns
a partial output, if available.
Additional single-level blocked images, specified as a vector of single-level
blockedImage objects. The write function
appends these additional single-level blocked image to the specified blocked image
(bim) to create a multiresolution blocked image. The
single-level blocked images should have the same NumDimensions
property value as bim.
Levels of a multiresolution blocked image to write, specified as vector of positive integers. Use this argument to selectively write the specified levels of the blocked image to the destination.
Version History
Introduced in R2021a
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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)