how to get image from specific folder and resize each image and save them is a new folder
Show older comments
i try below code, but it show error at 'thisimage' variable. whats the problem.
clc;
close all;
clear;
OutputFolder = 'D:\Datasets\handwritten-signatures\sample_Signature\edited'; % Set as needed [EDITED]
dinfo = dir('D:\Datasets\handwritten-signatures\sample_Signature\genuine\*.png');% image extension
for K = 1 : length(dinfo)
thisimage = dinfo(K).name;
Img = imread(thisimage);
Y = imshow(Img);
Gray = rgb2gray(Img);
i = imresize(Img, [227, 227], 'bilinear');
imwrite(i, fullfile(OutputFolder, thisimage)); % [EDITED]
end
2 Comments
Jan
on 27 May 2019
"it show error at 'thisimage' variable" - please post the complete error message. For solving a problem it is important to know, what the problem is.
Awais Khan
on 27 May 2019
Accepted Answer
More Answers (1)
Rik
on 27 May 2019
This is how you can provide the full path to imread:
for K = 1 : length(dinfo)
thisimage = dinfo(K).name;
Img = imread(fullfile(dinfo(K).folder,thisimage));
Y = imshow(Img);
Gray = rgb2gray(Img);
i = imresize(Img, [227, 227], 'bilinear');
imwrite(i, fullfile(OutputFolder, thisimage));
end
Categories
Find more on Color Segmentation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!