Changing image size with interp1()
조회 수: 1 (최근 30일)
이전 댓글 표시
I am new to MATLAB so I am unfamiliar with many things. One of the tasks that was handed to me to complete was to change the size of the image using interp1(), I have previously asked the similar question and I am able to change my image size from 256x256 to 256x512. I have only succeeded in changing the image size for rows with the following codes:
data1 = imread('lighthouse_half.png');
%lighthouse_half
numcr = 512;
[m,n,p] = size(data1);
iwant = zeros(m,numcr,p);
xi = linspace(1,n,numcr);
for i = 1:m
for j = 1:p
T = interp1(1:n,double(data1(i,:,j)),xi);
iwant(i,:,j) = T;
end
end
iwant = uint8(iwant);
imshow(iwant);
I have been trying to figure how to change both rows and columns so that I get the image size of 512x512, can someone please help?
댓글 수: 0
채택된 답변
KSSV
2018년 5월 30일
data1 = imread('lighthouse_half.png');
%lighthouse_half
numcr = 512; numrr = 512 ;
[m,n,p] = size(data1);
% interpolation along column
iwant1 = zeros(m,numcr,p);
xi = linspace(1,n,numcr);
for i = 1:m
for j = 1:p
T = interp1(1:n,double(data1(i,:,j)),xi);
iwant1(i,:,j) = T;
end
end
[m,n,p] = size(iwant1);
% interpolation along row
iwant2 = zeros(numrr,numcr,p) ;
yi = linspace(1,m,numrr);
for i = 1:n
for j = 1:p
T = interp1(1:m,double(iwant1(:,i,j)),yi);
iwant2(:,i,j) = T;
end
end
iwant2 = uint8(iwant2);
imshow(iwant2);
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!