Borrar filtros
Borrar filtros

画像処理に使用する画像の使用方法について

12 visualizaciones (últimos 30 días)
大空
大空 el 24 de Jun. de 2022
Comentada: Atsushi Ueno el 25 de Jun. de 2022
現在ディープラーニングを利用して画像処理を行っているのですがエクスプローラから画像をお読み取ることができません
imredを使用したのですがそれでもできなく。
できれば写真単体ではなくファイル事アップロードできる方法はございますか?
  3 comentarios
大空
大空 el 25 de Jun. de 2022
%% Initialization
clear, close all
%% Load Pre-trained CNN
convnet = alexnet;
imageSize = convnet.Layers(1).InputSize;
%% Load Images
imds =imageDatastore( "FileExtensions","C:\Users\misaki\MATLAB Drive\catdog.xlsm");
imds.ReadFcn = @(filename)readAndPreprocessImage(filename, imageSize);
このようなプログラムを入れて
使い方によるエラー imageDatastore
入力フォルダーまたは入力ファイルに非標準のファイル拡張子が含まれています。
非標準のファイル拡張子を含めるには、名前と値のペア FileExtensions を使用してください。
というエラーがでました。
Atsushi Ueno
Atsushi Ueno el 25 de Jun. de 2022
>エクスプローラから画像をお読み取ることができません
拡張子が.xlsm(マクロ付)であることから察するに、Excelファイルに貼り付けた画像データ(おそらく大量)をイメージデータストアに格納したい状況だが、Excelファイルから画像を読み取れない状況だと想定します。
  • imageDatastore関数の引数指定方法が文法と違います
%【誤】imds =imageDatastore( "FileExtensions","C:\Users\misaki\MATLAB Drive\catdog.xlsm");
%【正】imds =imageDatastore( "C:\Users\misaki\MATLAB Drive\catdog.xlsm","FileExtensions",".xlsm");
  • サンプルデータを作成してイメージデータストアに格納してみましたが、Excelファイルを取り込むだけで画像データとして取り出せる形にはなっていません。
imds = imageDatastore("myfile.xls","FileExtensions",".xls")
imds =
ImageDatastore with properties: Files: { '/users/mss.system.6ThM9L/myfile.xls' } Folders: { '/users/mss.system.6ThM9L' } AlternateFileSystemRoots: {} ReadSize: 1 Labels: {} SupportedOutputFormats: ["png" "jpg" "jpeg" "tif" "tiff"] DefaultOutputFormat: "png" ReadFcn: @readDatastoreImage
type readDatastoreImage
function data = readDatastoreImage(filename) %READDATASTOREIMAGE Read file formats supported by IMREAD. % % See also matlab.io.datastore.ImageDatastore, datastore, % mapreduce. % Copyright 2016-2020 The MathWorks, Inc. % Turn off warning backtrace before calling imread onState = warning('off', 'backtrace'); c = onCleanup(@() warning(onState)); N = 10; for iter = 1 : N try data = imread(filename); break; catch ME pause(10^-6); if iter == N throw(ME); end end end end
imout = readimage(imds,1)
Error using matlab.io.datastore.ImageDatastore/readimage
Error using ReadFcn @readDatastoreImage for file:

/users/mss.system.6ThM9L/myfile.xls

Error using readDatastoreImage
Unable to determine the file format.
  • >できれば写真単体ではなくファイル事アップロードできる方法はございますか?という質問に下記でYESと回答出来ますが、質問の意図は「画像データディープラーニングの学習関数に取り込める形にする必要がある」と思われ、目的に叶う形にはなっていません。
  • どうしてもimageDatastore関数でExcelファイルの画像データを読むのであれば、ReadFcnを指定する方法があります。デフォルトのReadFcnreadDataStoreImage関数ですが、上記に表示した通りその中身はimread関数です。当然imread関数でExcelファイルを開く事は出来ません。
  • ReadFcnを「xlsファイルを開いて中に貼り付けてある画像データを特定して所定の画像データ形式で出力する」関数に指定するには、COMサーバ経由でExcelファイルを開いて中の画像データを特定する必要がありそうです。PNGやJPG等の画像ファイルを読み込むのに比べて大幅に時間が掛かる事が予想されます。
  • Excelのマクロ等(MATLABでも可)で、Excelファイル内の画像データを画像ファイル群にしておいた方が作業効率が良くなると思います。

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!