Show mask overlay at specified inclusion threshold
mask, as an overlay on the blocked image displayed in the
b. The overlay shows the
blocks that the
apply object function processes with the specified mask.
mask is a 2-D blocked image object the same size as the displayed
mask has multiple resolution levels,
bigimageshow uses the finest level.
bigimageshowdisplays blocks of the mask that exceed a minimum percentage of nonzero pixels (by default, 50%) with a green tint. These blocks are considered regions of interest and would be selected for processing by the
applyobject function of the
bigimageshowdisplays blocks of the mask below the minimum percentage of nonzero pixels with a red tint. These blocks are considered background and would not be processed by the
the appearance of the mask blocks by using name-value pair arguments.
Create Single-Resolution Mask from Multiresolution Blocked Image
Create a blocked image from the sample image tumor_091R.tif. This sample image is a training image of a lymph node containing tumor tissue from the CAMELYON16 data set. The image has been modified to have three coarse resolution levels, and has been adjusted to enforce a consistent aspect ratio and to register features at each level.
bim = blockedImage('tumor_091R.tif');
Display the entire blocked image at the finest resolution level, including a grid of the block boundaries.
bshow = bigimageshow(bim,'ResolutionLevel','fine', ... 'GridVisible','on','GridLevel',1);
Create a mask of the coarsest resolution level.
First create a single-resolution image of the coarsest resolution level. By default, the
gather function gets data from the coarsest resolution level.
imcoarse = gather(bim);
Convert the coarse image to grayscale.
graycoarse = rgb2gray(imcoarse);
Binarize the grayscale image. In the binarized image, the object of interest is black and the background is white.
bwcoarse = imbinarize(graycoarse);
Take the complement of the binarized image. The resulting mask follows the convention in which the object of interest is white and the background is black.
mask = imcomplement(bwcoarse);
Create a blocked image containing the mask.
Use the same spatial referencing as the original blocked image. Determine the coarsest resolution level and capture the spatial referencing information of the blocked image at the first two dimensions at that level.
coarsestLevel = bim.NumLevels; originalWorldStartCoarsest = bim.WorldStart(coarsestLevel,1:2); originalWorldEndCoarsest = bim.WorldEnd(coarsestLevel,1:2);
Create the blocked image for the mask.
bmask = blockedImage(mask,'WorldStart',originalWorldStartCoarsest, ... 'WorldEnd',originalWorldEndCoarsest);
Display the mask image.
Overlay the mask on the display of the original blocked image using the
showmask function. To highlight all blocks that contain at least one nonzero mask pixel, specify an inclusion threshold of
bigimageshow object displaying blocked image data
bigimageshow object displaying blocked image data, specified as a
bigimageshow object. The
CData property of the
specifies the blocked image data that is being displayed.
level — Resolution level
Resolution level at which to display the bocked image data, specified as a positive integer.
Specify optional pairs of arguments as
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.
Alpha — Mask transparency
0.3 (default) | scalar value in the range [0, 1]
Mask transparency, specified as a scalar value in the range [0, 1]. A value of
1 means the mask is completely opaque and a value of
0 means the mask is completely transparent.
BlockSize — Block size used with
1-by-2 vector of positive integers
Block size used with the
apply function, specified as a 1-by-2
vector of positive integers of the form
[numrows numcols]. The
default value is equal to the
BlockSize property of the
InclusionThreshold — Inclusion threshold
0.5 (default) | number in the range [0, 1]
Inclusion threshold, specified as a number in the range [0, 1]. The inclusion threshold indicates the minimum fraction of nonzero pixels in a mask block required to consider the mask block as a region of interest.
When the inclusion threshold is
showmaskfunction displays a mask block when at least one pixel in the mask block is nonzero.
When the inclusion threshold is
showmaskfunction displays a mask block only when all pixels in the mask block are nonzero.
When you call
showmaskfor the first time,
bigimageshowcalculates the ratio of nonzero to zero mask pixels for each block at the finest level of the displayed
blockedImage. This calculation takes some time to complete, so there can be some delay displaying the mask. When you make subsequent calls to
showmask, the function reuses the computed inclusion values and updates the displayed mask more quickly.