showlabels
Description
showlabels(
uses name-value arguments to modify the appearance of the overlay.b,labels,Name=Value)
Example: showlabels(b,labels,Colormap="jet") displays the label
overlay using the "jet" colormap.
Examples
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");Create a label image at a coarse resolution level.
First get a single-resolution image. By default, gather gets data from the coarsest resolution level.
cim = gather(bim);
Convert the image to grayscale. Use multithresh to calculate three threshold values to convert the image into a four-level image.
cgim = im2gray(cim); numClasses = 4; thresh = multithresh(cgim,numClasses-1);
Segment the image into four regions using imquantize, specifying the threshold levels returned by multithresh.
labels = imquantize(cgim,thresh); imagesc(labels) axis square title("Coarse Label Image")

Convert the labels image back to a blockedImage object, using the same spatial referencing as the original image at the coarsest resolution level.
blabels = blockedImage(labels,WorldStart=bim.WorldStart(3,1:2),...
WorldEnd=bim.WorldEnd(3,1:2));Display the original blocked image.
figure hB = bigimageshow(bim);

Overlay the labels image on the original blocked image.
showlabels(hB,blabels)

Create a blocked image using a modified version of image tumor_091R.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 = blockedImage("tumor_091R.tif");Create a mask at the coarsest resolution level and display it.
blabels = apply(bim,@(bs)rgb2lightness(bs.Data)<80,Level=3); hbim = bigimageshow(blabels);

Display the original blocked image with the mask as a label overlay. Use the Alphadata and Alphamap name-value arguments to display the mask background overlay as translucent and the mask foreground overlay as fully transparent.
hbim = bigimageshow(bim); showlabels(hbim,blabels,AlphaData=blabels,Alphamap=[0.8 0])

Load a file containing an image, img, and its corresponding pixel label data, label. Convert the image to a blockedImage object.
load("buildingPixelLabeled.mat")
bim = blockedImage(img);Create a blocked image of the categorical pixel label data. Display the order of the four label categories.
blabel = blockedImage(label); labels = categories(blabel.InitialValue)
labels = 4×1 cell
{'sky' }
{'grass' }
{'building'}
{'sidewalk'}
Define a custom colormap specifying RGB triplets for each category. The first row of cmap corresponds to undefined pixel labels, and the remaining four rows correspond to each categorical label. Assign the sky overlay to display blue and the grass overlay to display green.
cmap = [0 0 0; 0 0 1; 0 1 0; 0 0 0; 0 0 0];
Define the transparency map.
amap = [.5 .5 0 0];
Display the original unlabeled blocked image and the label overlay on the same axes. The AlphaData and Alphamap name-value arguments map each defined category in blabel to the corresponding element in amap, making the sky and grass overlays translucent and the building and sidewalk overlays fully transparent. Undefined pixel labels map to the first element in amap.
hbim = bigimageshow(bim); showlabels(hbim,blabel,AlphaData=blabel,Alphamap=amap,Colormap=cmap)

Input Arguments
bigimageshow object displaying 2-D blocked image data, specified as
a bigimageshow object.
Labels, specified as a 2-D blockedImage
object, numeric matrix, or logical matrix. If labels is a
blockedImage object with multiple resolution levels,
showlabels selects the level closest to the current
ResolutionLevel of b for display. If
labels is specified as a numeric or logical matrix,
showlabels converts the matrix to a blockedImage
object.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
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.
Example: showlabels( specifies five varying transparency values in the
overlay by mapping each element in b,labels,AlphaData=labels,Alphamap=[0
0.1 0.1 0.5 1])AlphaData to an index in
Alphamap.
Transparency data, specified in one of these forms:
Numeric scalar — Applies consistent transparency across the entire image.
2-D
blockedImageobject — Applies varying transparency values based on the underlying pixel values. Transparency data must be the same size as theblockedImageobject displayed inb.
The function interprets the numeric scalar or underlying pixel values as indices
of the transparency map specified by Alphamap. Values with a
decimal portion are fixed to the nearest lower integer:
If the values are of type
doubleorsingle, values of1or less map to the first element ofAlphamap. Values equal to or greater than the length ofAlphamapmap to the last element ofAlphamap.If the values are of an integer data type, then values of
0or less map to the first element ofAlphamap. Values equal to or greater than the length ofAlphmapmap to the last element ofAlphamap(or up to the range limits of the data type). The integer data types areuint8,uint16,uint32,uint64,int8,int16,int32, andint64.If the values are of type
logical, values of0map to the first element ofAlphamapand values of1map to the second element ofAlphamap.If
AlphaDatais a categoricalblockedImageobject, the defined categories map to corresponding elements ofAlphamap. You can verify the order in which categories map toAlphamapby using thecategoriesfunction.
Transparency map, specified as a numeric scalar or m-element
vector. All values must be in the range [0, 1], where 0 is
transparent and 1 is opaque. You can specify
Alphamap as a 1-by-m or
m-by-1 vector, where m is the number of
transparency values.
Colormap, specified as one of these values:
A c-by-3 colormap, where c is the number of colors in the colormap. RGB triplets in each row of the colormap must be normalized to the range [0, 1]. When c is greater than the number of labels l in the blocked image
labels,showlabelsuses only the first l colors of the colormap.A string scalar or character vector corresponding to one of the valid inputs to the
colormapfunction.showlabelspermutes the specified colormap so that adjacent labels are more distinct.
Example: [0.2 0.1 0.5; 0.1 0.5 0.8]
Example: "hot"
Data Types: single | double | char | string
Version History
Introduced in R2021b
See Also
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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)