countEachLabel
Count files in ImageDatastore labels
Syntax
Description
Examples
Label Count
Create an ImageDatastore
object and label each image according to the folder it is in.
imds = imageDatastore(fullfile(matlabroot, 'toolbox', 'matlab', {'demos','imagesci'}),... 'LabelSource', 'foldernames', 'FileExtensions', {'.jpg', '.png', '.tif'})
imds = ImageDatastore with properties: Files: { ' ...\matlab\toolbox\matlab\demos\cloudCombined.jpg'; ' ...\matlab\toolbox\matlab\demos\example.tif'; ' ...\matlab\toolbox\matlab\demos\landOcean.jpg' ... and 5 more } Labels: [demos; demos; demos ... and 5 more categorical] ReadFcn: @readDatastoreImage
List the file count for each label.
T = countEachLabel(imds)
T = Label Count ________ _____ demos 6 imagesci 2
Input Arguments
imds
— Input datastore
ImageDatastore
object
Input datastore, specified as an ImageDatastore
object.
To create an ImageDatastore
from your image data, use the
imageDatastore
function.
Output Arguments
T
— Table of label counts
two-column table
Table of label counts, returned as a two-column table containing the name
of each label in imds
and the number of files associated
with each label.
Data Types: table
Extended Capabilities
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced in R2016a
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.
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)