mergeBlockLocationSets
Syntax
Description
Examples
Combine Block Sets Sampled from Same Image
Create a blocked image.
bim = blockedImage("tumor_091R.tif");
blockSize = [128 128];
Create a mask at the coarsest level. The mask corresponds to regions of the image that contain tissue.
clevel = bim.NumLevels; bmask = apply(bim,@(b)~imbinarize(im2gray(b.Data)),Level=clevel);
Display all regions with tissue. Specify a region as having tissue when at least 20% of pixels are true
in the stained region, as defined by the mask.
threshTissue = 0.2;
figure
h1 = bigimageshow(bim);
showmask(h1,bmask,BlockSize=blockSize,InclusionThreshold=threshTissue)
title("Highlighted Tissue Mask")
The tissue regions occupy a large portion of the image. When selecting tissue blocks, reduce the size of the data set by adding a gap between sampled blocks. The returned blockLocationSet
object contains 184 tissue blocks.
undersampleFactor = 1.5;
bls1 = selectBlockLocations(bim,BlockSize=blockSize,Masks=bmask, ...
InclusionThreshold=threshTissue,BlockOffsets=blockSize*undersampleFactor)
bls1 = blockLocationSet with properties: ImageNumber: [184×1 double] BlockOrigin: [184×3 double] BlockSize: [128 128 3] Levels: 1
Display the relatively homogeneous regions. Define a homogeneous region as a region in which at least 90% of pixels are true
in the stained region, as defined by the mask.
threshHomogeneous = 0.9; h2 = bigimageshow(bim); showmask(h2,bmask,BlockSize=blockSize,InclusionThreshold=threshHomogeneous) title("Highlighted " + threshHomogeneous*100 + "% Uniform Regions")
The homogeneous regions occupy a much smaller portion of the image. To select a balanced number of blocks, oversample the homogeneous blocks. The returned blockLocationSet
object contains 166 homogeneous blocks.
oversampleFactor = 2;
bls2 = selectBlockLocations(bim,BlockSize=blockSize,Levels=1,Masks=bmask, ...
InclusionThreshold=threshHomogeneous,BlockOffsets=blockSize/oversampleFactor)
bls2 = blockLocationSet with properties: ImageNumber: [166×1 double] BlockOrigin: [166×3 double] BlockSize: [128 128 3] Levels: 1
Merge the two sets of blocks.
blsMerged = mergeBlockLocationSets(bls1,bim,bls2,bim);
Create a blocked image datastore from the merged set of blocks.
bimds = blockedImageDatastore(bim,BlockLocationSet=blsMerged);
Input Arguments
bls1
— First set of block locations
blockLocationSet
object
First set of block locations, specified as a blockLocationSet
object.
bims1
— First set of blocked images
blockedImage
object | array of blockedImage
objects
First set of blocked images, specified as a blockedImage
object or an array of blockedImage
objects. These images correspond to
the images sampled by bls1
.
bls2
— Second set of block locations
blockLocationSet
object
Second set of block locations, specified as a blockLocationSet
object.
bims2
— Second set of blocked images
blockedImage
object | array of blockedImage
objects
Second set of blocked images, specified as a blockedImage
object or an array of blockedImage
objects. These images correspond to
the images sampled by bls2
Output Arguments
blsMerged
— Merged set of block locations
blockLocationSet
object
Merged set of block locations, returned as a blockLocationSet
object.
Version History
Introduced in R2023a
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)