马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
X=imread('AA.bmp'); <BR>figure; <BR>imshow(X); <BR><BR>[imagewidth,imageheight]=size(X); <BR><BR>width=512; <BR>height=512; <BR>Y=uint8(zeros(width,height)); <BR><BR><BR>wscale=imagewidth/width; <BR>hscale=imageheight/height; <BR><BR>for i=1:width <BR> for j=1:height <BR> x=i*wscale; <BR> y=j*hscale; <BR> if(x==floor(x)) & (y==floor(y)) % x,y are both integer <BR> Y(i,j)=X(int16(x),int16(y)); <BR> else <BR> if(floor(x)==0) | (floor(y)==0) % exceed the index <BR> Y(i,j)=X(1,1); <BR> else <BR> xx=uint16(x+0.5); <BR> yy=uint16(y+0.5); <BR> if(xx==0) | (yy==0) % exceed the index <BR> Y(i,j)=X(1,1); <BR> else <BR> Y(i,j)=X(xx,yy); % replace with the nearest neighbour <BR> end <BR> end <BR> end <BR> end <BR>end <BR> <BR>figure; <BR>imshow(Y) <BR>为什么运行后会显示3副图像? 如何只显示一副? <BR>另外,这个编写的最邻近算法如何运用到图像放大中去? 而不是单纯的用IMRESIZE(M,N,’NERAEST’)? |