diff --git a/external/history.txt b/external/history.txt index bed22a20..8c00ea7a 100644 --- a/external/history.txt +++ b/external/history.txt @@ -1,5 +1,6 @@ Version NEW -optimized images/imtransform2 + -optimized getPrmDflt. New way of using it too. -minor tweak to images/imrectLite Version 2.02 (31-Oct-07) diff --git a/external/toolboxGenDoc.m b/external/toolboxGenDoc.m index ba42c62d..f67c07fb 100644 --- a/external/toolboxGenDoc.m +++ b/external/toolboxGenDoc.m @@ -6,13 +6,6 @@ % toolbox/external/m2html/templates/frame-piotr/overview.html % 1) The version / date % 2) Link to rar/zip file -% -% After running, remove links to Subsequent directories (*/private and -% */.svn from): -% doc/classify/menu.html -% doc/iamges/menu.html -% doc/filters/menu.html -% doc/matlab/menu.html % % USAGE % toolboxGenDoc @@ -41,3 +34,21 @@ % copy history file copyfile('external\history.txt','doc/history.txt') + +% remove links to .svn and private in the menu.html files +d = { './doc' }; + +while ~isempty(d) + dTmp = dir(d{1}); + for i = 1 : length(dTmp) + name = dTmp(i).name; + if strcmp( name,'.') || strcmp( name,'..'); continue; end + if dTmp(i).isdir; d{end+1} = [ d{1} '/' name ]; continue; end + if ~strcmp( name,'menu.html'); continue; end + fid = fopen( [ d{1} '/' name ], 'r' ); c = fread(fid, '*char')'; fclose( fid ); + c = regexprep( c, '
  • ([^<]*[<]?[^<]*)\.svn([^<]*[<]?[^<]*)
  • ', ''); + c = regexprep( c, '
  • ([^<]*[<]?[^<]*)private([^<]*[<]?[^<]*)
  • ', ''); + fid = fopen( [ d{1} '/' name ], 'w' ); fwrite( fid, c ); fclose( fid ); + end + d(1) = []; +end diff --git a/matlab/getPrmDflt.m b/matlab/getPrmDflt.m index 39eb6b00..d6c8ed3a 100644 --- a/matlab/getPrmDflt.m +++ b/matlab/getPrmDflt.m @@ -30,21 +30,52 @@ function varargout = getPrmDflt( prm, dfs ) -if (iscell(prm)); prm = cell2struct( prm(2:2:end), prm(1:2:end), 2 ); end -if(~isstruct(prm)); error('prm must be a struct'); end -if(mod(length(dfs),2)~=0); error('incorrect num dfs'); end +if(mod(length(dfs),2)~=0); error('odd number of default parameters'); end -for i=1:2:length(dfs) - if( ~isfield(prm,dfs{i}) || isempty(prm.(dfs{i})) ) - if(strcmp('REQ',dfs{i+1})) +if (iscell(prm)) && (nargout~=1) + if(mod(length(prm),2)~=0); error('odd number of parameters'); end + + varargout=dfs(2:2:end); + + for i=1:2:length(dfs) + j = 0; + for k=1:2:length(prm) + if strcmp( dfs{i}, prm{k} ) + j=k; break; + end + end + + if j==0 + if strcmp('REQ',dfs{i+1}) + error(['Required field ''' dfs{i} ''' not specified.'] ); + end + else + varargout{(i+1)*0.5} = prm{j+1}; + end + end +else + if (iscell(prm)); prm = cell2struct( prm(2:2:end), prm(1:2:end), 2 ); end + if(~isstruct(prm)); error('prm must be a struct'); end + + toDo = isfield( prm, dfs(1:2:end) ); + for i=find(~toDo) + if(strcmp('REQ',dfs{2*i})) error(['Required field ''' dfs{i} ''' not specified.'] ); else - prm.(dfs{i})=dfs{i+1}; + prm.(dfs{2*i-1})=dfs{2*i}; + end + end + + if nargout==1 + varargout(1) = {prm}; + else + try + varargout = struct2cell( ordedrfields( prm, dfs ) ); + catch + varargout=cell(1,nargout); + for i=1:2:length(dfs) + varargout((i+1)/2)={prm.(dfs{i})}; + end end end -end -if nargout==1; varargout(1)={prm}; return; end -varargout=cell(1,nargout); -for i=1:2:length(dfs) - varargout((i+1)/2)={prm.(dfs{i})}; end diff --git a/matlab/isfield2.m b/matlab/isfield2.m index 12c022eb..0c6cdefc 100644 --- a/matlab/isfield2.m +++ b/matlab/isfield2.m @@ -1,4 +1,4 @@ -% Similar to isfield but also test whether fields are intitialized. +% Similar to isfield but also test whether fields are initialized. % % A more comprehensive test of what fields are present [and optionally % initialized] in a stuct S. fs is either a single field name or a cell diff --git a/matlab/rotationMatrix.m b/matlab/rotationMatrix.m index 47d71c04..ccc9dbf4 100644 --- a/matlab/rotationMatrix.m +++ b/matlab/rotationMatrix.m @@ -94,7 +94,7 @@ function varargout=rotationMatrix(varargin) -%%% Find the closest rotation matrix +%%% Find the closest orthonormal matrix if all(size(varargin{1})==[3 3]) && nargout<=1 [U,S,V]=svd(varargin{1}); varargout{1}=U*V';