read
The read
function of the bigimageDatastore
object is
not recommended. Use the read
function
associated with the blockedImageDatastore
object instead. For more information, see Compatibility Considerations.
Description
Examples
Read Data from Big Image Datastore
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 bigimageDatastore
that manages blocks of the big image at the finest resolution level.
bimds = bigimageDatastore(bim,1)
bimds = bigimageDatastore with properties: ReadSize: 1 BorderSize: [0 0] PadMethod: 0 Images: [1x1 bigimage] Levels: 1 BlockSize: [1024 1024] BlockOffsets: [1024 1024] IncompleteBlocks: 'same' BlockLocationSet: [1x1 blockLocationSet]
Change the 'ReadSize'
property of the datastore to 3
.
bimds.ReadSize = 3;
Read one batch of image data from the datastore.
[data,info] = read(bimds);
Display the returned image data in a montage with a black border around each image. The montage shows that the datastore reads blocks of the big image in row-major order.
montage(data,'Size',[1 3],"BorderSize",10)
Display the information about the returned data.
info
info = struct with fields:
Level: [1 1 1]
ImageNumber: [1 1 1]
BlockStartWorld: [3x2 double]
BlockEndWorld: [3x2 double]
DataStartWorld: [3x2 double]
DataEndWorld: [3x2 double]
Inspect the (x,y) coordinates of the center of the top-left pixel of each returned block of data.
info.BlockStartWorld
ans = 3×2
1 1
1025 1
2049 1
Input Arguments
bigds
— Big image datastore
bigimageDatastore
Big image datastore, specified as a bigimageDatastore
object.
The datastore contains one or more big images,
Images
, each withChannels
number of channels.The datastore reads blocks from each big image at specified resolution levels,
Levels
.The datastore specifies the number of blocks to read in each batch,
ReadSize
.The datastore specifies the m-by-n pixel size of blocks to read,
BlockSize
.
Output Arguments
data
— Output data
cell array
Output data, returned as a cell array with ReadSize
elements.
Each cell contains an
m-by-n-by-Channels
numeric
array.
info
— Information about output data
struct
Information about output data, returned as a struct containing these fields.
Field Name | Description |
---|---|
Level | Resolution level of the data, specified as a
1-by-ReadSize vector of positive integers. |
ImageNumber | Index of the big image providing the data, specified as a
1-by-ReadSize vector of positive integers. |
BlockStartWorld | (x,y) coordinates of the center of
the top-left pixel of the data, excluding padding, specified as a
ReadSize -by-2 numeric vector. Values are in
world-coordinates. |
BlockEndWorld | (x,y) coordinates of the center of
the bottom-right pixel of the data, excluding padding, specified as a
ReadSize -by-2 numeric vector. Values are in
world-coordinates. |
DataStartWorld | (x,y) coordinates of the center of
the top-left pixel of the data, including padding, specified as a
ReadSize -by-2 numeric vector. Values are in
world-coordinates. |
DataEndWorld | (x,y) coordinates of the center of
the bottom-right pixel of the data, including padding, specified as a
ReadSize -by-2 numeric vector. Values are in
world-coordinates. |
Version History
Introduced in R2019bR2021a: read
function is not recommended
Starting in R2021a, the bigimageDatastore
object and its object
functions, which operate on data from bigimage
objects, are no longer
recommended. Instead, use the blockedImageDatastore
object and its object functions, which operate on data
from blockedImage
objects. 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.
Although there are no plans to remove the bigimageDatastore
object and
its read
function at this time, switch to the
blockedImageDatastore
object and its read
function
to take advantage of the additional capabilities and flexibility.
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
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)