How to read an image after a particular result from CNN classification?

1 回表示 (過去 30 日間)
Vinay Chawla
Vinay Chawla 2020 年 9 月 16 日
コメント済み: Vinay Chawla 2020 年 9 月 22 日
Hello,
I am working with CNN for Image classification and I have created the code. I am now testing it against a new data and I want to apply a function that would only display the image when the result is a particluar class and I was wondering if I can do it using a FOR LOOP. I am using the following lines of codes for new test data but I am unable to display the image:
newImage= imread('C:\Users\ChawlaV\Desktop\MATLAB\Test Data\AC 4.jpg');
ds = augmentedImageDatastore(inputSize,newImage,'ColorPreprocessing','gray2rgb');
imageFeatures = activations(trainedNet, ds, featurelayer, 'MiniBatchSize', 32,'OutputAs', 'columns');
label = predict(classifier,imageFeatures, 'ObservationsIn','columns');
DistressType = (label); %%there are three classes AlligatorCracks, Potholes and Rutting
For DistressType = Potholes;
imshow(newImage);
end
%% the error that occurs while using this code is as follows:

採用された回答

Nomit Jangid
Nomit Jangid 2020 年 9 月 22 日
There are couple of things i'd suggest
  1. If you're comparing DistressType to Potholos, make sure to use '==' (not '=').
  2. label is categorical data so make sure to compare it with some string.
ex; DistressType = 'Potholes'
Since you're not using a 'Potholos' , MATLAB is looking for a variable or function.
  1 件のコメント
Vinay Chawla
Vinay Chawla 2020 年 9 月 22 日
Thank you so much. The second suggestion worked.
Appreciate it.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by