필터 지우기
필터 지우기

manual bilinear and nearest neighbor interpolation

조회 수: 3 (최근 30일)
tilak tenneti
tilak tenneti 2014년 11월 10일
편집: Image Analyst 2014년 11월 10일
Hi , i am trying to perform nearest neighbor and bilinear interpolation on a 512*512 image to convert into 1024*1024 as well as 768*768 . i got some code but not able to proceed further with errors such as "undefined function for input argument double" please help me to convert to 1024*1024 as well as 768*768 without using imresize
here is the following code and attached is the image
inputI= imread('lenatest3.jpg');
[r c] = size(inputI);
scale=2;
for i=1: scale *r
for j=1: scale *c
% map from output image location to input image location by nearest neighbor
ii = round( (i-1)*(r-1)/( scale *r-1)+1 );
jj = round( (j-1)*(c-1)/( scale *c-1)+1 );
% assign value
nni(i,j) = inputI(ii,jj);
end
end
% bilinear
scale=2;
blin=uint8(zeros(r*scale,c*scale));
for i=1:1:size(blin,1)-scale
for j=1:1:size(blin,2)-scale
A=im(ceil(i/scale),ceil(j/scale));
B=im(ceil(i/scale)+1,ceil(j/scale));
C=im(ceil(i/scale),ceil(j/scale)+1);
D=im(ceil(i/scale)+1,ceil(j/scale)+1);
ii=mod(i-1,scale)/scale;
jj=mod(j-1,scale)/scale;
blin(i,j)=A+ii*(B-A)+jj*(C-A+ii*(D+A-C-B));
end
end

답변 (1개)

Image Analyst
Image Analyst 2014년 11월 10일
Don't do any of that. Simply call imresize().
  댓글 수: 2
tilak tenneti
tilak tenneti 2014년 11월 10일
thank you sir but as a task of my work i am required to do the manual task of achieving bilinear and nearest neighbor without using imresize().
any help would be appreciated
thanks
Image Analyst
Image Analyst 2014년 11월 10일
편집: Image Analyst 2014년 11월 10일
Why? Is this homework? You didn't tag it as homework. How about interp2()? Or is that not allowed either? Maybe I'll have time to look at it later....

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

Community Treasure Hunt

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

Start Hunting!

Translated by