画像フォルダを読み取​る際に、不要なファイ​ルを名前で指定する方​法

6 vues (au cours des 30 derniers jours)
翔
le 17 Jan 2023
Commenté : Shunichi Kusano le 18 Jan 2023
画像ファイルが複数入っているフォルダをimageDatastoreに保存したが、画像ファイル名称の先頭に"._"(ドットアンダーバー)がついているファイルを削除できません。
~ismemberを使用しましたが、「クラス cell の入力 A とクラス cell の入力 B は、一方が文字ベクトルでない限り、文字ベクトルのセル配列でなければなりません。」というエラーが出てしまいます。
ImageDataStoreのFilesは1230×1のcell配列になっており、原因がわかりません。
よろしくお願いします。
imagefile = imageDatastore("imagefolder");
imagefile = imagefile(~ismember({imagefile.Files},{'._'}));

Réponse acceptée

Shunichi Kusano
Shunichi Kusano le 17 Jan 2023
startsWith関数が便利そうです。
filelist = {'1.jpg';'data.jpg';'.temp.jpg';'XXX.jpg'} % 適当にimds.Filesにあたるリストを作成
filelist = 4×1 cell array
{'1.jpg' } {'data.jpg' } {'.temp.jpg'} {'XXX.jpg' }
dotIdx = startsWith(filelist,'.')
dotIdx = 4×1 logical array
0 0 1 0
ロジカル配列が取得できたので、subset関数を使ってdatastoreからドットから始まるファイルを除いたdatastoreを作成できます。
subimds = imageDatastore(imds,~dotIdx);
Unrecognized function or variable 'imds'.
  2 commentaires
Shunichi Kusano
Shunichi Kusano le 18 Jan 2023
すみません、パスのことを忘れていました。ですが、上手くいったようで良かったです。

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur イメージを使用した深層学習 dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!