readRelative
(To be removed) Read neighboring block from bigimageDatastore
using relative position
The readRelative function of the bigimageDatastore
object will be removed in a future release. Use the getBlock function
of the blockedImage object
instead. For more information, see Version History.
Syntax
Description
returns the block from big image datastore data = readRelative(bigds,sourceInfo,blockOffset)bigds that neighbors the
source block sourceInfo with offset
blockOffset.
[
also returns information about the extracted data, including metadata, in
data,info]
= readRelative(bigds,sourceInfo,blockOffset)info.
Examples
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);
Read the first block from the datastore.
[b,binfo] = read(bimds);
b = b{1};Read the neighboring blocks to the left and right of the block. The left neighboring block is empty because the block is out of the bounds of bim.
bLeft = readRelative(bimds,binfo,[0 -1]); bRight = readRelative(bimds,binfo,[0 1]);
Display the blocks as a montage. The left neighboring block appears black because it is empty.
montage({bLeft,b,bRight},'Size',[1 3],'BorderSize',5,'BackgroundColor','b')
Input Arguments
Big image datastore, specified as a bigimageDatastore
object.
Information about source block, specified as a struct containing at least these
fields. The value of info returned by read is a valid input
for sourceInfo.
| Field Name | Description |
|---|---|
Level | Resolution level of the data, specified as a positive integers. |
ImageNumber | Index of the big image providing the data, specified as a positive integer. |
BlockStartWorld | (x,y) world coordinates of the top-left corner of the data, specified as a 1-by-2 numeric vector. The coordinates correspond to a position on the boundary of the block, not the center of the top-left pixel. |
Block offset, specified as a 1-by-2 vector of integers in units of blocks. The two elements specify the vertical and horizontal offset from the source block, respectively.
Output Arguments
Output data, returned as a numeric array. If the requested block is outside the
bounds of the source image, then readRelative returns an empty
block, [].
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. |
Tips
readRelativeignores masks.readRelativerespects thePadMethodandBorderSizeproperties of the big image datastore.If the requested block is incomplete and
has a value ofbigds.IncompleteBlocks'exclude', thenreadRelativereturns an empty block
Version History
Introduced in R2019bThe readRelative function issues a warning that it will be removed
in a future release.
The bigimageDatastore object and this function will be removed in a
future release. Use the getBlock
function of the blockedImage
object instead. The getBlock function does not support reading
neighboring blocks outside the bounds of the image.
To update your code, first create a blockedImage object to read your
image data, then create a blockedImageDatastore to manage blocks of the data. Then, follow these steps to
read a neighboring block using a relative position:
Read a block and return the block metadata from the
blockedImageDatastoreusing thereadfunction.Get the subscripts and resolution level by querying the
BlocksubandLevelproperties of the block metadata structure, respectively.Get the subscripts of the neighboring block by adding the relative offset of the neighboring block. If the block of data is an RGB image, then specify the offset as a 3-element vector with a value of
0for the last element.Call the
getBlockfunction, specifying the blocked image and the subscripts of the neighboring block. If the resolution level is a value other than1, also specify the resolution level by using theLevelname-value argument.
| Discouraged Usage | Recommended Replacement |
|---|---|
This example reads the neighboring block to the right of a specified
block from a bigIm = bigimage("tumor_091R.tif");
bigImds = bigimageDatastore(bigIm);
[block,info] = read(bigDS);
blockRightOffset = [0 1];
blockRight = readRelative(bigDS,info,blockRightOffset); | Here is equivalent code that reads the neighboring block to the right of
a specified block using a blockedIm = blockedImage("tumor_091R.tif");
blockedDS = blockedImageDatastore(blockedIm);
[block,info] = read(blockedDS);
blockSub = info.BlockSub;
blockRightOffset = [0 1 0];
blockRightSub = blockSub + blockRightOffset;
blockRight = getBlock(blockedIm,blockRightSub); |
This example reads the neighboring block at resolution level
bigIm = bigimage("tumor_091R.tif");
level = 2;
bigDS = bigimageDatastore(bigIm,level);
[block,info] = read(bigDS);
blockRightOffset = [0 1];
blockRight = readRelative(bigDS,info,blockRightOffset); | Here is equivalent code using a blockedIm = blockedImage("tumor_091R.tif");
level = 2;
blockedDS = blockedImageDatastore(blockedIm);
[block,info] = read(blockedDS);
blockSub = info.BlockSub;
blockRightOffset = [0 1 0];
blockRightSub = blockSub + blockRightOffset;
blockRight = getBlock(blockedIm,blockRightSub,Level=level); |
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.
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.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)