Home > GLMdenoise > utilities > imageactual.m

imageactual

PURPOSE ^

function h = imageactual(im)

SYNOPSIS ^

function h = imageactual(im)

DESCRIPTION ^

 function h = imageactual(im)

 <im> is the filename of an image

 in the current figure, display the image specified by <im> at its 
 native resolution (thus, avoiding downsampling or upsampling).
 this is accomplished by changing the position and size of the current
 figure and its axes.  return the handle of the created image.

 note that if <im> is an indexed image and does not have an 
 associated colormap, then we default to the colormap gray(256).

 history:
 - 2013/07/02 - change functionality and clean up

 example:
 imwrite(uint8(255*rand(100,100,3)),'temp.png');
 figure; imageactual('temp.png');

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function h = imageactual(im)
0002 
0003 % function h = imageactual(im)
0004 %
0005 % <im> is the filename of an image
0006 %
0007 % in the current figure, display the image specified by <im> at its
0008 % native resolution (thus, avoiding downsampling or upsampling).
0009 % this is accomplished by changing the position and size of the current
0010 % figure and its axes.  return the handle of the created image.
0011 %
0012 % note that if <im> is an indexed image and does not have an
0013 % associated colormap, then we default to the colormap gray(256).
0014 %
0015 % history:
0016 % - 2013/07/02 - change functionality and clean up
0017 %
0018 % example:
0019 % imwrite(uint8(255*rand(100,100,3)),'temp.png');
0020 % figure; imageactual('temp.png');
0021 
0022 % read image
0023 [im,cmap] = imread(im);
0024 if isempty(cmap)
0025   cmap = gray(256);
0026 end
0027 
0028 % calc
0029 r = size(im,1);
0030 c = size(im,2);
0031 
0032 % change figure position
0033 set(gcf,'Units','points');
0034 pos = get(gcf,'Position');
0035 newx = pos(1) - (c/1.25 - pos(3))/2;
0036 newy = pos(2) - (r/1.25 - pos(4))/2;
0037 set(gcf,'Position',[newx newy c/1.25 r/1.25]);
0038 
0039 % change axis position
0040 set(gca,'Position',[0 0 1 1]);
0041 
0042 % draw image and set axes
0043 h = image(im);
0044 if size(im,3) ~= 3
0045   colormap(cmap);
0046 end
0047 axis equal tight off;

Generated on Fri 01-Aug-2014 12:03:17 by m2html © 2005