- 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
조회 수: 13 (최근 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에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!