我试图使用像素复制方法缩放图像。下面的代码有一个"警告:图像太大,无法放在屏幕上;"。我不知道这是否是输出的问题。输出完全显示其他内容。这是输出的链接...https://www.dropbox.com/s/ixl80jwutra8e1a/Q.PNG
Img = handles.Image;
temp = double(imread(Img));
b=temp;
[m,n,colormap]=size(b);
%If RGB Image is given at Input
if colormap==3
x=b(:,:,1);
y=b(:,:,2);
z=b(:,:,3);
end
k=1; %Counter for Row and
l=1; %Column replication
f=2; %Replica factor
for i=1:m %Loop for reading row and
for t=1:f %Row replication
for j=1:n %Loop for reading column and
for t=1:f %Column replication
if colormap==3 %If Image is RGB
c1(k,l)= x(i,j);
c2(k,l)= y(i,j);
c3(k,l)= z(i,j);
else %If Image is grayscale
c(k,l)=b(i,j);
end
l=l+1;
end
end
l=1;
k=k+1;
end
end
if colormap==3 %If Image is RGB
c(:,:,1)=c1;
c(:,:,2)=c2;
c(:,:,3)=c3;
end
axes(handles.axes2);
imshow(c);
问题到底出在哪里,有什么出路吗?
您会收到警告,因为如果图像很大,imshow
自动缩放图像以适应屏幕。它告诉你它确实做到了。
如果要强制输出按 1:1 缩放,可以使用:
imshow(c, 'InitialMagnification', 100);