Make images into the same dimensions

조회 수: 15 (최근 30일)
Tony
Tony 2014년 1월 20일
댓글: Image Analyst 2019년 8월 2일
hello, So i am having trouble making images the same dimensions. I have a library of images and i need help accomplishing this.
i would like to search for the image with the biggest dimensions then have the other images form to that.
i tried useing
imresize(img(i),[376 292], 'bilinear')
just using a base row col but not all of them became the same

채택된 답변

Matt J
Matt J 2014년 1월 20일
편집: Matt J 2014년 1월 20일
Should have worked, as long as you're not really using img(i) (a scalar) to index your images. I assume you mean img{i}, if holding them in a cell array, or something along those lines.
  댓글 수: 1
Tony
Tony 2014년 1월 20일
yea its working i was just doing a few things wrong lol was staring at the thing for a while

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

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 1월 20일
Inside the loop you just check the size of each image
[rows, columns, numberOfColorChannels] = size(theImage);
if rows > mostRows
mostRows = rows;
end
if columns > mostColumns
mostColumns = columns
end
Then do the loop again but call imresize() inside the loop
theImage = imresize(theImage, [mostRows, mostColumns]);
You can save it with the new size if you want, or just process it in the loop with whatever operations you want to do on it.
  댓글 수: 2
Diah Junaidi
Diah Junaidi 2019년 8월 1일
Got this error sir:
Undefined function or variable 'mostRows'.
Error in hitungRMSE (line 21)
if rows > mostRows
Image Analyst
Image Analyst 2019년 8월 2일
You should know the max number of rows that your images have. So just assign that variable to that number. You can find out in many ways, such as with a MATLAB script, or simply by looking at your images in File Explorer and see what it says the sizes are.

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

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by