remove image from imageDatastore
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I often encounter the need for excluding images from an imageDatastore object. One could remove the image from the corresponding file system directory and create the imageDatastore again, but that should not be the default way. How do I remove a single image once the imageDatastore has been defined?
0 comentarios
Respuestas (1)
karim botros
el 4 de Mzo. de 2019
I have been looking for the same issue, and i found an easy work around to remove specific images from the imagedatastore
where {1,1} is the index of the data you want to delete
data.Files = setdiff(data.Files,data.Files{1,1})
1 comentario
Atsushi Ueno
el 15 de Mzo. de 2022
setdiff function removes only the relevant "Files" field and no other fields in this case.
The image data store object function that corresponds to the setdiff function is the subset function that has been introduced in R2019a.
You see "Files" and "Labels" field has been deleted as expected in the example below.
imds = imageDatastore(fullfile(matlabroot,"toolbox","matlab"),...
"IncludeSubfolders",true,"FileExtensions",".tif","LabelSource","foldernames")
delimg = matches(imds.Files, imds.Files{1,1});
subimds = subset(imds, ~delimg)
Ver también
Categorías
Más información sobre Image Sequences and Batch Processing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!