イメージデータストア​の画像をノイズ付加や​ガンマ補正で水増しし​たい

10 visualizaciones (últimos 30 días)
Takumi Enomoto
Takumi Enomoto el 31 de Mzo. de 2022
Respondida: Kenta el 9 de Abr. de 2022
イメージデータストアを水増しさせる意図でtransform関数の例を参考に以下のコードを書きました。
しかし、実行すると
使い方によるエラー matlab.io.datastore.TransformedDatastore/read
データストアに定義されている変換関数が無効です。
使い方によるエラー imnoise
1 番目の入力引数 I は次のタイプのいずれかにする必要があります:
uint8, uint16, double, int16, single
指定されたタイプは table でした
という結果になってしまいます。
イメージデータストアの回転や切り抜きの伴わないノイズやブレなどの水増しはどのようにすればよろしいでしょうか。
%Train2=transform(Train,@(x) imnoise(x,'gaussian'));
  1 comentario
Hiroyuki Hishida
Hiroyuki Hishida el 1 de Abr. de 2022
実際に読み込まれているデータや、これ以前のスクリプトが不明なため、具体的なアドバイスがし辛い状況ですが、deep learningのためのaugmentationをされようとしており、そこでエラーが生じているように思われます。仮にそうだとした場合、以下のリンクの、「データストア出力に必要な形式は、ネットワーク アーキテクチャによって異なります。」以降の表が参考になるかもしれません(R2022a現在)
https://jp.mathworks.com/help/deeplearning/ref/trainnetwork.html#mw_199f8be9-53f8-4bac-acdf-2846778f5904

Iniciar sesión para comentar.

Respuesta aceptada

Kenta
Kenta el 9 de Abr. de 2022
こんにちは、MATLABの関数に加えて、よりカスタマイズされたデータ拡張をしたい場合は、以下のファイルを参考にしていただくと良いと思います。
ここでは2つのファイルがあります。1つ目は、質問者様のおっしゃるような、N番目の画像を処理したい場合、
2つ目は、N番目とその他の画像を同時に処理したい場合です。例としては、mixupのような、ある2つの画像を組み合わせて、あらたな画像を作る場合です。
おそらく、今回は1つ目のケースだと思います。
transform関数に適用させる関数としては、以下のような関数を定義していて、この中身をノイズやブレ、またはその組み合わせのコードに書き換えると良いと思います。
function [dataOut,info] = CutOutAug(InputImgs,info)
numImg = size(InputImgs,1);
dataOut = cell(numImg,2);
for idx = 1:numImg
I =InputImgs{idx,1};
% Add salt and pepper noise if you want
% I = imnoise(I,'salt & pepper',0.01);
%
maskHeightMax=round(size(I,1)/2);
maskWidthMax=round(size(I,2)/2);
% randomly define the location, width and height of the mask
x = randi(size(I,1),1);
y = randi(size(I,2),1);
h = randi(min(size(I,1)-x+1,maskHeightMax),1);
w = randi(min(size(I,2)-y+1,maskWidthMax),1);
% fill in the rectangle with gray
I(x:x+h,y:y+w,:)=128;
% resize the image
I = I(1:32,1:32,:);
% prepare for output
dataOut(idx,:) = {I,info.Label(idx)};
end
end

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!