showmask

Show mask overlay on bigimageshow

Description

showmask(b,mask) overlays a mask on a bigimageshow object, b, at the finest resolution level of the big image data.

  • 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 bigimage.

  • 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 apply function.

example

showmask(b,mask,level) overlays a mask on a bigimageshow object, b, at the specified resolution level of the big image data.

showmask(___,Name,Value) modifies the appearance of the mask blocks by using name-value pair arguments.

Examples

collapse all

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:

  1. Get a single-resolution image of the coarsest resolution level.

  2. Convert the image to grayscale.

  3. Binarize the image. In the binarized image, the object of interest is black and the background is white.

  4. 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);

Create a bigimage containing the mask. Use the same spatial referencing as the original big image.

bmask = bigimage(mask,'SpatialReferencing',clevelLims);

Display the mask.

figure
bigimageshow(bmask);

Overlay the mask on the original bigimage. To highlight all blocks that contain at least one nonzero mask pixel, specify an inclusion threshold of 0.

showmask(bshow,bmask,'InclusionThreshold',0);

Input Arguments

collapse all

Displayed big image data, specified as a bigimageshow object. The CData property specifies the big image data.

Mask, specified as a single-resolution bigimage object with a ClassUnderlying property value of logical. The spatial extents of the mask must be the same as the big image data at the displayed resolution level.

Resolution level at which to display the big image data, specified as a positive integer.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is 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 Name1,Value1,...,NameN,ValueN.

Example: showmask(b,mask,'InclusionThreshold',0.4)

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 bigimageobject in b.

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 0, the showmask function displays a mask block as ROI when at least one pixel in the mask block is nonzero.

  • When the inclusion threshold is 1, the showmask function displays a mask block as ROI only when all pixels in the mask block are nonzero.

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.

Tips

  • 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 the displayed 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.

Introduced in R2019b