- Other image augmentation functions that are available in MATLAB: Get Started with Image Preprocessing and Augmentation for Deep Learning - MATLAB & Simulink - MathWorks India
- imwrite function Write image to graphics file - MATLAB imwrite - MathWorks India
imageDataAugmenter saving images separately
24 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I have been having some issues with image augmentation, so in a nutshell what i am trying to do is to have my images augmented then saved indivually in a folder like a regular photo and in a regular folder. for example, in python after I do the augmentation; each augmented image will be saved seperatly as a copy of its original with the same formate in a folder, and that is what i am trying to do here or at least a simialr approach. I have attached my code
clc
clear all
Non_Augmented = 'C:\Users\Main\Desktop\matlab_projects\Non_Augmented';
allImages = imageDatastore(Non_Augmented,"IncludeSubfolders",true,"LabelSource","foldernames");
imageSize = [28 28 1];
imageAugmenter = imageDataAugmenter('RandRotation',[-20,20],'RandXTranslation',[-3 3], 'RandYTranslation',[-3 3]);
auimds = augmentedImageSource([244 244 1],allImages,'DataAugmentation',imageAugmenter);
saveas(gcf,'auimds','tif');
minibatch = read(auimds);
imshow(imtile(minibatch.input))
0 个评论
回答(2 个)
Vinayak Choyyan
2023-2-9
Hello Engineer Undergoing,
As per my understanding, you would like to perform some augmentation on some images and save the augmented images with the same file format.
I see you have tried to use ‘augmentedImageSource()’. This function is primarily intended to be used along with Neural Networks. Along with ‘imageDatastore()’ this function is used to load data into memory (RAM) in batches. Memory is expensive and limited. Loading an entire huge dataset into memory all at once is not feasible. This function hence loads a batch of images, augments it and then feeds it into a neural network for training or testing.
To achieve the results you are looking for, please use the ‘randomAffine2d()’ function. You can read more about this function here Create randomized 2-D affine transformation - MATLAB randomAffine2d - MathWorks India.
Here is also a demo code for the same:
imageFileName="kobi.png";
I = imread(imageFileName);
imshow(I);
tform1 = randomAffine2d(Rotation=[35 55]);
J = imwarp(I,tform1);
imshow(J);
%imwrite(J,"path/to/save/location/"+imageFileName);
I hope this helps resolve the issue you were facing. Please alsorefer to the following documents to read more about the following:
0 个评论
Michael Butchers
2023-12-19
Hi
I'm trying to do the same thing. I've got folders with images that i want to augmentate. Once i have augmentated them, i want to save those images back into the same folder with the original images. The file names of the orginal images are 1, 2, 3, 4, 5 ...etc, so i want the augmentated images to follow suit in the file names i,e. 6, 7, 8, 9 ......
I also need to find the code in which i can create 'x' number of augmentated images. I.e i have 15 original images, and i want to create 50+ more augmentated images using the various augmentated techniques out there.
Any clever person out there that can give me the code for that?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning for Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!