MATLAB Answers

victor
0

How can I change imge dimensions?

Asked by victor
on 19 Jul 2018
Latest activity Edited by James Tursa
on 20 Jul 2018
Hi, everyone!
I have a database of images (the number of images may vary) with different dimensions, need to change thier width/high (resize whole image but not crop it) to same one, then save the new images in a separate folder.
I have tried the im.resize function, but the image is cropped and information lost. It is necessary that the integrity of the image does not change, but only its parameters.
Thanks

  6 Comments

victor
on 19 Jul 2018
Have done this:
for k = 1:9
% Create an image filename, and read it in to a variable called imageData.
jpgFileName = strcat('book-0', num2str(k), '.jpg');
if exist(jpgFileName, 'file')
imageData = imread(jpgFileName);
resize = imresize(imageData,[100 150]);
imwrite (resize,'resize.jpg');
else
fprintf('File %s does not exist.\n', jpgFileName);
end
end
how can I save them one by one?
outfilename = strcat('resize_', jpgFileName);
imrewrite(resize, outfilename);
victor
on 20 Jul 2018
Thank you

Sign in to comment.

0 Answers