MATLAB: Resize the images without deforming them

cell arraysdeep learningimage analysisimage processing

Hi
I want to know how to resize images 200 x 200 to 100 x 100 without deforming the images in this code
close all;
clc;
%% Initalize the data
dataDir= fullfile('Data/');
exts = {'.jpg','.png','.tif','BMP'};
imds = imageDatastore(fullfile(dataDir),...
'IncludeSubfolders',true,'FileExtensions','.jpg','LabelSource','foldernames');
countEachLabel(imds);
[TrainData, TestData] = splitEachLabel(imds, 0.5);
size(TrainData);
countEachLabel(TrainData);
numImages = numel(TrainData.Files);
for i = 1:numImages
img = readimage(TrainData, i);
% img2= imshow(img, 'InitialMagnification', 800);
img3= imresize(img, [100 100]);
img4= imshow(img3, 'InitialMagnification', 800);
drawnow;
Train{i} = (img3); %#ok<SAGROW>
end

Best Answer

you're trying to resize 200x200 to 100x100 images.
scale = 0.5;
J = imresize(I,scale); % using scale rather than your final output image didn't work as well?
Related Question