画像フォルダを読み取る際に、不要なファイルを名前で指定する方法
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
翔
el 17 de En. de 2023
Comentada: Shunichi Kusano
el 18 de En. de 2023
画像ファイルが複数入っているフォルダをimageDatastoreに保存したが、画像ファイル名称の先頭に"._"(ドットアンダーバー)がついているファイルを削除できません。
~ismemberを使用しましたが、「クラス cell の入力 A とクラス cell の入力 B は、一方が文字ベクトルでない限り、文字ベクトルのセル配列でなければなりません。」というエラーが出てしまいます。
ImageDataStoreのFilesは1230×1のcell配列になっており、原因がわかりません。
よろしくお願いします。
imagefile = imageDatastore("imagefolder");
imagefile = imagefile(~ismember({imagefile.Files},{'._'}));
0 comentarios
Respuesta aceptada
Shunichi Kusano
el 17 de En. de 2023
startsWith関数が便利そうです。
filelist = {'1.jpg';'data.jpg';'.temp.jpg';'XXX.jpg'} % 適当にimds.Filesにあたるリストを作成
dotIdx = startsWith(filelist,'.')
ロジカル配列が取得できたので、subset関数を使ってdatastoreからドットから始まるファイルを除いたdatastoreを作成できます。
subimds = imageDatastore(imds,~dotIdx);
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!