function [img, size1] = dispp5(fname)
% [img, size]: image matrix and size vector(width,height, max_gray)
fid = fopen(fname, 'r');
fread(fid,3,'char'); %Read P5
while 1>0,
  com = fscanf(fid,'%s',1);
  if (com(1) == '#'),
    while 1>0,
     ch = fread(fid,1,'char');
     if ch == 10,
       break;
     end;
    end;
  else 
    break;
  end;
end;

height = sscanf(com,'%d',1);  
size2 = fscanf(fid,'%d',2);
fread(fid,1,'char');
%height = size(1);
width = size2(1);
size1 = [height; size2];
%img = zeros(width,height);
%for i=1:height
%img(i,:) = fread(fid,width,'uchar');
%end
img = fread(fid,[height, width],'uchar');
img = img';
fclose(fid);
%for i=1:width
%for j=1:height
%      img(i,j) = img1(j,i);
%   end
%end
image(img);
axis('off');
axis('image');
return
