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 CenterFile Exchange 中查找有关 Geometric 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