combineddatastoreのAugmentationの方法
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Image to Image回帰のNeuralNetworkをつくるため、以下のようにDatastoreを作成しました。
予測子はDicomで応答は同サイズのpngでフォルダに保存しています。
以下のデータセットで学習は可能でしたが、汎化性を高めるため
予測子と応答に同じ関数で画像処理を行い、Augmentationも行いたいと考えています。
dsTrainにtransformを行ったものをいくつか生成して、Sequential datastoreにしてみてもうまく行きませんでした。(読み取り関数がサポートされていないというメッセージがでました。)
最終的には、Augmentationした画像をフォルダに保存すればできるとは思いますが、それ以外でうまい方法はありますでしょうか?
%% random shuffle Separate data
rng(0)
shuffledIndices = randperm(height(T));
idx = floor(0.7 * height(T));
trainingIdx = 1:idx;
trainingDataTbl = T(shuffledIndices(trainingIdx),:);
validationIdx = idx+1 : idx+0.2*length(shuffledIndices);
validationDataTbl = T(shuffledIndices(validationIdx),:);
testIdx = 0.2*length(shuffledIndices)+1+idx : length(shuffledIndices);
testDataTbl = T(shuffledIndices(validationIdx),:);
%% Making Datastore
cd 'C:\Users\------------------\Image\dicomfiles'
ids=imageDatastore(trainingDataTbl.filename,"ReadFcn",@dicomread,"FileExtensions",'.dcm');
val_ids=imageDatastore(validationDataTbl.filename,"ReadFcn",@dicomread,"FileExtensions",'.dcm');
test_ids=imageDatastore(testDataTbl.filename,"ReadFcn",@dicomread,"FileExtensions",'.dcm');
cd ..\pngfiles
%拡張子以外のファイル名は共通なので.dcmから.pngに変更
trainingPng=cellfun(@(x) extractBefore(x,'.dcm'),trainingDataTbl.filename,UniformOutput=false);
valPng=cellfun(@(x) extractBefore(x,'.dcm'),validationDataTbl.filename,UniformOutput=false);
testPng=cellfun(@(x) extractBefore(x,'.dcm'),testDataTbl.filename,UniformOutput=false);
trainingPng=cellfun(@(x) horzcat(x,'.png'),trainingPng,UniformOutput=false);
valPng=cellfun(@(x) horzcat(x,'.png'),valPng,UniformOutput=false);
testPng=cellfun(@(x) horzcat(x,'.png'),testPng,UniformOutput=false);
lds=imageDatastore(trainingPng,"IncludeSubfolders",false,"FileExtensions",'.png','ReadFcn',@imread);
val_lds=imageDatastore(valPng,"IncludeSubfolders",false,'FileExtensions','.png','ReadFcn',@imread);
test_lds=imageDatastore(testPng,"IncludeSubfolders",false,'FileExtensions','.png','ReadFcn',@imread);
% pngとdicomを統合
ds=combine(ids,lds);
val_ds=combine(val_ids,val_lds);
test_ds=combine(test_ids,test_lds);
%% preprocessingはZero paddingして512*512にResizeする関数
dsTrain=transform(ds,@preprocessing);
dsVal=transform(val_ds,@preprocessing);
dsTest=transform(test_ds,@preprocessing);
5 Commenti
Atsushi Ueno
il 24 Mar 2023
> 引数にとるのは、imagedatastoreかと思いますが、combineddatastoreにも適用できるのでしょうか?
⇒ わかりません(よく調べないと即答できません)。augmentedImageDatastore 関数のドキュメントを眺めて何となく判る事は、回帰問題用の入力データは CombinedDatastore としてではなく「予測子(Predictor)(dicom)」と「応答(response)(png)」の引数に分けて入力する仕様の様です。
>image to image回帰を行っているため、response(png)にも予測子(dicom)と同じ画像処理が行われてほしいのですが、可能なのでしょうか?
「予測子側だけの処理(ノイズ付加等)」と「予測子と応答の両方共に同一の処理(回転等)」をする必要があるという事ですね。上記ドキュメントでは「予測子側だけの処理は CombinedDatastore 結合前に transform 関数で実施」「予測子と応答の同一処理は独自の関数を作成し CombinedDatastore に対して実施」しているので、augmentedImageDatastore 関数ではそれが出来ない(細かい所まで手が届かない)のかもしれません。
augmentedImageDatastore 関数に下記の機能があるのかが論点ですね。
- CombinedDatastore を入力する事が可能か(分けて入力する必要がありそう)
- CombinedDatastore の予測子と応答それぞれに対する変換を制御出来るのか
- (↑予測子と応答に分けて入力すれば予測子側だけ変換(水増し)してくれそうだが、
Risposte (0)
Vedere anche
Categorie
Scopri di più su イメージ処理の深層学習 in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!