How can I change imge dimensions?

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

Walter Roberson
Walter Roberson 2018년 7월 19일
?? imresize never crops.
imresize can give you a result that looks distorted, if you do not preserve the aspect ratio, but it will not crop.
Simply have tried this:
I = imread('key_orig.jpg');
K = imresize(I,[100 150]);
figure, imshow(K)
imwrite (K,'resized.jpg')
and it works but how to apply it to all images in a folder?
victor
victor 2018년 7월 19일
편집: victor 2018년 7월 19일
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
victor 2018년 7월 20일
Thank you

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

질문:

2018년 7월 19일

편집:

2018년 7월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by