How to apply a function on all images in ImageDatastore ?

조회 수: 9 (최근 30일)
Ardalan Jalal
Ardalan Jalal 2021년 2월 5일
댓글: Ardalan Jalal 2021년 2월 7일
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);

채택된 답변

Jeremy Hughes
Jeremy Hughes 2021년 2월 5일
편집: Jeremy Hughes 2021년 2월 5일
I think this is what you want.
imds = imageDatastore(files,...)
tds = transform(imds,@(img)classify(net,img));
YPred = readall(tds);
  댓글 수: 3
Jeremy Hughes
Jeremy Hughes 2021년 2월 7일
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
Ardalan Jalal
Ardalan Jalal 2021년 2월 7일
Thank you so much that was exactly what i want

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by