画像の一括保存

21 vues (au cours des 30 derniers jours)
Kodai Sato
Kodai Sato le 13 Jan 2020
Réponse apportée : Kenta le 13 Jan 2020
セマンティックセグメンテーションを行うにあたってデータセットを作成するため上のURLを参考にrandomCropWindow2dを使用して画像のランダム抽出を行ったところ,画像を表示させることは出来たのですが,保存されたファイルは真っ白でうまく保存することが出来ません.複数枚の画像を一括で保存する方法を教えてください.
A = imread('1.jpg');
%imshow(A)
targetSize = [96 96];
for i=1:10
wini = randomCropWindow2d(size(A),targetSize);
Bi = imcrop(A,wini);
imshow(Bi)
filename=['image1_',num2str(i),'.png'];
saveas(gcf,filename)
end

Réponse acceptée

Kenta
Kenta le 13 Jan 2020
こんにちは、単に切り出すというだけであれば下のようにすれば可能です。
pauseは見やすくするために書いているので不要です。
またランダムに回転させたり色を変化させたりしながら切り出したかったらこちらをご参照ください。
result.PNG
A = imread('onion.png');
%imshow(A)
targetSize = [96 96];
figure;
for i=1:10
wini = randomCropWindow2d(size(A),targetSize);
Bi = imcrop(A,wini);
imshow(Bi)
pause(.3)
filename=['image1_',num2str(i),'.png'];
imwrite(Bi,filename)
end

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!