필터 지우기
필터 지우기

padarray for resizing canvas of images

조회 수: 2 (최근 30일)
dan kin
dan kin 2014년 10월 18일
댓글: Image Analyst 2014년 10월 18일
Hi,
I have multiply PNG images in one folder with different images sizes (height and width), how can I use the padarray function so they will have the same canvas size (according to the bigger image) without resizing them?
Thanks a lot

답변 (1개)

Image Analyst
Image Analyst 2014년 10월 18일
Not hard. Just get the sizes of both, get the max, and figure out what to pass to padarray()
[rows1, columns1, numberOfColorChannels1] = size(image1);
[rows2, columns2, numberOfColorChannels2] = size(image2);
maxRows = max(rows1, rows2);
maxColumns = max(columns1, columns2);
and so on...
  댓글 수: 2
dan kin
dan kin 2014년 10월 18일
Thanks.
Why in the code rows3 and columns3 do not match rows2 and columns2?
Code:
clc;
clear;
img=imread('pears.png');
[rows1, columns1, numberOfColorChannels1] = size(img);
rows2=1000;
columns2=2000;
imgpad = padarray(img,[rows2 columns2],'both');
imshow(imgpad);
[rows3, columns3, numberOfColorChannels1] = size(imgpad);
Image Analyst
Image Analyst 2014년 10월 18일
Because that's not the way to use padarray. Read the instructions. The inputs are the number of rows you want to add, not the overall total rows.

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

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by