I have trained 80% of a data image, but want to Rotate and Crop only 10%. How to rotate and crop only the 10% and show cropped image

1 回表示 (過去 30 日間)
clear ;
clc;
imds = imageDatastore('D:\dataimage','IncludeSubfolders',true,'LabelSource','foldernames');
[imdsTrain,imdsValidation,imdsTest] = splitEachLabel(imds,0.8,0.1,0.1);
augimdsTrain = augmentedImageDatastore([227 227],imdsTrain);
augimdsValidation = augmentedImageDatastore([227 227],imdsValidation); % resize image
augimdsTest = augmentedImageDatastore([227 227],imdsTest);
g=ceil((t1.Count*10/100));

回答 (1 件)

Prateek Rai
Prateek Rai 2021 年 9 月 13 日
To my understanding, you have trained 80% of a data image, but want to Rotate and Crop only 10%.
For cropping,you can use ''OutputSizeMode' Name-value pair of 'augmentedImageDatastore' and set it to 'centercrop' or 'randcrop' as per your requirement.
augimdsValidation = augmentedImageDatastore([227 227],imdsValidation,'OutputSizeMode','centercrop');
For rotation, you can use 'imageDataAugmenter' in 'augmentedImageDatastore'. 'imageDataAugmenter' will use 'RandRotation' to set range of rotation.
% imageDataAugmenter use 'RandRotation' to set range of rotation.
augmenter = imageDataAugmenter('RandRotation',[0 360]);
% 'imageDataAugmenter' will passed to 'augmentedImageDatastore' as 'DataAugmentation' Name-Value pair
augimdsValidation = augmentedImageDatastore([227 227],imdsValidation,'DataAugmentation',augmenter);
You can club both to get crop and rotation both:
augmenter = imageDataAugmenter('RandRotation',[0 360]);
augimdsValidation = augmentedImageDatastore([227 227],imdsValidation,'OutputSizeMode','centercrop','DataAugmentation',augmenter);
You can refer to augmentedImageDatastore MathWorks documentation page to find more on augmentedImageDatastore and imageDataAugmenter MathWorks documentation page to find more on imageDataAugmenter.

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by