Code covered by the BSD License  

Highlights from
publish2latex

image thumbnail

publish2latex

by

 

09 Apr 2013 (Updated )

Using full Latex markup in m-files to generate high quality documentation. Version 1.3

imagefigure( imageIn, map, width, alpha );
function H = imagefigure( imageIn, map, width, alpha );
%
% Use: fig1 = imagefigure( image, map );
%       or
%      fig1 = imagefigure( image, map, width );
%      
% Description: This function generates a figure so that the image fills the
%   complete figure space.
%
% Input Parameters:
%   image:  the image to be plotted
%   map:    the colormap which is to be used
%   width (optional): the desired width of the figure in centimeters.
%
% Return Paramerets:
%   H:  The handle to the figure
%
% By: 		Paul O`Leary
% Date:		9 March 2005
% Version:	1.0
% 
% (c) 2005, Instutite for Automation, University of Leoben, Leoben, Austria
% email: automation@unileoben.ac.at, url: automation.unileoben.ac.at
%
% History:
%	Date: 	        Comment:
%   9. March 2005   Original Vereion 1.0
%---------------------------------------------------------------------------

%
Hint = figure;
% Set up the figure width
if nargin == 3
    figWidth = width;
else
    defaultFigureWidth = 12;
    figWidth = defaultFigureWidth; % default figure width
end;
%
% determine the aspect ratio of the image
%
[ny, nx, nz] = size( imageIn );
aspectRatio = ny / nx;
figHeight = figWidth * aspectRatio ;
%
figSize=[1 1 figWidth figHeight];
myAxesPosition=[0 0 1 1];
%
% generate the figure and set its properties. I do this step for step since
% I have experienced difficulties with some versions of MATLAB is this is
% done in one step.
%
set(Hint,'Units' , 'Centimeters','Position',figSize,'PaperUnits','centimeters','PaperPosition',figSize,'papertype','A4');
%
% setup the axis position so that the image fills the figure
%
set(gca,'Position',myAxesPosition);
%
% plot the image
%
if nargin == 4
    imagesc( imageIn, 'alphaData', alpha );
else
    imagesc( imageIn );
end;
%
% generate the colormap if required. This was programmed to solve a problem
% with the colormap( gray ).
%
if isempty( map );
    vals = linspace(0,1,64)';
    map = [vals, vals, vals];
end;
%
colormap(map);
axis image;
axis off;
hold on;
%
% return the handle if required.
%
if nargout == 1
    H = Hint;
end;

Contact us