How to apply a function on all images in ImageDatastore ?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ardalan Jalal
am 5 Feb. 2021
Kommentiert: Ardalan Jalal
am 7 Feb. 2021
I am using Imagedatastore function for classification problem but now I need to apply an function to all images in imageDatastore
YPred =classify(net,TestImages);
0 Kommentare
Akzeptierte Antwort
Jeremy Hughes
am 5 Feb. 2021
Bearbeitet: Jeremy Hughes
am 5 Feb. 2021
I think this is what you want.
imds = imageDatastore(files,...)
tds = transform(imds,@(img)classify(net,img));
YPred = readall(tds);
3 Kommentare
Jeremy Hughes
am 7 Feb. 2021
You can do multiple transforms,
imds = imageDatastore(files,...);
tds = transform(imds,@(img) ~imbinarize(img));
tds = transform(tds,@(img) classify(net,img));
YPred = readall(tds);
Based on what you wrote, I want to make sure you understand that this:
@(imd) ~imbinarize(imd)
doesn't take in a datastore as an input, it takes the image data, one-by-one, and then calls imbinarize on each result.
It works as if you called
imds = imageDatastore(files);
while hasdata(imds)
img = read(imds); % read an image from the datastore
img = ~imbinarize(img);
Ypred(end+1) = classify(net,img);
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!