rescaleVolume - rescales an input volume Usage: outVol = rescaleVolume(inVol, ncmap) outVol = rescaleVolume(inVol, minvol, maxvol) rescaleVolume will rescale an input volume in one of two ways, depending on the number of inputs. If given two inputs, rescaleVolume will rescale inVol (the first argument) to be between 1 and ncmap (the number of elements in the colormap, the second argument). If given three inputs, rescaleVolume will rescale inVol (the first argument) to be between minvol (the second argument) and maxvol (the third argument). This function is part of froi, available from http://froi.sourceforge.net and is goverened under the terms of the Artistic License. $Id: rescaleVolume.m,v 1.3 2003/09/23 18:52:04 nknouf Exp $
This function calls:
This function is called by:
0001 function outVol = rescaleVolume(varargin) 0002 % rescaleVolume - rescales an input volume 0003 % 0004 % Usage: outVol = rescaleVolume(inVol, ncmap) 0005 % outVol = rescaleVolume(inVol, minvol, maxvol) 0006 % 0007 % rescaleVolume will rescale an input volume in one of two ways, depending 0008 % on the number of inputs. If given two inputs, rescaleVolume will rescale 0009 % inVol (the first argument) to be between 1 and ncmap (the number of 0010 % elements in the colormap, the second argument). If given three inputs, 0011 % rescaleVolume will rescale inVol (the first argument) to be between minvol 0012 % (the second argument) and maxvol (the third argument). 0013 % 0014 % This function is part of froi, available from http://froi.sourceforge.net 0015 % and is goverened under the terms of the Artistic License. 0016 % 0017 % $Id: rescaleVolume.m,v 1.3 2003/09/23 18:52:04 nknouf Exp $ 0018 0019 0020 if (nargin == 2) 0021 inVol = varargin{1}; 0022 ncmap = varargin{2}; 0023 0024 %% rescales the volume to be between 1 and ncmap 0025 minvol = min(reshape1d(inVol)); 0026 maxvol = max(reshape1d(inVol)); 0027 outVol = floor(ncmap*(inVol - minvol)/(maxvol - minvol)) + 1; 0028 elseif (nargin == 3) 0029 inVol = varargin{1}; 0030 minvol = varargin{2}; 0031 maxvol = varargin{3}; 0032 0033 minin = min(reshape1d(inVol)); 0034 maxin = max(reshape1d(inVol)); 0035 meanin = mean(reshape1d(inVol)); 0036 0037 outVol = (maxvol-minvol)*(inVol - minin)/(maxin - minin) + minvol; 0038 end 0039 0040 return;