Show mask overlay on
Blocks of the mask that exceed a minimum percentage of nonzero pixels (by default,
50%) are displayed with a green tint. These blocks are considered ROI and would be
selected for processing by the
apply function of
Blocks of the mask below the minimum percentage of nonzero pixels are displayed
with a red tint. These blocks are considered background and would not be processed by
the appearance of the mask blocks by using name-value pair arguments.
Load a bigimage. This examples uses 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');
Display the entire bigimage at the finest resolution level. Display a grid of the block boundaries.
bshow = bigimageshow(bim,'GridVisible','on','GridLevel',1);
Determine the coarsest resolution level and the spatial referencing of the
bigimage at that level.
clevel = bim.CoarsestResolutionLevel; clevelLims = bim.SpatialReferencing(clevel);
Create a mask of the coarsest resolution level by following these steps:
Get a single-resolution image of the coarsest resolution level.
Convert the image to grayscale.
Binarize the image. In the binarized image, the object of interest is black and the background is white.
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.
imcoarse = getFullLevel(bim,clevel); graycoarse = rgb2gray(imcoarse); bwcoarse = imbinarize(graycoarse); mask = imcomplement(bwcoarse);
bigimage containing the mask. Use the same spatial referencing as the original big image.
bmask = bigimage(mask,'SpatialReferencing',clevelLims);
Display the mask.
Overlay the mask on the original
bigimage. To highlight all blocks that contain at least one nonzero mask pixel, specify an inclusion threshold of
level— Resolution level
Resolution level at which to display the big image data, specified as a positive integer.
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
'BlockSize'— Block size
Block size of image data, specified as the comma-separated pair consisting of
'BlockSize' and 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 the comma-separated pair consisting of
'InclusionThreshold' and 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 ROI.
When the inclusion threshold is
showmask function displays a mask block as ROI when at
least one pixel in the mask block is nonzero.
When the inclusion threshold is
showmask function displays a mask block as ROI only when
all pixels in the mask block are nonzero.
'Alpha'— Mask transparency
0.3(default) | number in the range [0, 1]
Mask transparency, specified as the comma-separated pair consisting of
'Alpha' and a number 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.
When you call
showmask for the first time, the function
calculates the ratio of nonzero to zero mask pixels for each block at the finest level of
bigimage. 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.