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));
0 件のコメント
回答 (1 件)
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.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!