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 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Prateek Rai
el 13 de Sept. de 2021
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 comentarios
Ver también
Categorías
Más información sobre Geometric Transformation and Image Registration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!