Main Content

countEachLabel

Count files in ImageDatastore labels

Description

example

T= countEachLabel(imds)returns a summary table of the labels inimdsand the number of files associated with each.

Examples

collapse all

Create anImageDatastoreobject 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

collapse all

Input datastore, specified as anImageDatastoreobject. To create anImageDatastorefrom your image data, use theimageDatastorefunction.

Output Arguments

collapse all

表的标签数,返回ed as a two-column table containing the name of each label inimdsand the number of files associated with each label.

Data Types:table

Extended Capabilities

Version History

Introduced in R2016a