PageRenderTime 52ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/krp_ranros.m

http://github.com/aludnam/MATLAB
Objective C | 194 lines | 191 code | 3 blank | 0 comment | 56 complexity | 17c8056c7800b08d9b8fe6428d391794 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %krp_ranros 'Ranade/Rosenfeld relaxation method for pairing points'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros rp_ranros.pane file
  3. %
  4. % Parameters:
  5. % InputFile: iref 'Reference Image', required: 'reference image'
  6. % InputFile: idist 'Distorted Image', required: 'distorted image'
  7. % InputFile: iweights 'Input Support Weights', required: 'input support weights'
  8. % OutputFile: oweights 'Output Support Weights', required: 'output support weights'
  9. %
  10. % Example: oweights = krp_ranros({iref, idist, iweights}, {'iref','';'idist','';'iweights','';'oweights',''})
  11. %
  12. % Khoros helpfile follows below:
  13. %
  14. % PROGRAM
  15. % rp_ranros - Ranade/Rosenfeld relaxation method for pairing points
  16. %
  17. % DESCRIPTION
  18. % This program performs one iteration of Ranade and
  19. % Rosenfeld's point matching (relaxation) algorithm.
  20. %
  21. % An array of values representing the 'support' given
  22. % to the pairing of reference point 'i' to distortion
  23. % point 'j' is given in the (i,j)th pixel value of the
  24. % input weight data object. This routine uses these
  25. % weights to produce the next iteration of support
  26. % weights.
  27. %
  28. %
  29. %
  30. % EXAMPLES
  31. % See the html tutorial in $REGISTER/examples/html/README_FIRST.html
  32. %
  33. % "SEE ALSO"
  34. %
  35. % RESTRICTIONS
  36. %
  37. % REFERENCES
  38. % Ranade, Sanjay and Azriel Rosenfeld. "Point Pattern
  39. % Matching by Relaxation." PATTERN RECOGNITION.
  40. % Vol. 12, pp 269-75. 1980.
  41. %
  42. % COPYRIGHT
  43. % Copyright (C) 1996 - 1997, University of New Mexico. All rights reserved.
  44. %
  45. function varargout = krp_ranros(varargin)
  46. if nargin ==0
  47. Inputs={};arglist={'',''};
  48. elseif nargin ==1
  49. Inputs=varargin{1};arglist={'',''};
  50. elseif nargin ==2
  51. Inputs=varargin{1}; arglist=varargin{2};
  52. else error('Usage: [out1,..] = krp_ranros(Inputs,arglist).');
  53. end
  54. if size(arglist,2)~=2
  55. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  56. end
  57. narglist={'iref', '__input';'idist', '__input';'iweights', '__input';'oweights', '__output'};
  58. maxval={0,0,0,0};
  59. minval={0,0,0,0};
  60. istoggle=[0,0,0,0];
  61. was_set=istoggle * 0;
  62. paramtype={'InputFile','InputFile','InputFile','OutputFile'};
  63. % identify the input arrays and assign them to the arguments as stated by the user
  64. if ~iscell(Inputs)
  65. Inputs = {Inputs};
  66. end
  67. NumReqOutputs=1; nextinput=1; nextoutput=1;
  68. for ii=1:size(arglist,1)
  69. wasmatched=0;
  70. for jj=1:size(narglist,1)
  71. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  72. wasmatched = 1;
  73. was_set(jj) = 1;
  74. if strcmp(narglist{jj,2}, '__input')
  75. if (nextinput > length(Inputs))
  76. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  77. end
  78. narglist{jj,2} = 'OK_in';
  79. nextinput = nextinput + 1;
  80. elseif strcmp(narglist{jj,2}, '__output')
  81. if (nextoutput > nargout)
  82. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  83. end
  84. if (isempty(arglist{ii,2}))
  85. narglist{jj,2} = 'OK_out';
  86. else
  87. narglist{jj,2} = arglist{ii,2};
  88. end
  89. nextoutput = nextoutput + 1;
  90. if (minval{jj} == 0)
  91. NumReqOutputs = NumReqOutputs - 1;
  92. end
  93. elseif isstr(arglist{ii,2})
  94. narglist{jj,2} = arglist{ii,2};
  95. else
  96. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  97. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  98. end
  99. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  100. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  101. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  102. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  103. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  104. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  105. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  106. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  107. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  108. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  109. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  110. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  111. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  112. end
  113. end
  114. end
  115. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  116. narglist{jj,2} = arglist{ii,2};
  117. end
  118. end
  119. end
  120. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  121. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  122. end
  123. end
  124. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  125. for jj=1:size(narglist,1)
  126. if strcmp(paramtype{jj}, 'Toggle')
  127. if (narglist{jj,2} ==0)
  128. narglist{jj,1} = '';
  129. end;
  130. narglist{jj,2} = '';
  131. end;
  132. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  133. narglist{jj,1} = '';
  134. narglist{jj,2} = '';
  135. end;
  136. if strcmp(narglist{jj,2}, '__input')
  137. if (minval{jj} == 0) % meaning this input is required
  138. if (nextinput > size(Inputs))
  139. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  140. else
  141. narglist{jj,2} = 'OK_in';
  142. nextinput = nextinput + 1;
  143. end
  144. else % this is an optional input
  145. if (nextinput <= length(Inputs))
  146. narglist{jj,2} = 'OK_in';
  147. nextinput = nextinput + 1;
  148. else
  149. narglist{jj,1} = '';
  150. narglist{jj,2} = '';
  151. end;
  152. end;
  153. else
  154. if strcmp(narglist{jj,2}, '__output')
  155. if (minval{jj} == 0) % this is a required output
  156. if (nextoutput > nargout & nargout > 1)
  157. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  158. else
  159. narglist{jj,2} = 'OK_out';
  160. nextoutput = nextoutput + 1;
  161. NumReqOutputs = NumReqOutputs-1;
  162. end
  163. else % this is an optional output
  164. if (nargout - nextoutput >= NumReqOutputs)
  165. narglist{jj,2} = 'OK_out';
  166. nextoutput = nextoutput + 1;
  167. else
  168. narglist{jj,1} = '';
  169. narglist{jj,2} = '';
  170. end;
  171. end
  172. end
  173. end
  174. end
  175. if nargout
  176. varargout = cell(1,nargout);
  177. else
  178. varargout = cell(1,1);
  179. end
  180. global KhorosRoot
  181. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  182. w=['"' KhorosRoot];
  183. else
  184. if ispc
  185. w='"C:\Program Files\dip\khorosBin\';
  186. else
  187. [s,w] = system('which cantata');
  188. w=['"' w(1:end-8)];
  189. end
  190. end
  191. [varargout{:}]=callKhoros([w 'rp_ranros" '],Inputs,narglist);