画像フォルダを読み取る際に、不要なファイルを名前で指定する方法
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
翔
am 17 Jan. 2023
Kommentiert: Shunichi Kusano
am 18 Jan. 2023
画像ファイルが複数入っているフォルダをimageDatastoreに保存したが、画像ファイル名称の先頭に"._"(ドットアンダーバー)がついているファイルを削除できません。
~ismemberを使用しましたが、「クラス cell の入力 A とクラス cell の入力 B は、一方が文字ベクトルでない限り、文字ベクトルのセル配列でなければなりません。」というエラーが出てしまいます。
ImageDataStoreのFilesは1230×1のcell配列になっており、原因がわかりません。
よろしくお願いします。
imagefile = imageDatastore("imagefolder");
imagefile = imagefile(~ismember({imagefile.Files},{'._'}));
0 Kommentare
Akzeptierte Antwort
Shunichi Kusano
am 17 Jan. 2023
startsWith関数が便利そうです。
filelist = {'1.jpg';'data.jpg';'.temp.jpg';'XXX.jpg'} % 適当にimds.Filesにあたるリストを作成
dotIdx = startsWith(filelist,'.')
ロジカル配列が取得できたので、subset関数を使ってdatastoreからドットから始まるファイルを除いたdatastoreを作成できます。
subimds = imageDatastore(imds,~dotIdx);
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 大きなファイルとビッグ データ finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!