Resize the images without deforming them

Illustration
Ernest - 2020-10-30T09:45:07+00:00
Question: Resize the images without deforming them

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 end

Expert Answer

Profile picture of Prashant Kumar Prashant Kumar answered . 2025-11-20

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?


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!