Main Content

getFullLevel

(To be removed) Get all data in one level of bigimage object

Since R2019b

The getFullLevel function of the bigimage object will be removed in a future release. Use the gather function associated with the blockedImage object instead. For more information, see Compatibility Considerations.

Description

I = getFullLevel(bigimg) reads the big image data in bigimg at the coarsest resolution level and returns the single-resolution image I.

example

I = getFullLevel(bigimg,level) reads the big image data in bigimg at the specified resolution level and returns the single-resolution image I.

Examples

collapse all

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

Figure contains an axes object. The axes object contains an object of type bigimageshow.

Create a mask at 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 = im2gray(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.

figure
bigimageshow(bmask)

Figure contains an axes object. The axes object contains an object of type bigimageshow.

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 0.

showmask(bshow,bmask,InclusionThreshold=0)

Figure contains an axes object. The axes object contains an object of type bigimageshow.

Input Arguments

collapse all

Big image, specified as a bigimage object.

Resolution level, specified as a positive integer that is less than or equal to the number of resolution levels of bigimg. The default level is the coarsest resolution level, bigimg.CoarsestResolutionLevel.

Output Arguments

collapse all

Single-resolution image, returned as a numeric array.

Tips

  • Check the LevelSizes property of the input big image bigimg to confirm that the size of image data at the specified level is small enough to fit in memory.

Version History

Introduced in R2019b

expand all

R2023b: getFullLevel will be removed

The bigimage object and this function will be removed in a future release. Use the gather function of the blockedImage object instead.

To update your code, first create a blockedImage object to read your image data. Then, follow these steps:

  • Replace instances of the getFullLevel function name with the gather function.

  • Replace the first input argument with the blockedImage object.

  • If you want to get the block at a different resolution level, then specify that level by using the Level name-value argument.

Discouraged UsageRecommended Replacement

This example uses the getFullLevel function with a bigimage object to return the image at the coarsest resolution level.

filename = "tumor_091R.tif";
bim = bigimage(filename);
img = getFullLevel(bim);

Here is equivalent code using a blockedImage object and the gather function.

filename = "tumor_091R.tif";
blockedIm = blockedImage(filename);
img = gather(blockedIm);

This example repeats the operation at resolution level 2.

lvl = 2;
img = getFullLevel(bim,lvl);

This example repeats the operation at resolution level 2 by specifying the Level name-value argument.

lvl = 2;
img = gather(blockedIm,Level=lvl);