Evy Lino
Evy Lino

Reputation: 19

Matlab Zooming Using Pixel Replication

I was trying to zoom an image using pixel replication method. The code below has a "Warning: Image is too big to fit on screen;". I don't know if this is the problem with the output. The output is totally displaying something else. Here is a link to the output... 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);

What exactly is the problem, is there any way out?

Upvotes: 0

Views: 6887

Answers (1)

Cape Code
Cape Code

Reputation: 3574

You get a warning because imshow automatically scale the images to fit the screen if they are two big. And it tells you it did.

If you want to force the output to be scaled 1:1, you can use:

imshow(c, 'InitialMagnification', 100);

Upvotes: 1

Related Questions