countEachLabel
(Removed) Count number of pixel labels for each class of
bigimageDatastore object
The countEachLabel function of the
bigimageDatastore object has been
removed (since R2026a). Use the countEachLabel function associated with the blockedImageDatastore object instead. For more information, see Version History.
Description
Examples
Load pixel label data.
load("buildingPixelLabeled.mat");Specify the classes and pixel label IDs of the pixel label data.
pixelLabelID = [1 2 3 4]; classNames = ["sky" "grass" "building" "sidewalk"];
Create a bigimage to manage the pixel label
data.
bigLabeledImage = bigimage(uint8(label),"Classes",classNames, ... "PixelLabelIDs",pixelLabelID);
Create a bigimageDatastore that reads blocks of size
200-by-150 pixels at the finest resolution level from
bigLabeledImage.
level = 1;
blockSize = [200 150];
biglabelds = bigimageDatastore(bigLabeledImage,level,"BlockSize",blockSize);Count the number of pixel labels for each class.
tbl = countEachLabel(biglabelds)
tbl=4×3 table
Name PixelCount BlockPixelCount
__________ __________ _______________
"sky" 81525 1.58e+05
"grass" 32983 51200
"building" 1.8036e+05 3.072e+05
"sidewalk" 10491 51200
Input Arguments
Big image datastore, specified as a bigimageDatastore object.
Output Arguments
Label information, returned as a table that contains three variables.
| Pixel Count Variables | Description |
|---|---|
Name | Pixel label class name |
PixelCount | Number of pixels in class |
BlockPixelCount | Total number of pixels in blocks that have an instance of the class |
Version History
Introduced in R2020aThe countEachLabel function has been removed. Use the countEachLabel function of the blockedImageDatastore object instead.
To update your code, follow these steps to create a
blockedImageDatastore object and count class labels:
Optionally, if you have categorical data and want to specify the order of the class labels, then you can convert the data to a numeric data type.
Create a
blockedImageobject to read your numeric or categorical image data.Create a
blockedImageDatastoreobject to manage blocks of the data.In the call to the
countEachLabelfunction, replace the first input argument with theblockedImageDatastoreobject. If the image data is numeric, also specify the class names and pixel label IDs using theClassesandPixelLabelIDsname-value arguments, respectively.
The countEachLabel function of
blockedImageDatastore and
blockedImageDatastore can return different results for the
BlockPixelCount variable of the
counts output argument.
| Discouraged Usage | Recommended Replacement |
|---|---|
This example counts the number of pixel
labels for each class of a
load("buildingPixelLabeled.mat"); numericLabels = uint8(label); pixelLabelID = [1 2 3 4]; classNames = ["sky" "grass" "building" "sidewalk"]; bigLabeledImage = bigimage(numericLabels,BlockSize=[200 150], ... Classes=classNames,PixelLabelIDs=pixelLabelID); bigLabeledDS = bigimageDatastore(bigLabeledImage,1); tbl = countEachLabel(bigLabeledDS) | Here is approximately equivalent code using a
load("buildingPixelLabeled.mat"); numericLabels = uint8(label); pixelLabelID = [1 2 3 4]; classNames = ["sky" "grass" "building" "sidewalk"]; blockedIm = blockedImage(numericLabels,BlockSize=[200 150]); blockedDS = blockedImageDatastore(blockedIm); tbl = countEachLabel(blockedDS, ... Classes=classNames,PixelLabelIDs=pixelLabelID) |
Here is approximately equivalent code using a
load("buildingPixelLabeled.mat");
blockedLabeledImage = blockedImage(label,BlockSize=[200 150]);
blockedLabeledDS = blockedImageDatastore(blockedLabeledImage);
tbl = countEachLabel(blockedLabeledDS) |
The countEachLabel function issues a warning that it will be
removed in a future release.
The bigimageDatastore object and this function will be removed in
a future release.
Starting in R2021a, the bigimageDatastore object and its object
functions, which operate on data from bigimage objects, are no
longer recommended. Instead, use the blockedImageDatastore object and its object functions, which operate
on data from blockedImage objects. The blockedImage object offers
several advantages including extension to N-D processing, a simpler interface, and
custom support for reading and writing nonstandard image formats.
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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)